mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 11:50:15 +01:00
🎨 Improve #commonMenu menu (#16147)
This commit is contained in:
parent
2c23d05c7c
commit
3922ca0cd4
7 changed files with 17 additions and 11 deletions
|
|
@ -194,7 +194,7 @@ export class Title {
|
|||
});
|
||||
} else {
|
||||
const iconRect = iconElement.getBoundingClientRect();
|
||||
openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom});
|
||||
openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom}, Constants.MENU_FROM_TITLE_PROTYLE);
|
||||
}
|
||||
});
|
||||
this.element.addEventListener("contextmenu", (event) => {
|
||||
|
|
@ -202,7 +202,7 @@ export class Title {
|
|||
return;
|
||||
}
|
||||
if (getSelection().rangeCount === 0 || iconElement.contains((event.target as HTMLElement))) {
|
||||
openTitleMenu(protyle, {x: event.clientX, y: event.clientY});
|
||||
openTitleMenu(protyle, {x: event.clientX, y: event.clientY}, Constants.MENU_FROM_TITLE_PROTYLE);
|
||||
return;
|
||||
}
|
||||
protyle.toolbar?.element.classList.add("fn__none");
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: string) => {
|
||||
hideTooltip();
|
||||
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
|
||||
window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TITLE) {
|
||||
|
|
@ -38,6 +38,8 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
|||
}, (response) => {
|
||||
window.siyuan.menus.menu.remove();
|
||||
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TITLE);
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover-" + from : "app-" + from);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "copy",
|
||||
label: window.siyuan.languages.copy,
|
||||
|
|
@ -293,7 +295,5 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
|||
/// #else
|
||||
window.siyuan.menus.menu.popup(position);
|
||||
/// #endif
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue