Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/6453

Vanessa7cd8f8f7d06c
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 6e1daa2850..e2a5f624ff 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 983bb7432d..724a54eade 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 be9b270794..9d1ebe2be5 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 {