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/12703

Vanessadb46f8a1c2d6
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index c590e93f36..a574a4a084 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -347,14 +347,21 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
if (operation.action === "unfoldHeading") {
const scrollTop = protyle.contentElement.scrollTop;
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
- if (isInEmbedBlock(item)) {
+ item.removeAttribute("fold");
+ // undo 会走 transaction
+ if (isUndo) {
+ return;
+ }
+ const embedElement = isInEmbedBlock(item)
+ if (embedElement) {
+ embedElement.removeAttribute("data-render");
+ blockRender(protyle, embedElement);
return;
}
if (operation.retData) { // undo 的时候没有 retData
removeUnfoldRepeatBlock(operation.retData, protyle);
item.insertAdjacentHTML("afterend", operation.retData);
}
- item.removeAttribute("fold");
if (operation.data === "remove") {
item.remove();
}
@@ -379,6 +386,10 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
removeFoldHeading(item);
}
});
+ // undo 会走 transaction
+ if (isUndo) {
+ return;
+ }
if (operation.retData) {
operation.retData.forEach((item: string) => {
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${item}"]`).forEach(item => {
@@ -1181,7 +1192,10 @@ const processFold = (operation: IOperation, protyle: IProtyle) => {
if (operation.action === "unfoldHeading") {
const scrollTop = protyle.contentElement.scrollTop;
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
- if (isInEmbedBlock(item)) {
+ const embedElement = isInEmbedBlock(item)
+ if (embedElement) {
+ embedElement.removeAttribute("data-render");
+ blockRender(protyle, embedElement);
return;
}
if (!item.lastElementChild.classList.contains("protyle-attr")) {
@@ -1209,6 +1223,13 @@ const processFold = (operation: IOperation, protyle: IProtyle) => {
protyle.scroll.lastScrollTop = scrollTop;
return;
}
+ protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
+ const embedElement = isInEmbedBlock(item)
+ if (embedElement) {
+ embedElement.removeAttribute("data-render");
+ blockRender(protyle, embedElement);
+ }
+ });
// 折叠标题后未触发动态加载 https://github.com/siyuan-note/siyuan/issues/4168
if (protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "2" &&
!protyle.scroll.element.classList.contains("fn__none") &&