diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index 6e1daa285..e2a5f624f 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -74,6 +74,7 @@ export class Menu { } this.element.innerHTML = ""; + this.element.removeAttribute("data-filetreeid"); // 用于标记文档数右键所选文档 https://ld246.com/article/1667311960383 this.element.classList.add("fn__none"); this.element.style.zIndex = ""; } diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts index 983bb7432..724a54ead 100644 --- a/app/src/menus/navigation.ts +++ b/app/src/menus/navigation.ts @@ -132,6 +132,7 @@ export const initNavigationMenu = (liElement: HTMLElement) => { } }] }).element); + window.siyuan.menus.menu.element.setAttribute("data-filetreeid", notebookId); return window.siyuan.menus.menu; }; @@ -283,6 +284,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement: /// #endif genImportMenu(notebookId, pathString); window.siyuan.menus.menu.append(exportMd(id)); + window.siyuan.menus.menu.element.setAttribute("data-filetreeid", id); return window.siyuan.menus.menu; }; diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index be9b27079..9d1ebe2be 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -865,7 +865,20 @@ const fileTreeKeydown = (event: KeyboardEvent) => { if (!files.element.parentElement.classList.contains("layout__tab--active")) { return false; } - let liElement = files.element.querySelector(".b3-list-item--focus"); + let liElement + const menuId = window.siyuan.menus.menu.element.getAttribute("data-filetreeid") + if (menuId) { + liElement = files.element.querySelector(`li[data-node-id="${menuId}"]`) + if (!liElement) { + liElement = files.element.querySelector(`ul[data-url="${menuId}"] > li`) + } + if (!liElement) { + return; + } + window.siyuan.menus.menu.remove(); + } else { + liElement = files.element.querySelector(".b3-list-item--focus"); + } if (!liElement) { if (event.key.startsWith("Arrow")) { liElement = files.element.querySelector(".b3-list-item"); @@ -1020,7 +1033,6 @@ const fileTreeKeydown = (event: KeyboardEvent) => { return true; } if (event.key === "Delete" || (event.key === "Backspace" && isMac())) { - window.siyuan.menus.menu.remove(); if (isFile) { deleteFile(notebookId, pathString, getDisplayName(liElement.getAttribute("data-name"), false, true)); } else {