Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/14370

Vanessa0ebd5d6d75ae
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 107c89e6a1..c64fc92320 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -263,7 +263,21 @@ const promiseTransaction = () => {
const updateEmbed = (protyle: IProtyle, operation: IOperation) => {
let updatedEmbed = false;
- protyle.wysiwyg.element.querySelectorAll(`[data-type="NodeBlockQueryEmbed"] [data-node-id="${operation.id}"]`).forEach((item) => {
+ const updateEmbedElements = Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-type="NodeBlockQueryEmbed"] [data-node-id="${operation.id}"]`))
+ if (updateEmbedElements.length === 0) {
+ const tempElement = document.createElement("template");
+ tempElement.innerHTML = operation.data;
+ protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => {
+ item.querySelectorAll(`.protyle-wysiwyg__embed`).forEach(embedBlockItem => {
+ const newTempElement = tempElement.content.querySelector(`[data-node-id="${embedBlockItem.getAttribute("data-id")}"]`)
+ if (newTempElement) {
+ updateEmbedElements.push(embedBlockItem.firstElementChild)
+ operation.data = newTempElement.outerHTML
+ }
+ });
+ });
+ }
+ updateEmbedElements.forEach((item) => {
const tempElement = document.createElement("div");
tempElement.innerHTML = operation.data;
tempElement.querySelectorAll('[contenteditable="true"]').forEach(editItem => {