From 2b29d2d5cc8cc1f8b53041ec1db4d3bfda1c3aee Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 18 Sep 2026 04:10:41 -0700 Subject: [PATCH] fix(editor): type table cell rendering --- .../editor/rich-markdown-table-markdown.ts | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/renderer/src/components/editor/rich-markdown-table-markdown.ts b/src/renderer/src/components/editor/rich-markdown-table-markdown.ts index 6015943b88b..c446cc6faf0 100644 --- a/src/renderer/src/components/editor/rich-markdown-table-markdown.ts +++ b/src/renderer/src/components/editor/rich-markdown-table-markdown.ts @@ -64,22 +64,23 @@ function separatorCell(width: number, align: TableCellAlign): string { function extractRows(node: JSONContent, helpers: MarkdownRendererHelpers): TableCell[][] { return (node.content ?? []).map((rowNode) => - (rowNode.content ?? []).map((cellNode) => ({ - text: collapseWhitespace( - (cellNode.content?.length ?? 0) > 1 - ? cellNode.content + (rowNode.content ?? []).map((cellNode) => { + const content = cellNode.content ?? [] + const rendered = + content.length > 1 + ? content .map((child) => helpers.renderChildren(child)) .join(CELL_LINE_SEPARATOR) .split(CELL_LINE_SEPARATOR) .join('\n') .replace(/[ \t]*\r?\n[ \t]*/g, '
') - : cellNode.content - ? helpers.renderChildren(cellNode.content) - : '' - ), - isHeader: cellNode.type === 'tableHeader', - align: normalizeAlign(cellNode.attrs) - })) + : helpers.renderChildren(content) + return { + text: collapseWhitespace(rendered), + isHeader: cellNode.type === 'tableHeader', + align: normalizeAlign(cellNode.attrs) + } + }) ) }