Skip to content

Commit 0c88719

Browse files
gnapserfgamaral
authored andcommitted
fix: check table element before pasting it as a string
1 parent 868f683 commit 0c88719

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/extensions/shared/paste-html-table-as-string.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ const PasteHTMLTableAsString = Extension.create({
3535

3636
// Concatenate all tables into a single string of paragraphs
3737
return tableHTML.reduce((result, table) => {
38-
const { firstElementChild: tableElement } = parseHtmlToElement(
39-
table,
40-
) as {
41-
firstElementChild: HTMLTableElement | null
42-
}
38+
const { firstElementChild: tableElement } = parseHtmlToElement(table)
4339

44-
if (!tableElement) {
40+
if (
41+
!tableElement ||
42+
!(tableElement instanceof HTMLTableElement) ||
43+
!tableElement.rows
44+
) {
4545
return result
4646
}
4747

0 commit comments

Comments
 (0)