From d758a0d2186f50d99d6485888ea5f6fcfbbe04cf Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 13 Oct 2025 17:49:45 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/15989 28&29 --- app/src/menus/protyle.ts | 18 +++++++++++++++++- app/src/protyle/index.ts | 5 ++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index da75a4ab7..c49f1493a 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -2,7 +2,7 @@ import { hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByTag, - hasTopClosestByClassName + hasTopClosestByClassName, isInEmbedBlock } from "../protyle/util/hasClosest"; import {MenuItem} from "./Menu"; import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection"; @@ -2433,6 +2433,22 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement: return {menus, removeMenus, insertMenus, otherMenus, other2Menus}; }; +export const setFoldById = (data: { + id: string, + currentNodeID: string, +}, protyle: IProtyle) => { + Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.id}"]`)).find((item: Element) => { + if (!isInEmbedBlock(item)) { + const operations = setFold(protyle, item, true, false, true, true); + operations.doOperations[0].context = { + focusId: data.currentNodeID, + }; + transaction(protyle, operations.doOperations, operations.undoOperations); + return true; + } + }); +}; + export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: boolean, isRemove?: boolean, addLoading = true, getOperations = false) => { if (nodeElement.getAttribute("data-type") === "NodeListItem" && nodeElement.childElementCount < 4) { diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 06de392dd..86989d811 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -47,7 +47,7 @@ import {getAllModels} from "../layout/getAll"; /// #endif import {isSupportCSSHL} from "./render/searchMarkRender"; import {renderAVAttribute} from "./render/av/blockAttr"; -import {zoomOut} from "../menus/protyle"; +import {setFoldById, zoomOut} from "../menus/protyle"; export class Protyle { @@ -157,6 +157,9 @@ export class Protyle { addLoading(this.protyle, data.msg); } break; + case "unfoldHeading": + setFoldById(data.data, this.protyle); + break; case "transactions": this.onTransaction(data); break;