Skip to content

Commit

Permalink
fix(table): fix merge row show error
Browse files Browse the repository at this point in the history
  • Loading branch information
cycleccc committed Dec 15, 2024
1 parent d298d36 commit 3d5ccfa
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/table-module/src/module/menu/MergeCell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ class MergeCell implements IButtonMenu {

readonly tag = 'button'

private needKeepCell(editor: Editor, trPath: Path): boolean {
// 检查同行是否有其他单元格
const [, rowSibling] = Node.children(editor, trPath)

// 检查同列是否有其他单元格
const parentTable = Editor.parent(editor, trPath)
const hasOtherRows = parentTable[0].children.length > 1

return !!rowSibling || hasOtherRows
}

getValue(_editor: IDomEditor): string | boolean {
// 无需获取 val
return ''
Expand Down Expand Up @@ -111,13 +122,7 @@ class MergeCell implements IButtonMenu {
at: path,
})

const [, sibling] = Node.children(editor, trPath)

if (sibling) {
/**
* 删除节点调整成隐藏节点
* 隐藏节点不会影响 table 布局
*/
if (this.needKeepCell(editor, trPath)) {
Transforms.setNodes(editor, { hidden: true } as TableCellElement, { at: path })
continue
}
Expand Down

0 comments on commit 3d5ccfa

Please sign in to comment.