Vanessa 2024-01-02 12:34:10 +08:00
parent ae2d70f706
commit 594f2935dd
3 changed files with 8 additions and 4 deletions

View file

@ -8,7 +8,9 @@ import {showMessage} from "../../dialog/message";
export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
if (!window.siyuan.menus.menu.element.contains(event.target) && !hasClosestByAttribute(event.target, "data-menu", "true")) {
if (getSelection().rangeCount > 0 && window.siyuan.menus.menu.element.contains(getSelection().getRangeAt(0).startContainer) &&
window.siyuan.menus.menu.element.contains(document.activeElement)) {
window.siyuan.menus.menu.element.contains(document.activeElement) &&
// 点击题头图菜单无法消失
!event.target.parentElement?.classList.contains("protyle-background__img")) {
// https://ld246.com/article/1654567749834/comment/1654589171218#comments
} else {
window.siyuan.menus.menu.remove();

View file

@ -87,8 +87,10 @@ const renderAssetList = (element: Element, k: string, position: IPosition, exts:
};
export const assetMenu = (protyle: IProtyle, position: IPosition, callback?: (url: string) => void, exts?: string[]) => {
window.siyuan.menus.menu.remove();
const menu = new Menu();
const menu = new Menu("background-asset");
if (menu.isOpen) {
return;
}
menu.addItem({
iconHTML: "",
type: "readonly",

View file

@ -18,7 +18,7 @@ export class Menu {
}
this.menu.remove();
if (!this.isOpen) {
this.menu.element.setAttribute("data-name", id);
this.menu.element.setAttribute("data-name", id || "");
this.menu.removeCB = closeCB;
}
}