Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Unify table cell splitting to restore undo and redo https://github.com/siyuan-note/siyuan/issues/19188

Daniel37341e2f3d0f
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 270967c6e0..764a46e804 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -2258,6 +2258,10 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
icon: "iconTableCellsSplit",
label: window.siyuan.languages.cancelMerged,
click: () => {
+ if (protyle.wysiwyg.tableControl) {
+ protyle.wysiwyg.tableControl.splitCell(cellElement);
+ return;
+ }
const oldHTML = nodeElement.outerHTML;
let rowSpan = cellElement.rowSpan;
let currentRowElement: Element = cellElement.parentElement;
diff --git a/app/src/protyle/util/tableControl.ts b/app/src/protyle/util/tableControl.ts
index dbc7b74563..fe68c65677 100644
--- a/app/src/protyle/util/tableControl.ts
+++ b/app/src/protyle/util/tableControl.ts
@@ -2048,8 +2048,8 @@ export class TableControl {
this.scheduleRender();
}
- private splitCell(cell: HTMLTableCellElement) {
- if (!this.selection) {
+ public splitCell(cell: HTMLTableCellElement) {
+ if (!this.wysiwygElement.contains(cell) || !this.selectCellRange(cell, cell)) {
return;
}
const grid = buildTableGrid(this.selection.table);