Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(table): improve type handling for table-cell elements in parseRow… #488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading