An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/9908
Vanessaaa55a11d1c1e
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex e4dc0173d9..6b1218bd37 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -890,6 +890,7 @@ export const turnsIntoTransaction = (options: {let html = "";const doOperations: IOperation[] = [];const undoOperations: IOperation[] = [];+ const tempElement = document.createElement("div");selectsElement.forEach((item, index) => {if ((options.type === "Blocks2Ps" || options.type === "Blocks2Hs") &&item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {@@ -903,7 +904,9 @@ export const turnsIntoTransaction = (options: {undoOperations.push({action: "update",id,- data: item.outerHTML+ data: item.outerHTML,+ parentID: item.parentElement?.getAttribute("data-node-id") || options.protyle.block.parentID || options.protyle.block.rootID,+ previousID: undoOperations[undoOperations.length - 1]?.id || item.previousElementSibling?.getAttribute("data-node-id")});if (!options.isContinue) {@@ -911,7 +914,6 @@ export const turnsIntoTransaction = (options: {item.outerHTML = options.protyle.lute[options.type](item.outerHTML, options.level);} else {if (index === selectsElement.length - 1) {- const tempElement = document.createElement("div");// @ts-ignoretempElement.innerHTML = options.protyle.lute[options.type](html, options.level);item.outerHTML = tempElement.innerHTML;@@ -922,12 +924,43 @@ export const turnsIntoTransaction = (options: {});undoOperations.forEach(item => {const nodeElement = options.protyle.wysiwyg.element.querySelector(`[data-node-id="${item.id}"]`);- doOperations.push({- action: "update",- id: item.id,- data: nodeElement.outerHTML- });+ if (!nodeElement) {+ item.action = "insert";+ doOperations.push({+ action: "delete",+ id: item.id,+ });+ } else {+ doOperations.push({+ action: "update",+ id: item.id,+ data: nodeElement.outerHTML+ });+ }});+ Array.from(tempElement.children).forEach(item => {+ const itemId = item.getAttribute("data-node-id");+ let find = false;+ undoOperations.find(undoItem => {+ if (itemId === undoItem.id) {+ find = true+ return true;+ }+ })+ if (!find) {+ doOperations.push({+ action: "insert",+ id: itemId,+ previousID: item.previousElementSibling?.getAttribute("data-node-id") || undoOperations[0].previousID,+ data: item.outerHTML,+ parentID: item.parentElement?.getAttribute("data-node-id") || options.protyle.block.parentID || options.protyle.block.rootID,+ });+ undoOperations.splice(0, 0, {+ action: "delete",+ id: itemId,+ })+ }+ })transaction(options.protyle, doOperations, undoOperations);processRender(options.protyle.wysiwyg.element);highlightRender(options.protyle.wysiwyg.element);