Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13793

Vanessa2b22ff9aa6ed
diff --git a/app/src/boot/globalEvent/click.ts b/app/src/boot/globalEvent/click.ts
index a2c35d411f..d6b91fb20f 100644
--- a/app/src/boot/globalEvent/click.ts
+++ b/app/src/boot/globalEvent/click.ts
@@ -10,9 +10,8 @@ import {writeText} from "../../protyle/util/compatibility";
import {showMessage} from "../../dialog/message";
import {cancelDrag} from "./dragover";
-export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
- cancelDrag();
- if (!window.siyuan.menus.menu.element.contains(event.target) && !hasClosestByAttribute(event.target, "data-menu", "true")) {
+export const globalClickHideMenu = (element: HTMLElement) => {
+ if (!window.siyuan.menus.menu.element.contains(element) && !hasClosestByAttribute(element, "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)) {
// https://ld246.com/article/1654567749834/comment/1654589171218#comments
@@ -20,6 +19,12 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
window.siyuan.menus.menu.remove();
}
}
+}
+
+export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
+ cancelDrag();
+
+ globalClickHideMenu(event.target);
if (!hasClosestByClassName(event.target, "pdf__outer")) {
hideAllElements(["pdfutil"]);
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index b8abb56a73..8b2493d6c0 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -96,6 +96,7 @@ import {openLink} from "../../editor/openLink";
import {mathRender} from "../render/mathRender";
import {editAssetItem} from "../render/av/asset";
import {img3115} from "../../boot/compatibleVersion";
+import {globalClickHideMenu} from "../../boot/globalEvent/click";
export class WYSIWYG {
public lastHTMLs: { [key: string]: string } = {};
@@ -2590,6 +2591,7 @@ export class WYSIWYG {
hasClosestByClassName(event.target, "iframe");
if (!event.shiftKey && !ctrlIsPressed && selectElement) {
selectElement.classList.add("protyle-wysiwyg--select");
+ globalClickHideMenu(event.target);
event.stopPropagation();
return;
}