Vanessa 2024-12-10 09:13:21 +08:00
parent 6d66c807d0
commit 51501ed4a0

View file

@ -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") {