From 4825e4f461593f036b880b51dba017a829aee7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Garc=C3=ADa?= Date: Tue, 10 Dec 2024 18:06:28 -0300 Subject: [PATCH] fix: check table element before pasting it as a string --- src/extensions/shared/paste-html-table-as-string.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/extensions/shared/paste-html-table-as-string.ts b/src/extensions/shared/paste-html-table-as-string.ts index ae4a1a0b..d0791a4f 100644 --- a/src/extensions/shared/paste-html-table-as-string.ts +++ b/src/extensions/shared/paste-html-table-as-string.ts @@ -35,13 +35,13 @@ const PasteHTMLTableAsString = Extension.create({ // Concatenate all tables into a single string of paragraphs return tableHTML.reduce((result, table) => { - const { firstElementChild: tableElement } = parseHtmlToElement( - table, - ) as { - firstElementChild: HTMLTableElement | null - } + const { firstElementChild: tableElement } = parseHtmlToElement(table) - if (!tableElement) { + if ( + !tableElement || + !(tableElement instanceof HTMLTableElement) || + !tableElement.rows + ) { return result }