diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index 075e12d88..6f95cc192 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -160,10 +160,17 @@ const editKeydown = (app: App, event: KeyboardEvent) => { if (getSelection().rangeCount > 0) { range = getSelection().getRangeAt(0); } + const activePanelElement = document.querySelector(".layout__tab--active"); + let isFileFocus = false; + if (activePanelElement && activePanelElement.classList.contains("sy__file")) { + isFileFocus = true; + } if (range) { window.siyuan.dialogs.find(item => { if (item.editor && item.editor.protyle.element.contains(range.startContainer)) { protyle = item.editor.protyle; + // https://github.com/siyuan-note/siyuan/issues/9384 + isFileFocus = false; return true; } }); @@ -224,11 +231,6 @@ const editKeydown = (app: App, event: KeyboardEvent) => { return false; } } - const activePanelElement = document.querySelector(".layout__tab--active"); - let isFileFocus = false; - if (activePanelElement && activePanelElement.classList.contains("sy__file")) { - isFileFocus = true; - } let searchKey = ""; if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { searchKey = window.siyuan.config.keymap.general.replace.custom; @@ -254,7 +256,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => { return true; } if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) { - if (protyle.title.editElement.contains(range.startContainer)) { + if (protyle.title?.editElement.contains(range.startContainer)) { quickMakeCard(protyle, [protyle.title.element]); } else { const selectElement: Element[] = [];