From a21e72223fdbab14dbf40f654aaf6bf00cb14008 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 25 Sep 2023 09:17:24 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/9254 --- app/src/protyle/wysiwyg/index.ts | 78 ++++++++++++++++---------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index ec9225bc3..1d885eefe 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1836,44 +1836,46 @@ export class WYSIWYG { const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed"); if (embedItemElement) { const embedId = embedItemElement.getAttribute("data-id"); - /// #if MOBILE - openMobileFileById(protyle.app, embedId, [Constants.CB_GET_ALL]); - activeBlur(); - hideKeyboardToolbar(); - /// #else - if (event.shiftKey) { - openFileById({ - app: protyle.app, - id: embedId, - position: "bottom", - action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL], - zoomIn: true - }); - } else if (event.altKey) { - openFileById({ - app: protyle.app, - id: embedId, - position: "right", - action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL], - zoomIn: true - }); - } else if (ctrlIsPressed) { - openFileById({ - app: protyle.app, - id: embedId, - action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL], - keepCursor: true, - zoomIn: true - }); - } else if (!protyle.disabled) { - window.siyuan.blockPanels.push(new BlockPanel({ - app: protyle.app, - targetElement: embedItemElement, - isBacklink: false, - nodeIds: [embedId], - })); - } - /// #endif + fetchPost("/api/block/checkBlockFold", {id: embedId}, (foldResponse) => { + /// #if MOBILE + openMobileFileById(protyle.app, embedId, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]); + activeBlur(); + hideKeyboardToolbar(); + /// #else + if (event.shiftKey) { + openFileById({ + app: protyle.app, + id: embedId, + position: "bottom", + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL], + zoomIn: foldResponse.data + }); + } else if (event.altKey) { + openFileById({ + app: protyle.app, + id: embedId, + position: "right", + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL], + zoomIn: foldResponse.data + }); + } else if (ctrlIsPressed) { + openFileById({ + app: protyle.app, + id: embedId, + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL], + zoomIn: foldResponse.data, + keepCursor: true, + }); + } else if (!protyle.disabled) { + window.siyuan.blockPanels.push(new BlockPanel({ + app: protyle.app, + targetElement: embedItemElement, + isBacklink: false, + nodeIds: [embedId], + })); + } + /// #endif + }); event.stopPropagation(); return; }