Fix Linux key paste issue in tab
This commit is contained in:
parent
4b89022d0c
commit
b87f3b9342
1 changed files with 19 additions and 13 deletions
|
@ -101,20 +101,26 @@ export class Wnd {
|
|||
window.siyuan.menus.menu.remove();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
// 阻止 Linux 中键粘贴
|
||||
if ("linux" === window.siyuan.config.system.os) {
|
||||
const activeElement = document.activeElement;
|
||||
window.addEventListener("paste", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}, {
|
||||
capture: true,
|
||||
once: true
|
||||
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
|
||||
});
|
||||
// 保持原有焦点
|
||||
if (activeElement instanceof HTMLElement) {
|
||||
activeElement.focus();
|
||||
}
|
||||
}, 250);
|
||||
|
||||
// 保持原有焦点
|
||||
if (activeElement instanceof HTMLElement) {
|
||||
activeElement.focus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue