Skip to content

Commit

Permalink
fix(table): improve type handling for table-cell elements in parseRow… (
Browse files Browse the repository at this point in the history
#488)

* fix(table): improve type handling for table-cell elements in parseRowHtml function

* chore: add changeset publish md
  • Loading branch information
cycleccc authored Jan 2, 2025
1 parent cc890b6 commit 31f0207
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/chatty-goats-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@wangeditor-next/table-module': patch
'@wangeditor-next/editor': patch
---

fix(table): improve type handling for table-cell elements in parseRowHtml function
9 changes: 4 additions & 5 deletions packages/table-module/src/module/parse-elem-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ function parseRowHtml(

// 确保是 table-cell 类型
if (DomEditor.getNodeType(child) === 'table-cell') {
// @ts-ignore
const colSpan = child.colSpan || 1
const tableCell = child as TableCellElement
const colSpan = tableCell.colSpan || 1

tableCellChildren.push(child as TableCellElement) // 先添加当前单元格
tableCellChildren.push(tableCell) // 先添加当前单元格

// 如果 colSpan > 1,检查是否存在足够的隐藏 table-cell
for (let j = 1; j < colSpan; j += 1) {
Expand All @@ -74,8 +74,7 @@ function parseRowHtml(
if (
nextChild
&& DomEditor.getNodeType(nextChild) === 'table-cell'
// @ts-ignore
&& nextChild.style?.display === 'none'
&& (nextChild as TableCellElement).hidden
) {
// 已有隐藏的 table-cell,无需补充
continue
Expand Down

0 comments on commit 31f0207

Please sign in to comment.