diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index d403868eb..2f0024529 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -251,9 +251,9 @@ const editKeydown = (app: App, event: KeyboardEvent) => { } let searchKey = ""; if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { - searchKey = window.siyuan.config.keymap.general.replace.custom; + searchKey = Constants.DIALOG_REPLACE; } else if (matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) { - searchKey = window.siyuan.config.keymap.general.search.custom; + searchKey = Constants.DIALOG_SEARCH; } if (!isFileFocus && searchKey) { if (range && protyle.element.contains(range.startContainer)) { @@ -629,9 +629,9 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => { let searchKey = ""; if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { - searchKey = window.siyuan.config.keymap.general.replace.custom; + searchKey = Constants.DIALOG_REPLACE; } else if (matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) { - searchKey = window.siyuan.config.keymap.general.search.custom; + searchKey = Constants.DIALOG_SEARCH; } if (searchKey) { window.siyuan.menus.menu.remove(); @@ -1045,13 +1045,13 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { ["0", "1", "2", "3", "4", "j", "k", "l", ";", "s", " ", "p", "enter"].includes(event.key.toLowerCase())) { let cardElement: Element; window.siyuan.dialogs.find(item => { - if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.riffCard.custom) { + if (item.element.getAttribute("data-key") === Constants.DIALOG_OPENCARD) { cardElement = item.element; return true; } }); if (!cardElement) { - cardElement = document.querySelector(`.layout__wnd--active div[data-key="${window.siyuan.config.keymap.general.riffCard.custom}"]:not(.fn__none)`); + cardElement = document.querySelector(`.layout__wnd--active div[data-key="${Constants.DIALOG_OPENCARD}"]:not(.fn__none)`); } if (cardElement) { event.preventDefault(); @@ -1173,7 +1173,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
`, }); - switchDialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.goToEditTabNext.custom); + switchDialog.element.setAttribute("data-key", Constants.DIALOG_SWITCHTAB); // 需移走光标,否则编辑器会继续监听并执行按键操作 switchDialog.element.querySelector("input").focus(); if (isMac()) { @@ -1190,7 +1190,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { if (isNotCtrl(event) && !event.shiftKey && !event.altKey && (event.key.startsWith("Arrow") || event.key === "Enter")) { const openRecentDocsDialog = window.siyuan.dialogs.find(item => { - if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) { + if (item.element.getAttribute("data-key") === Constants.DIALOG_RECENTDOCS) { return true; } }); @@ -1214,7 +1214,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { if (event.key === "ArrowUp" || event.key === "ArrowDown") { const viewCardsDialog = window.siyuan.dialogs.find(item => { - if (item.element.getAttribute("data-key") === "viewCards") { + if (item.element.getAttribute("data-key") === Constants.DIALOG_VIEWCARDS) { return true; } }); @@ -1654,11 +1654,11 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { let searchKey = ""; if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { - searchKey = window.siyuan.config.keymap.general.replace.custom; + searchKey = Constants.DIALOG_REPLACE; } else if (!hasClosestByClassName(target, "pdf__outer") && matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) { - searchKey = window.siyuan.config.keymap.general.search.custom; + searchKey = Constants.DIALOG_SEARCH; } else if (matchHotKey(window.siyuan.config.keymap.general.globalSearch.custom, event)) { - searchKey = window.siyuan.config.keymap.general.globalSearch.custom; + searchKey = Constants.DIALOG_GLOBALSEARCH; } if (searchKey) { if (getSelection().rangeCount > 0) { diff --git a/app/src/boot/globalEvent/keyup.ts b/app/src/boot/globalEvent/keyup.ts index 5a05b5719..de7cda8b0 100644 --- a/app/src/boot/globalEvent/keyup.ts +++ b/app/src/boot/globalEvent/keyup.ts @@ -12,7 +12,7 @@ export const windowKeyUp = (app: App, event: KeyboardEvent) => { window.siyuan.shiftIsPressed = false; window.siyuan.altIsPressed = false; const switchDialog = window.siyuan.dialogs.find(item => { - if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.goToEditTabNext.custom) { + if (item.element.getAttribute("data-key") === Constants.DIALOG_SWITCHTAB) { return true; } }); diff --git a/app/src/business/openRecentDocs.ts b/app/src/business/openRecentDocs.ts index 35725b44c..5a941ad2d 100644 --- a/app/src/business/openRecentDocs.ts +++ b/app/src/business/openRecentDocs.ts @@ -69,7 +69,7 @@ ${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic export const openRecentDocs = () => { const openRecentDocsDialog = window.siyuan.dialogs.find(item => { - if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) { + if (item.element.getAttribute("data-key") === Constants.DIALOG_RECENTDOCS) { return true; } }); @@ -113,7 +113,7 @@ export const openRecentDocs = () => { } getHTML(response.data, dialog.element, searchElement.value); }); - dialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.recentDocs.custom); + dialog.element.setAttribute("data-key", Constants.DIALOG_RECENTDOCS); dialog.element.addEventListener("click", (event) => { const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item"); if (liElement) { diff --git a/app/src/card/makeCard.ts b/app/src/card/makeCard.ts index 6a90b6fb0..da9dc125b 100644 --- a/app/src/card/makeCard.ts +++ b/app/src/card/makeCard.ts @@ -37,7 +37,7 @@ export const genCardItem = (item: ICardPackage) => { export const makeCard = (app: App, ids: string[]) => { window.siyuan.dialogs.find(item => { - if (item.element.getAttribute("data-key") === "makeCard") { + if (item.element.getAttribute("data-key") === Constants.DIALOG_MAKECARD) { hideElements(["dialog"]); return true; } @@ -67,7 +67,7 @@ export const makeCard = (app: App, ids: string[]) => {