From f8ec38e4167492c8127edfef9195bd8f37c52e73 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 10 May 2023 15:57:15 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/8218 --- app/src/layout/dock/Bookmark.ts | 16 ++++++++++------ app/src/menus/bookmark.ts | 8 +++++++- app/src/mobile/dock/MobileBookmarks.ts | 18 ++++++++++-------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/src/layout/dock/Bookmark.ts b/app/src/layout/dock/Bookmark.ts index d2e3b59ad..e540ae7ef 100644 --- a/app/src/layout/dock/Bookmark.ts +++ b/app/src/layout/dock/Bookmark.ts @@ -73,12 +73,16 @@ export class Bookmark extends Model { this.tree = new Tree({ element: this.element.lastElementChild as HTMLElement, data: null, - click:(element: HTMLElement, event: MouseEvent)=> { - const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action"); - if (actionElement) { - openBookmarkMenu(actionElement.parentElement, event, this); - } else { - const id = element.getAttribute("data-node-id"); + click: (element: HTMLElement, event?: MouseEvent) => { + if (event) { + const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action"); + if (actionElement) { + openBookmarkMenu(actionElement.parentElement, event, this); + return; + } + } + const id = element.getAttribute("data-node-id"); + if (id) { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, diff --git a/app/src/menus/bookmark.ts b/app/src/menus/bookmark.ts index 33471c2ce..19aeeb67a 100644 --- a/app/src/menus/bookmark.ts +++ b/app/src/menus/bookmark.ts @@ -9,6 +9,11 @@ import {isMobile} from "../util/functions"; import {MobileBookmarks} from "../mobile/dock/MobileBookmarks"; export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookmarkObj: Bookmark | MobileBookmarks) => { + if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && + window.siyuan.menus.menu.element.getAttribute("data-name") === "bookmarkMenu") { + window.siyuan.menus.menu.remove(); + return; + } window.siyuan.menus.menu.remove(); const id = element.getAttribute("data-node-id"); if (!id && !window.siyuan.config.readonly) { @@ -79,6 +84,7 @@ export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookma } }).element); } + window.siyuan.menus.menu.element.setAttribute("data-name", "bookmarkMenu"); window.siyuan.menus.menu.element.style.zIndex = "221"; // 移动端被右侧栏遮挡 - window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY}); + window.siyuan.menus.menu.popup({x: event.clientX - 11, y: event.clientY + 11, h: 22}); }; diff --git a/app/src/mobile/dock/MobileBookmarks.ts b/app/src/mobile/dock/MobileBookmarks.ts index fc7f26512..39a0dca08 100644 --- a/app/src/mobile/dock/MobileBookmarks.ts +++ b/app/src/mobile/dock/MobileBookmarks.ts @@ -28,16 +28,18 @@ export class MobileBookmarks { this.tree = new Tree({ element: this.element.querySelector(".bookmarkList") as HTMLElement, data: null, - click: (element: HTMLElement, event: MouseEvent) => { + click: (element: HTMLElement, event?: MouseEvent) => { const id = element.getAttribute("data-node-id"); - const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action"); - if (actionElement) { - openBookmarkMenu(actionElement.parentElement, event, this); - } else { - fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { - openMobileFileById(id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML]); - }); + if (event) { + const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action"); + if (actionElement) { + openBookmarkMenu(actionElement.parentElement, event, this); + return; + } } + fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { + openMobileFileById(id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML]); + }); }, blockExtHTML: '', topExtHTML: ''