🐛(export) fix export column NaN

During the export of tables to PDF, columns
with NaN widths were not handled correctly,
leading to export not exporting.
We now take in case NaN columnwidths.
We update the regressions tests to include
this kind of tables.
This commit is contained in:
Anthony LC
2026-01-20 15:18:13 +01:00
parent f64800727a
commit dcfb1115dd
5 changed files with 26 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ and this project adheres to
### Fixed
- ✅(e2e) fix e2e test for other browsers #1799
- 🐛(export) fix export column NaN #1819
- 🐛(frontend) add fallback for unsupported Blocknote languages #1810
- 🐛(frontend) fix emojipicker closing in tree #1808
- 🐛(frontend) display children in favorite #1782

File diff suppressed because one or more lines are too long

View File

@@ -135,7 +135,7 @@ export const utilTable = (
columnWidths: (number | undefined)[],
) => {
const totalColumnWidthKnown = columnWidths.reduce(
(sum: number, w) => sum + (w ?? 0),
(sum: number, w) => sum + (w && !isNaN(w) ? w : 0),
0,
);
const nbColumnWidthUnknown = columnWidths.filter((w) => !w).length;

View File

@@ -22,6 +22,29 @@ export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
quote: blockMappingQuoteDocx,
image: blockMappingImageDocx,
uploadLoader: blockMappingUploadLoaderDocx,
table: (block, exporter, nestedLevel, numberedListIndex, children) => {
/**
* Nan values are not supported, so we need to replace them with undefined
* to avoid issues during the export.
*/
const { columnWidths } = block.content;
const hasNaN = columnWidths.some(
(width) => typeof width === 'number' && Number.isNaN(width),
);
if (hasNaN) {
block.content.columnWidths = columnWidths.map((width) =>
typeof width === 'number' && Number.isNaN(width) ? undefined : width,
);
}
return docxDefaultSchemaMappings.blockMapping.table(
block,
exporter,
nestedLevel,
numberedListIndex,
children,
);
},
},
inlineContentMapping: {
...docxDefaultSchemaMappings.inlineContentMapping,