Skip to content

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

:art: Improve fold heading editing https://github.com/siyuan-note/siyuan/issues/15848

Daniel48d5f0b78831
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 0eee0314ad..86e5f13de7 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -6,7 +6,7 @@ import {blockRender} from "../render/blockRender";
import {processRender} from "../util/processCode";
import {highlightRender} from "../render/highlightRender";
import {hasClosestBlock, hasClosestByAttribute, hasTopClosestByAttribute, isInEmbedBlock} from "../util/hasClosest";
-import {zoomOut} from "../../menus/protyle";
+import {setFold, zoomOut} from "../../menus/protyle";
import {disabledProtyle, enableProtyle, onGet} from "../util/onGet";
/// #if !MOBILE
import {getAllModels} from "../../layout/getAll";
@@ -1061,6 +1061,10 @@ export const turnsIntoTransaction = (options: {
const undoOperations: IOperation[] = [];
let previousId: string;
selectsElement.forEach((item, index) => {
+ if ((options.type === "Blocks2Ps" || options.type === "Blocks2Hs") &&
+ item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
+ setFold(options.protyle, item, undefined, undefined, false);
+ }
item.classList.remove("protyle-wysiwyg--select");
item.removeAttribute("select-start");
item.removeAttribute("select-end");
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 1690fc9ae0..97f19b859d 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -1559,14 +1559,6 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
}
}
}
-
- if oldNode.HeadingLevel != updatedNode.HeadingLevel {
- // 编辑折叠标题下方块,并且这个块的标题层级发生了变化(比如从 H2 变为 H3 或者从标题块变成段落块),则刷新所有编辑器以保持一致性
- go func() {
- tx.WaitForCommit()
- ReloadProtyle(tree.ID)
- }()
- }
return
}