Vanessa 2025-10-18 11:31:20 +08:00
parent 68cf4c601f
commit 5e67cc22a3
6 changed files with 5 additions and 13 deletions

View file

@ -236,8 +236,6 @@ export abstract class Constants {
public static readonly MENU_BLOCK_SINGLE = "block-single"; // 单选块菜单 public static readonly MENU_BLOCK_SINGLE = "block-single"; // 单选块菜单
public static readonly MENU_BLOCK_MULTI = "block-multi"; // 多选块菜单 public static readonly MENU_BLOCK_MULTI = "block-multi"; // 多选块菜单
public static readonly MENU_TITLE = "titleMenu"; // 文档块菜单 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_MORE = "breadcrumbMore"; // 面包屑更多菜单
public static readonly MENU_BREADCRUMB_MOBILE_PATH = "breadcrumb-mobile-path"; // 移动端面包屑菜单 public static readonly MENU_BREADCRUMB_MOBILE_PATH = "breadcrumb-mobile-path"; // 移动端面包屑菜单

View file

@ -120,7 +120,6 @@ export class Menu {
this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen"); this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen");
this.element.removeAttribute("style"); // zIndex this.element.removeAttribute("style"); // zIndex
this.element.removeAttribute("data-name"); // 标识再次点击不消失 this.element.removeAttribute("data-name"); // 标识再次点击不消失
this.element.removeAttribute("data-subname");
this.element.removeAttribute("data-from"); // 标识是否在浮窗内打开 this.element.removeAttribute("data-from"); // 标识是否在浮窗内打开
this.data = undefined; // 移除数据 this.data = undefined; // 移除数据
} }

View file

@ -32,7 +32,6 @@ import {openByMobile} from "../protyle/util/compatibility";
import {addFilesToDatabase} from "../protyle/render/av/addToDatabase"; import {addFilesToDatabase} from "../protyle/render/av/addToDatabase";
const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => { 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 => { const fileItemElement = Array.from(selectItemElements).find(item => {
if (item.getAttribute("data-type") === "navigation-file") { if (item.getAttribute("data-type") === "navigation-file") {
return true; return true;
@ -204,8 +203,6 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus"); const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
if (selectItemElements.length > 1) { if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements, app); 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 notebookId = liElement.parentElement.getAttribute("data-url");
const name = getNotebookName(notebookId); const name = getNotebookName(notebookId);
@ -711,7 +708,6 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
separatorPosition: "top", separatorPosition: "top",
}); });
} }
window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_DOC);
return window.siyuan.menus.menu; return window.siyuan.menus.menu;
}; };

View file

@ -97,7 +97,7 @@ ${padHTML}
}); });
} else { } else {
const targetRect = target.getBoundingClientRect(); 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.stopPropagation();
event.preventDefault(); event.preventDefault();

View file

@ -194,15 +194,15 @@ export class Title {
}); });
} else { } else {
const iconRect = iconElement.getBoundingClientRect(); 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) => { this.element.addEventListener("contextmenu", (event) => {
if (event.shiftKey) { if (event.shiftKey) {
return; return;
} }
if (iconElement.contains((event.target as HTMLElement))) { if (getSelection().rangeCount === 0 || iconElement.contains((event.target as HTMLElement))) {
openTitleMenu(protyle, {x: event.clientX, y: event.clientY}, Constants.MENU_TITLE_PROTYLE); openTitleMenu(protyle, {x: event.clientX, y: event.clientY});
return; return;
} }
protyle.toolbar?.element.classList.add("fn__none"); protyle.toolbar?.element.classList.add("fn__none");

View file

@ -26,7 +26,7 @@ import {addEditorToDatabase} from "../render/av/addToDatabase";
import {openFileById} from "../../editor/util"; import {openFileById} from "../../editor/util";
import {hasTopClosestByClassName} from "../util/hasClosest"; import {hasTopClosestByClassName} from "../util/hasClosest";
export const openTitleMenu = (protyle: IProtyle, position: IPosition, subname: string) => { export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
hideTooltip(); hideTooltip();
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TITLE) { 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) => { }, (response) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TITLE); 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({ window.siyuan.menus.menu.append(new MenuItem({
id: "copy", id: "copy",
label: window.siyuan.languages.copy, label: window.siyuan.languages.copy,