Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/5785

Vanessaa1f856676ef4
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index a0a86fb4b7..70cb70e2b1 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -82,6 +82,7 @@ const promiseTransaction = () => {
if (!item.lastElementChild.classList.contains("protyle-attr")) {
item.lastElementChild.remove();
}
+ removeUnfoldRepeatBlock(response.data[0].doOperations[0].retData, protyle);
item.insertAdjacentHTML("afterend", response.data[0].doOperations[0].retData);
if (doOperations[0].data === "remove") {
// https://github.com/siyuan-note/siyuan/issues/2188
@@ -216,6 +217,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
const scrollTop = protyle.contentElement.scrollTop;
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
if (operation.retData) { // undo 的时候没有 retData
+ removeUnfoldRepeatBlock(operation.retData, protyle);
item.insertAdjacentHTML("afterend", operation.retData);
}
item.removeAttribute("fold");
@@ -559,6 +561,14 @@ export const turnsIntoOneTransaction = (options: { protyle: IProtyle, selectsEle
hideElements(["gutter"], options.protyle);
};
+const removeUnfoldRepeatBlock = (html:string, protyle:IProtyle) => {
+ const temp = document.createElement("template")
+ temp.innerHTML = html
+ Array.from(temp.content.children).forEach(item => {
+ protyle.wysiwyg.element.querySelector(`:scope > [data-node-id="${item.getAttribute("data-node-id")}"]`)?.remove()
+ })
+}
+
export const turnsIntoTransaction = (options: {
protyle: IProtyle,
selectsElement?: Element[],