Skip to content

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

:bug: Improve temporary expansion of focused container blocks https://github.com/siyuan-note/siyuan/issues/19498

Daniel5f9d6db27539
diff --git a/app/src/protyle/util/focusFold.test.ts b/app/src/protyle/util/focusFold.test.ts
index 829541be01..c65f099818 100644
--- a/app/src/protyle/util/focusFold.test.ts
+++ b/app/src/protyle/util/focusFold.test.ts
@@ -40,6 +40,23 @@ const editor = (elements: FoldElement[]) => ({
} as unknown as IProtyle);
describe("focused list folding", () => {
+ for (const type of ["NodeBlockquote", "NodeCallout", "NodeSuperBlock"]) {
+ it(`temporarily expands ${type} without loading or changing child folds`, async () => {
+ const parent = new FoldElement("parent", type);
+ const child = new FoldElement("child", type);
+ const protyle = editor([parent, child]);
+ await applyFocusFold(protyle, async () => {
+ assert.fail("Container blocks must not load heading content");
+ });
+ assert.equal(parent.getAttribute("fold"), null);
+ assert.equal(child.getAttribute("fold"), "1");
+ protyle.block.showAll = false;
+ applyFocusFold(protyle);
+ assert.equal(parent.getAttribute("fold"), "1");
+ assert.equal(parent.hasAttribute("data-view-fold-source"), false);
+ });
+ }
+
it("temporarily unfolds only the focused item and restores it on exit", () => {
const parent = new FoldElement("parent");
const child = new FoldElement("child");
diff --git a/app/src/protyle/util/focusFold.ts b/app/src/protyle/util/focusFold.ts
index 65f00f4805..92f2931e16 100644
--- a/app/src/protyle/util/focusFold.ts
+++ b/app/src/protyle/util/focusFold.ts
@@ -38,7 +38,8 @@ export const applyFocusFold = (protyle: IProtyle,
}
const element = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`);
const type = element?.getAttribute("data-type");
- if (type !== "NodeListItem" && (type !== "NodeHeading" || !loadHeading)) {
+ if (!["NodeListItem", "NodeBlockquote", "NodeCallout", "NodeSuperBlock"].includes(type) &&
+ (type !== "NodeHeading" || !loadHeading)) {
return;
}
if (!state) {