Skip to content

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

:bug: Update table controls after content changes https://github.com/siyuan-note/siyuan/issues/18564

Daniel82414c8227b6
diff --git a/app/src/protyle/util/tableControl.ts b/app/src/protyle/util/tableControl.ts
index 132b666eff..a15ac0d21e 100644
--- a/app/src/protyle/util/tableControl.ts
+++ b/app/src/protyle/util/tableControl.ts
@@ -369,6 +369,14 @@ export class TableControl {
this.caretCell = undefined;
render = true;
}
+ const controlTables = [
+ this.hoverCell?.closest("table"),
+ this.caretCell?.closest("table"),
+ this.selection?.table,
+ ].filter((table): table is HTMLTableElement => !!table?.isConnected);
+ if (mutations.some(mutation => controlTables.some(table => table.contains(mutation.target)))) {
+ render = true;
+ }
const pinnedTableSelector = '[data-type="NodeTable"][custom-pinthead="true"]';
if (mutations.some(mutation => mutation.type === "attributes" ||
(mutation.target instanceof Element && !!mutation.target.closest(pinnedTableSelector)) ||
@@ -384,6 +392,7 @@ export class TableControl {
attributeFilter: ["custom-pinthead"],
attributes: true,
childList: true,
+ characterData: true,
subtree: true,
});
this.scheduleRender();
@@ -460,11 +469,6 @@ export class TableControl {
this.scheduleRender();
}
}, {signal});
- this.wysiwygElement.addEventListener("input", () => {
- if (this.caretCell?.isConnected || this.selection?.table.isConnected) {
- this.scheduleRender();
- }
- }, {signal});
this.wysiwygElement.addEventListener("pointermove", event => this.handleTablePointerMove(event, false), {signal});
// 手柄和添加按钮(pointer-events: auto)会截获鼠标事件,导致 wysiwygElement 收不到
// pointermove,边缘 hover 检测被卡住(例如鼠标停在 cell 手柄上时无法触发 add-column)。