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/9854

Vanessa99cf40b12d8c
diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts
index 0e86fba2a4..fc860b63d7 100644
--- a/app/src/block/Panel.ts
+++ b/app/src/block/Panel.ts
@@ -215,7 +215,10 @@ export class BlockPanel {
this.element = undefined;
this.targetElement = undefined;
// 移除弹出上使用右键菜单
- window.siyuan.menus.menu.remove();
+ if (window.siyuan.menus.menu.element.dataset.from !== "app") {
+ // https://github.com/siyuan-note/siyuan/issues/9854 右键菜单不是从浮窗中弹出的则不进行移除
+ window.siyuan.menus.menu.remove();
+ }
}
private render() {
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index ef0cf8f9c3..c2a0386deb 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -84,7 +84,7 @@ export class Menu {
}
public addSeparator(index?: number) {
- return this.addItem({type: "separator", index});
+ return this.addItem({type: "separator", index});
}
public addItem(option: IMenu) {
@@ -109,6 +109,7 @@ export class Menu {
this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen");
this.element.removeAttribute("style"); // zIndex
window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失
+ window.siyuan.menus.menu.element.removeAttribute("data-from"); // 标识是否在浮窗内打开
}
public append(element?: HTMLElement, index?: number) {
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 20f9f81b75..66b4955d48 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -279,7 +279,7 @@ export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement
y: rect.top + 26,
h: 26
});
-
+ window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
anchorElement.select();
window.siyuan.menus.menu.removeCB = () => {
if (nodeElement.outerHTML !== oldHTML) {
@@ -583,6 +583,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
y: rect.top + 26,
h: 26
});
+ window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
if (!protyle.disabled) {
window.siyuan.menus.menu.element.querySelector("input").select();
window.siyuan.menus.menu.removeCB = () => {
@@ -1062,6 +1063,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
}
window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY});
+ window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
if (!protyle.disabled) {
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
textElements[0].focus();
@@ -1248,6 +1250,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
y: rect.top + 26,
h: 26
});
+ window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) {
textElements[1].select();
@@ -1384,6 +1387,7 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
y: rect.top + 26,
h: 26
});
+ window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
window.siyuan.menus.menu.element.querySelector("input").select();
};