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

Vanessa84c4d736f941
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index c0de08dcee..75af593cc4 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -102,15 +102,39 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
if (!target) {
return false;
}
- if (hasClosestByClassName(target, "b3-menu") ||
- (target.id && target.tagName !== "svg" && (target.id.startsWith("minder_node") || target.id.startsWith("kity_") || target.id.startsWith("node_")))
+ if ((target.id && target.tagName !== "svg" && (target.id.startsWith("minder_node") || target.id.startsWith("kity_") || target.id.startsWith("node_")))
|| target.classList.contains("counter")
|| target.tagName === "circle"
) {
- // b3-menu 需要处理,(( 后的 hint 上的图表移上去需显示预览
// gutter & mindmap & 文件树上的数字 & 关系图节点不处理
return false;
}
+
+ const avPanelElement = hasClosestByClassName(target, "av__panel")
+ if (avPanelElement) {
+ // 浮窗上点击 av 操作,浮窗不能消失
+ const blockPanel = window.siyuan.blockPanels.find((item) => {
+ if (item.element.style.zIndex < avPanelElement.style.zIndex) {
+ return true;
+ }
+ });
+ if (blockPanel) {
+ return false;
+ }
+ } else {
+ // 浮窗上点击菜单,浮窗不能消失 https://ld246.com/article/1632668091023
+ const menuElement = hasClosestByClassName(target, "b3-menu")
+ if (menuElement) {
+ const blockPanel = window.siyuan.blockPanels.find((item) => {
+ if (item.element.style.zIndex < menuElement.style.zIndex) {
+ return true;
+ }
+ });
+ if (blockPanel) {
+ return false;
+ }
+ }
+ }
popoverTargetElement = hasClosestByAttribute(target, "data-type", "block-ref") as HTMLElement ||
hasClosestByAttribute(target, "data-type", "virtual-block-ref") as HTMLElement;
if (popoverTargetElement && popoverTargetElement.classList.contains("b3-tooltips")) {
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts
index 063f014d59..6e7689c2a5 100644
--- a/app/src/protyle/render/av/relation.ts
+++ b/app/src/protyle/render/av/relation.ts
@@ -192,11 +192,11 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
}
};
-const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, text?: string) => {
+const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, isDetached?: boolean, text?: string) => {
if (type === "selected") {
return `<button data-id="${id}" data-type="setRelationCell" class="b3-menu__item" draggable="true">
<svg class="b3-menu__icon"><use xlink:href="#iconDrag"></use></svg>
- <span class="b3-menu__label">${text}</span>
+ <span class="b3-menu__label${isDetached ? "" : " popover__block"}" ${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'} data-id="${id}">${text}</span>
<svg class="b3-menu__action"><use xlink:href="#iconMin"></use></svg>
</button>`;
}
@@ -207,7 +207,7 @@ const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string,
}
if (type == "unselect") {
return `<button data-id="${id}" class="b3-menu__item" data-type="setRelationCell">
- <span class="b3-menu__label">${text}</span>
+ <span class="b3-menu__label${isDetached ? "" : " popover__block"}" ${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'} data-id="${id}">${text}</span>
<svg class="b3-menu__action"><use xlink:href="#iconAdd"></use></svg>
</button>`;
}
@@ -237,7 +237,7 @@ export const bindRelationEvent = (options: {
if (hasId) {
avData.view.rows.find((item) => {
if (item.id === hasId) {
- selectHTML += genSelectItemHTML("selected", item.id, item.cells[cellIndex].value.block.content || "Untitled");
+ selectHTML += genSelectItemHTML("selected", item.id, item.cells[cellIndex].value.isDetached, item.cells[cellIndex].value.block.content || "Untitled");
return true;
}
});
@@ -245,7 +245,7 @@ export const bindRelationEvent = (options: {
});
avData.view.rows.forEach((item) => {
if (!hasIds.includes(item.id)) {
- html += genSelectItemHTML("unselect", item.id, item.cells[cellIndex].value.block.content || "Untitled");
+ html += genSelectItemHTML("unselect", item.id, item.cells[cellIndex].value.isDetached, item.cells[cellIndex].value.block.content || "Untitled");
}
});
options.menuElement.innerHTML = `<div class="b3-menu__items">${selectHTML || genSelectItemHTML("empty")}
@@ -303,7 +303,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar
newValue.blockIDs.splice(removeIndex, 1);
newValue.contents.splice(removeIndex, 1);
separatorElement.after(target);
- target.outerHTML = genSelectItemHTML("unselect", targetId, target.querySelector(".b3-menu__label").textContent);
+ target.outerHTML = genSelectItemHTML("unselect", targetId, !target.querySelector(".popover__block"), target.querySelector(".b3-menu__label").textContent);
if (!separatorElement.previousElementSibling) {
separatorElement.insertAdjacentHTML("beforebegin", genSelectItemHTML("empty"));
}
@@ -314,7 +314,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar
newValue.blockIDs.push(targetId);
newValue.contents.push(target.textContent.trim());
separatorElement.before(target);
- target.outerHTML = genSelectItemHTML("selected", targetId, target.querySelector(".b3-menu__label").textContent);
+ target.outerHTML = genSelectItemHTML("selected", targetId, !target.querySelector(".popover__block"), target.querySelector(".b3-menu__label").textContent);
if (!separatorElement.nextElementSibling) {
separatorElement.insertAdjacentHTML("afterend", genSelectItemHTML("empty"));
}