Skip to content

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

:bug: Preserve dialog focus during deferred editor click handling

Daniele437d8107b2c
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 1b842ad993..87c7a2fbbf 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -5140,7 +5140,12 @@ export class WYSIWYG {
pushBackByClick(protyle, event.target, {x: event.clientX, y: event.clientY});
}
/// #endif
+ const clickActiveElement = document.activeElement;
setTimeout(() => {
+ // 点击后的延迟处理不能覆盖随后打开的对话框或其他控件的焦点和选区。
+ if (document.activeElement !== clickActiveElement && !this.element.contains(document.activeElement)) {
+ return;
+ }
// 选中后,在选中的文字上点击需等待 range 更新
let newRange = getEditorRange(this.element);
const calloutElement = ["callout", "callout-info", "callout-content"].some(className =>