Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/10821

Vanessa7981945bd36a
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 55ee973351..92e1272a8a 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -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[];
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index bf434f5b02..461c92f4e1 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -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) {
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 5e39c93ce8..43c9e38729 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -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();