Vanessa 2024-04-03 10:43:34 +08:00
parent e7204ac10f
commit 7981945bd3
3 changed files with 5 additions and 2 deletions

View file

@ -177,7 +177,7 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
if (!popoverTargetElement && linkElement && linkElement.getAttribute("data-href")?.startsWith("siyuan://blocks")) {
popoverTargetElement = linkElement;
}
if (!popoverTargetElement) {
if (!popoverTargetElement || window.siyuan.menus.menu?.data.isSameNode(popoverTargetElement)) {
// 移动到弹窗的 loading 元素上,但经过 settimeout 后 loading 已经被移除了
// https://ld246.com/article/1673596577519/comment/1673767749885#comments
let targetElement = target;
@ -269,7 +269,7 @@ const getTarget = (event: MouseEvent & { target: HTMLElement }, aElement: false
};
export const showPopover = async (app: App, showRef = false) => {
if (!popoverTargetElement) {
if (!popoverTargetElement || window.siyuan.menus.menu.data?.isSameNode(popoverTargetElement)) {
return;
}
let ids: string[];

View file

@ -6,6 +6,7 @@ import {Constants} from "../constants";
export class Menu {
public element: HTMLElement;
public data: any; // 用于记录当前菜单的数据
public removeCB: () => void;
private wheelEvent: string;
@ -111,6 +112,7 @@ export class Menu {
this.element.removeAttribute("style"); // zIndex
window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失
window.siyuan.menus.menu.element.removeAttribute("data-from"); // 标识是否在浮窗内打开
window.siyuan.menus.menu.data = undefined; // 移除数据
}
public append(element?: HTMLElement, index?: number) {

View file

@ -604,6 +604,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
h: 26
});
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
window.siyuan.menus.menu.data = element;
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
if (!protyle.disabled) {
window.siyuan.menus.menu.element.querySelector("input").select();