An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Restore table cell math rendering and editing https://github.com/siyuan-note/siyuan/issues/19525
Daniel972b6cb19711
diff --git a/app/src/assets/scss/protyle/_toolbar.scss b/app/src/assets/scss/protyle/_toolbar.scssindex 72c4ff9d75..62d799a49d 100644--- a/app/src/assets/scss/protyle/_toolbar.scss+++ b/app/src/assets/scss/protyle/_toolbar.scss@@ -124,6 +124,7 @@}&-util {+ font-size: var(--b3-font-size);position: fixed;border-radius: var(--b3-border-radius-b);box-shadow: var(--b3-dialog-shadow);diff --git a/app/src/protyle/render/tableCellRichEditor.ts b/app/src/protyle/render/tableCellRichEditor.tsindex 3d76da2800..743a60583b 100644--- a/app/src/protyle/render/tableCellRichEditor.ts+++ b/app/src/protyle/render/tableCellRichEditor.ts@@ -79,7 +79,7 @@ export const applyTableCellRichInlineMark = (owner: IProtyle, cells: HTMLTableCe};export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElement,- navigation?: {key: string, goalX: number}, point?: {x: number, y: number},+ navigation?: {key: string, goalX: number}, point?: {x: number, y: number, target?: Element},restoredSelection?: ReturnType<typeof captureRichCellSelection>) => {if (owner.disabled || !cell.isConnected || activeEditor?.cell === cell) {return;@@ -103,6 +103,10 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElemreturn;}hideElements(["gutter", "toolbar"], owner);+ // 记录预览中被点击的公式位置,在重建单元格后打开对应公式的编辑面板。+ const clickedMath = point?.target?.closest('[data-subtype="math"]');+ const clickedMathIndex = clickedMath && cell.contains(clickedMath) ?+ Array.from(cell.querySelectorAll('[data-subtype="math"]')).indexOf(clickedMath) : -1;const selection = getSelection();const initialRange = selection.rangeCount ? selection.getRangeAt(0) : undefined;const richSelection = cell.hasAttribute(TABLE_CELL_RICH_ATTRIBUTE) ? captureRichCellSelection(cell, selection) : undefined;@@ -244,7 +248,11 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElemfragment.destroy();if (cell.isConnected && host.isConnected) {renderTableCellRich(cell);- renderTableCellRichElements(cell);+ if (cell.hasAttribute(TABLE_CELL_RICH_ATTRIBUTE)) {+ renderTableCellRichElements(cell);+ } else {+ mathRender(cell);+ }}if (activeEditor?.cell === cell) {activeEditor = undefined;@@ -439,6 +447,13 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElemfragment.focus(true);// 进入单元格编辑即按所属表格块同步大纲高亮updateOutlineCurrentBlock(owner, cell);+ if (clickedMathIndex >= 0) {+ const mathElement = fragment.wysiwyg.querySelectorAll('[data-subtype="math"]')[clickedMathIndex];+ if (mathElement) {+ fragment.protyle.toolbar.showRender(fragment.protyle, mathElement);+ return;+ }+ }if (restoredSelection && restoreRichCellSelection(fragment.wysiwyg, restoredSelection)) {undoSelection = restoredSelection;return;diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 2d438b11a0..e259c7a0cc 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -4520,7 +4520,7 @@ export class WYSIWYG {!event.target.closest("a, [data-type~='block-ref'], [data-type~='a'], img")) {event.preventDefault();void import("../render/tableCellRichEditor").then(module => module.openTableCellRichEditor(protyle, richCell,- undefined, {x: event.clientX, y: event.clientY}));+ undefined, {x: event.clientX, y: event.clientY, target: event.target}));return;}if (areProtylePluginExtensionsEnabled(protyle)) {