From 12c9151ab3c999b0c04666b0307356f25957c20e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 17 Nov 2023 22:03:59 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9674 --- app/src/boot/globalEvent/event.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/boot/globalEvent/event.ts b/app/src/boot/globalEvent/event.ts index 3a9543932..b70300a05 100644 --- a/app/src/boot/globalEvent/event.ts +++ b/app/src/boot/globalEvent/event.ts @@ -13,6 +13,8 @@ import {initTabMenu} from "../../menus/tab"; import {getInstanceById} from "../../layout/util"; import {Tab} from "../../layout/Tab"; import {hideTooltip} from "../../dialog/tooltip"; +import {fetchPost} from "../../util/fetch"; +import {openFileById} from "../../editor/util"; export const initWindowEvent = (app: App) => { document.body.addEventListener("mouseleave", () => { @@ -151,6 +153,25 @@ export const initWindowEvent = (app: App) => { event.preventDefault(); return; } + + const backlinkBreadcrumbItemElement = hasClosestByClassName(target, "protyle-breadcrumb__item"); + if (backlinkBreadcrumbItemElement) { + const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id")||backlinkBreadcrumbItemElement.getAttribute("data-node-id"); + if (breadcrumbId) { + fetchPost("/api/block/checkBlockFold", {id: breadcrumbId}, (foldResponse) => { + openFileById({ + app, + id: breadcrumbId, + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], + zoomIn: foldResponse.data + }); + window.siyuan.menus.menu.remove(); + }); + } + event.stopImmediatePropagation(); + event.preventDefault(); + return; + } } }, false); };