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/pull/13395

Vanessa51501ed4a0d3
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index 9b00bfda3a..e801442a03 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -37,7 +37,7 @@ import {Asset} from "../asset";
import {newFile} from "../util/newFile";
import {MenuItem} from "../menus/Menu";
import {escapeHtml} from "../util/escape";
-import {isWindow} from "../util/functions";
+import {getFrontend, isWindow} from "../util/functions";
import {hideAllElements} from "../protyle/ui/hideElements";
import {focusByOffset, getSelectionOffset} from "../protyle/util/selection";
import {Custom} from "./dock/Custom";
@@ -101,26 +101,24 @@ export class Wnd {
window.siyuan.menus.menu.remove();
event.stopPropagation();
event.preventDefault();
- const activeElement = document.activeElement;
- const pasteHandler = (e: ClipboardEvent) => {
- e.preventDefault();
- e.stopPropagation();
- };
- window.addEventListener("paste", pasteHandler, {
- capture: true,
- once: true
- });
-
- // 如果在短时间内没有 paste 事件发生,移除监听
- setTimeout(() => {
- window.removeEventListener("paste", pasteHandler, {
- capture: true
+ const frontend = getFrontend()
+ if ((["desktop", "desktop-window"].includes(frontend) && window.siyuan.config.system.os === "linux") ||
+ (frontend === "browser-desktop" && navigator.userAgent.indexOf("Linux") !== -1)) {
+ const activeElement = document.activeElement;
+ window.addEventListener("paste", this.#preventPast, {
+ capture: true,
+ once: true
});
- }, 250);
-
- // 保持原有焦点
- if (activeElement instanceof HTMLElement) {
- activeElement.focus();
+ // TODO 保持原有焦点?https://github.com/siyuan-note/siyuan/pull/13395/files#r1877004077
+ if (activeElement instanceof HTMLElement) {
+ activeElement.focus();
+ }
+ // 如果在短时间内没有 paste 事件发生,移除监听
+ setTimeout(() => {
+ window.removeEventListener("paste", this.#preventPast, {
+ capture: true
+ });
+ }, Constants.TIMEOUT_INPUT);
}
break;
}
@@ -610,6 +608,11 @@ export class Wnd {
}
}
+ #preventPast(event: ClipboardEvent) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+
private renderTabList(target: HTMLElement) {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "tabList") {