Skip to content

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

:recycle: https://github.com/siyuan-note/siyuan/pull/16141

Vanessa5e67cc22a307
diff --git a/app/src/constants.ts b/app/src/constants.ts
index c0b78cb349..c70af26719 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -236,8 +236,6 @@ export abstract class Constants {
public static readonly MENU_BLOCK_SINGLE = "block-single"; // 单选块菜单
public static readonly MENU_BLOCK_MULTI = "block-multi"; // 多选块菜单
public static readonly MENU_TITLE = "titleMenu"; // 文档块菜单
- public static readonly MENU_TITLE_PROTYLE = "title-protyle"; // 在 Protyle 触发的文档块菜单
- public static readonly MENU_TITLE_BREADCRUMB = "title-breadcrumb"; // 在面包屑触发的文档块菜单
public static readonly MENU_BREADCRUMB_MORE = "breadcrumbMore"; // 面包屑更多菜单
public static readonly MENU_BREADCRUMB_MOBILE_PATH = "breadcrumb-mobile-path"; // 移动端面包屑菜单
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 7d98235928..209c91cc7d 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -120,7 +120,6 @@ export class Menu {
this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen");
this.element.removeAttribute("style"); // zIndex
this.element.removeAttribute("data-name"); // 标识再次点击不消失
- this.element.removeAttribute("data-subname");
this.element.removeAttribute("data-from"); // 标识是否在浮窗内打开
this.data = undefined; // 移除数据
}
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index dad7dbfbe8..da764a800a 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -32,7 +32,6 @@ import {openByMobile} from "../protyle/util/compatibility";
import {addFilesToDatabase} from "../protyle/render/av/addToDatabase";
const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
- window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_DOCS);
const fileItemElement = Array.from(selectItemElements).find(item => {
if (item.getAttribute("data-type") === "navigation-file") {
return true;
@@ -204,8 +203,6 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements, app);
- } else {
- window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_NOTEBOOK);
}
const notebookId = liElement.parentElement.getAttribute("data-url");
const name = getNotebookName(notebookId);
@@ -711,7 +708,6 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
separatorPosition: "top",
});
}
- window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_DOC);
return window.siyuan.menus.menu;
};
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts
index 8dbca467d3..48d55556e0 100644
--- a/app/src/protyle/breadcrumb/index.ts
+++ b/app/src/protyle/breadcrumb/index.ts
@@ -97,7 +97,7 @@ ${padHTML}
});
} else {
const targetRect = target.getBoundingClientRect();
- openTitleMenu(protyle, {x: targetRect.right, y: targetRect.bottom, isLeft: true}, Constants.MENU_TITLE_BREADCRUMB);
+ openTitleMenu(protyle, {x: targetRect.right, y: targetRect.bottom, isLeft: true});
}
event.stopPropagation();
event.preventDefault();
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index a489c389c6..5aa47dbbda 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -194,15 +194,15 @@ export class Title {
});
} else {
const iconRect = iconElement.getBoundingClientRect();
- openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom}, Constants.MENU_TITLE_PROTYLE);
+ openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom});
}
});
this.element.addEventListener("contextmenu", (event) => {
if (event.shiftKey) {
return;
}
- if (iconElement.contains((event.target as HTMLElement))) {
- openTitleMenu(protyle, {x: event.clientX, y: event.clientY}, Constants.MENU_TITLE_PROTYLE);
+ if (getSelection().rangeCount === 0 || iconElement.contains((event.target as HTMLElement))) {
+ openTitleMenu(protyle, {x: event.clientX, y: event.clientY});
return;
}
protyle.toolbar?.element.classList.add("fn__none");
diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.ts
index 7e8e78e034..8bf1cc2bbb 100644
--- a/app/src/protyle/header/openTitleMenu.ts
+++ b/app/src/protyle/header/openTitleMenu.ts
@@ -26,7 +26,7 @@ import {addEditorToDatabase} from "../render/av/addToDatabase";
import {openFileById} from "../../editor/util";
import {hasTopClosestByClassName} from "../util/hasClosest";
-export const openTitleMenu = (protyle: IProtyle, position: IPosition, subname: string) => {
+export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
hideTooltip();
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TITLE) {
@@ -38,7 +38,6 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition, subname: s
}, (response) => {
window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TITLE);
- window.siyuan.menus.menu.element.setAttribute("data-subname", subname);
window.siyuan.menus.menu.append(new MenuItem({
id: "copy",
label: window.siyuan.languages.copy,