Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/9384

Vanessaa3094fe3ead6
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index 075e12d88b..6f95cc192d 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[] = [];