Skip to content

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

:bug: Prevent heading fold errors in empty search previews https://github.com/siyuan-note/siyuan/issues/19578

Danield1fc31df8c31
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 7df2185bb2..6b697f26a9 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -865,6 +865,7 @@ export const onTransaction = (protyle: IProtyle, operations: IOperation[], isUnd
return;
}
if (operation.action === "foldHeading") {
+ const hadContent = protyle.wysiwyg.element.childElementCount > 0;
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
item.setAttribute("fold", "1");
if (!operation.retData) {
@@ -889,7 +890,7 @@ export const onTransaction = (protyle: IProtyle, operations: IOperation[], isUnd
});
// 折叠移除子块后,刷新折叠标题所在超级块的拖拽手柄(子块数变化)
refreshSbs(...Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`)));
- if (protyle.wysiwyg.element.childElementCount === 0) {
+ if (hadContent && protyle.block.rootID && protyle.wysiwyg.element.childElementCount === 0) {
zoomOut({
protyle,
id: protyle.block.rootID,