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/9521
Vanessa1c8983e1f891
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex b1e3dd7155..67287df95b 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -1064,12 +1064,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {editorElement.querySelectorAll(".protyle-wysiwyg--empty").forEach(item => {item.classList.remove("protyle-wysiwyg--empty");});-- // 需重新渲染 https://github.com/siyuan-note/siyuan/issues/7574- protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach(item => {- item.removeAttribute("data-render");- blockRender(protyle, item);- });}dragoverElement = undefined;}diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 1f583a11b0..2db8d7ce83 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -69,6 +69,8 @@ const promiseTransaction = (options: {skipSync: boolean}) => {const protyle = options.protyle;+ // 受影响的嵌入块需推迟到事务提交后再渲染,否则其查询请求会早于写入到达内核而拿到旧数据+ const pendingEmbedElements: Element[] = [];/// #if MOBILEif (((0 !== window.siyuan.config.sync.provider && isPaidUser()) ||(0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&@@ -141,9 +143,8 @@ const promiseTransaction = (options: {}// 更新嵌入块protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => {- if (item.querySelector(`[data-node-id="${operation.id}"]`)) {- item.removeAttribute("data-render");- blockRender(protyle, item);+ if (item.querySelector(`[data-node-id="${operation.id}"]`) && !pendingEmbedElements.includes(item)) {+ pendingEmbedElements.push(item);}});hideElements(["gutter"], protyle);@@ -195,9 +196,8 @@ const promiseTransaction = (options: {}// 更新嵌入块protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => {- if (item.querySelector(`[data-node-id="${operation.id}"],[data-node-id="${operation.parentID}"],[data-node-id="${operation.previousID}"]`)) {- item.removeAttribute("data-render");- blockRender(protyle, item);+ if (item.querySelector(`[data-node-id="${operation.id}"],[data-node-id="${operation.parentID}"],[data-node-id="${operation.previousID}"]`) && !pendingEmbedElements.includes(item)) {+ pendingEmbedElements.push(item);}});// 移动块(含撤销移动)后刷新相关超级块的拖拽手柄,避免手柄残留/缺失@@ -278,9 +278,8 @@ const promiseTransaction = (options: {}// 仅在 alt+click 箭头折叠时才会触发protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => {- if (item.querySelector(`[data-node-id="${operation.id}"]`)) {- item.removeAttribute("data-render");- blockRender(protyle, item);+ if (item.querySelector(`[data-node-id="${operation.id}"]`) && !pendingEmbedElements.includes(item)) {+ pendingEmbedElements.push(item);}});}@@ -323,6 +322,13 @@ const promiseTransaction = (options: {}});}+ // 事务提交后再渲染嵌入块,避免其查询请求早于写入到达内核而拿到旧数据+ pendingEmbedElements.forEach(item => {+ if (item.isConnected) {+ item.removeAttribute("data-render");+ blockRender(protyle, item);+ }+ });});};@@ -810,15 +816,13 @@ export const onTransaction = (protyle: IProtyle, operations: IOperation[], isUndfocusByWbr(protyle.wysiwyg.element, range);}}- // 更新 ws 嵌入块,undo 会在 transaction 中更新- if (!isUndo) {- protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => {- if (item.querySelector(`[data-node-id="${operation.id}"],[data-node-id="${operation.parentID}"],[data-node-id="${operation.previousID}"]`)) {- item.removeAttribute("data-render");- blockRender(protyle, item);- }- });- }+ // 更新嵌入块。undo 已由 kernel 执行事务后广播,查询能拿到最新数据,无竞态。+ protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => {+ if (item.querySelector(`[data-node-id="${operation.id}"],[data-node-id="${operation.parentID}"],[data-node-id="${operation.previousID}"]`)) {+ item.removeAttribute("data-render");+ blockRender(protyle, item);+ }+ });// 移动块(含重做/同步)后刷新相关超级块的拖拽手柄[operation.id, operation.parentID, operation.previousID].forEach(blockId => {if (blockId) {