-
-
Notifications
You must be signed in to change notification settings - Fork 601
fix: Table column widths not being set in exported HTML #1947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
this.name, | ||
"table", | ||
{ | ||
...(this.options.domAttributes?.blockContent || {}), | ||
...(this.options.domAttributes?.blockContent || { fesfes: "fesfes" }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this?
renderHTML({ HTMLAttributes }) { | ||
return ["p", HTMLAttributes, 0]; | ||
renderHTML({ node, HTMLAttributes }) { | ||
return ["p", HTMLAttributes, node.childCount ? 0 : ["br"]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a break?
// Need to manually add column widths. | ||
const cols: HTMLTableColElement[] = []; | ||
for (const tableCell of node.children[0].children) { | ||
const colWidths: null | (number | undefined)[] = | ||
tableCell.attrs["colwidth"]; | ||
|
||
if (colWidths) { | ||
for (const colWidth of tableCell.attrs["colwidth"]) { | ||
const col = document.createElement("col"); | ||
if (colWidth) { | ||
col.style = `width: ${colWidth}px`; | ||
} | ||
|
||
cols.push(col); | ||
} | ||
} else { | ||
cols.push(document.createElement("col")); | ||
} | ||
} | ||
|
||
const colGroup = document.createElement("colgroup"); | ||
for (const col of cols) { | ||
colGroup.appendChild(col); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Need to manually add column widths. | |
const cols: HTMLTableColElement[] = []; | |
for (const tableCell of node.children[0].children) { | |
const colWidths: null | (number | undefined)[] = | |
tableCell.attrs["colwidth"]; | |
if (colWidths) { | |
for (const colWidth of tableCell.attrs["colwidth"]) { | |
const col = document.createElement("col"); | |
if (colWidth) { | |
col.style = `width: ${colWidth}px`; | |
} | |
cols.push(col); | |
} | |
} else { | |
cols.push(document.createElement("col")); | |
} | |
} | |
const colGroup = document.createElement("colgroup"); | |
for (const col of cols) { | |
colGroup.appendChild(col); | |
} | |
// Need to manually add colgroup element | |
const colGroup = document.createElement("colgroup"); | |
for (const tableCell of node.children[0].children) { | |
const colWidths: null | (number | undefined)[] = | |
tableCell.attrs["colwidth"]; | |
if (colWidths) { | |
for (const colWidth of tableCell.attrs["colwidth"]) { | |
const col = document.createElement("col"); | |
if (colWidth) { | |
col.style = `width: ${colWidth}px`; | |
} | |
colGroup.appendChild(col); | |
} | |
} else { | |
colGroup.appendChild(document.createElement("col")); | |
} | |
} |
Just makes it a bit clearer what is happening here without the extra insertion loop
Closes #1574
TODO: Empty paragraphs should also include a line break for correct row height.