This commit is contained in:
parent
16564ed002
commit
90f1798dff
4 changed files with 15 additions and 13 deletions
|
@ -47,14 +47,12 @@ export const initWindowEvent = (app: App) => {
|
|||
}
|
||||
});
|
||||
|
||||
let switchDialog: Dialog;
|
||||
|
||||
window.addEventListener("keyup", (event) => {
|
||||
windowKeyUp(app, event, switchDialog);
|
||||
windowKeyUp(app, event);
|
||||
});
|
||||
|
||||
window.addEventListener("keydown", (event) => {
|
||||
windowKeyDown(app, event, switchDialog);
|
||||
windowKeyDown(app, event);
|
||||
});
|
||||
|
||||
window.addEventListener("blur", () => {
|
||||
|
|
|
@ -57,7 +57,7 @@ import {commandPanel} from "../../plugin/commandPanel";
|
|||
import {toggleDockBar} from "../../layout/dock/util";
|
||||
import {workspaceMenu} from "../../menus/workspace";
|
||||
|
||||
const switchDialogEvent = (app: App, event: MouseEvent, switchDialog: Dialog) => {
|
||||
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
let target = event.target as HTMLElement;
|
||||
while (!target.isSameNode(switchDialog.element)) {
|
||||
|
@ -815,8 +815,8 @@ const panelTreeKeydown = (app: App, event: KeyboardEvent) => {
|
|||
return false;
|
||||
};
|
||||
|
||||
export const windowKeyDown = (app: App, event: KeyboardEvent, switchDialog: Dialog) => {
|
||||
|
||||
let switchDialog: Dialog
|
||||
export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||
if (document.querySelector(".av__mask") || document.getElementById("errorLog") || event.isComposing) {
|
||||
return;
|
||||
}
|
||||
|
@ -942,15 +942,16 @@ export const windowKeyDown = (app: App, event: KeyboardEvent, switchDialog: Dial
|
|||
<div class="switch-doc__path"></div>
|
||||
</div>`,
|
||||
});
|
||||
switchDialog.element.setAttribute("data-key", "⌃⇥");
|
||||
// 需移走光标,否则编辑器会继续监听并执行按键操作
|
||||
switchDialog.element.querySelector("input").focus();
|
||||
if (isMac()) {
|
||||
switchDialog.element.addEventListener("contextmenu", (event) => {
|
||||
switchDialogEvent(app, event, switchDialog);
|
||||
switchDialogEvent(app, event);
|
||||
});
|
||||
}
|
||||
switchDialog.element.addEventListener("click", (event) => {
|
||||
switchDialogEvent(app, event, switchDialog);
|
||||
switchDialogEvent(app, event);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import {Dialog} from "../../dialog";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {escapeHtml} from "../../util/escape";
|
||||
import {openCard} from "../../card/openCard";
|
||||
|
@ -6,10 +5,15 @@ import {getDockByType} from "../../layout/util";
|
|||
import {getAllTabs} from "../../layout/getAll";
|
||||
import {App} from "../../index";
|
||||
|
||||
export const windowKeyUp = (app: App,event:KeyboardEvent, switchDialog:Dialog) => {
|
||||
export const windowKeyUp = (app: App,event:KeyboardEvent) => {
|
||||
window.siyuan.ctrlIsPressed = false;
|
||||
window.siyuan.shiftIsPressed = false;
|
||||
window.siyuan.altIsPressed = false;
|
||||
const switchDialog = window.siyuan.dialogs.find(item => {
|
||||
if (item.element.getAttribute("data-key") === "⌃⇥") {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (switchDialog && switchDialog.element.parentElement) {
|
||||
if (event.key === "Tab") {
|
||||
let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
|
||||
|
@ -112,7 +116,6 @@ export const windowKeyUp = (app: App,event:KeyboardEvent, switchDialog:Dialog)
|
|||
});
|
||||
}
|
||||
switchDialog.destroy();
|
||||
switchDialog = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ const getRightBlock = (element: HTMLElement, x: number, y: number) => {
|
|||
return nodeElement;
|
||||
};
|
||||
|
||||
export const windowMouseMove = (event: MouseEvent & { target: HTMLElement }, mouseIsEnter:boolean) => {
|
||||
export const windowMouseMove = (event: MouseEvent & { target: HTMLElement }, mouseIsEnter: boolean) => {
|
||||
if (document.body.classList.contains("body--blur")) {
|
||||
// 非激活状态下不执行 https://ld246.com/article/1693474547631
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue