diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index 451f90c49..98b70aa35 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -377,6 +377,29 @@ export const globalShortcut = () => { } } + if (switchDialog && event.ctrlKey && !event.metaKey && event.key.startsWith("Arrow")) { + const currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus"); + if (currentLiElement) { + currentLiElement.classList.remove("b3-list-item--focus"); + if (event.key === "ArrowUp") { + if (currentLiElement.previousElementSibling) { + currentLiElement.previousElementSibling.classList.add("b3-list-item--focus"); + } else { + currentLiElement.parentElement.lastElementChild.classList.add("b3-list-item--focus"); + } + } else if (event.key === "ArrowDown") { + if (currentLiElement.nextElementSibling) { + currentLiElement.nextElementSibling.classList.add("b3-list-item--focus"); + } else { + currentLiElement.parentElement.firstElementChild.classList.add("b3-list-item--focus"); + } + } else { + const sideElement = currentLiElement.parentElement.previousElementSibling|| currentLiElement.parentElement.nextElementSibling; + (sideElement.querySelector(`[data-index="${currentLiElement.getAttribute("data-index")}"]`)|| sideElement.lastElementChild).classList.add("b3-list-item--focus"); + } + } + return; + } if (event.ctrlKey && !event.metaKey && event.key === "Tab") { if (switchDialog && switchDialog.element.parentElement) { return; @@ -390,7 +413,7 @@ export const globalShortcut = () => { const currentId = currentTabElement.getAttribute("data-id"); getAllTabs().sort((itemA, itemB) => { return itemA.headElement.getAttribute("data-activetime") > itemB.headElement.getAttribute("data-activetime") ? -1 : 1; - }).forEach(item => { + }).forEach((item, index) => { let icon = ``; let rootId = ""; const initData = item.headElement.getAttribute("data-initdata"); @@ -401,12 +424,12 @@ export const globalShortcut = () => { rootId = ` data-node-id="${JSON.parse(initData).rootId}"`; icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true); } - tabHtml += `