diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index 0fdefd6aa..fc4218d79 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -42,7 +42,6 @@ import {getStartEndElement} from "../protyle/wysiwyg/commonHotkey"; import {getNextFileLi, getPreviousFileLi} from "../protyle/wysiwyg/getBlock"; import {editor} from "../config/editor"; import {hintMoveBlock} from "../protyle/hint/extend"; -import {Outline} from "../layout/dock/Outline"; import {Backlink} from "../layout/dock/Backlink"; const getRightBlock = (element: HTMLElement, x: number, y: number) => { @@ -70,7 +69,6 @@ const switchDialogEvent = (event: MouseEvent, switchDialog: Dialog) => { getAllTabs().find(item => { if (item.id === currentId) { item.parent.switchTab(item.headElement); - setPanelFocus(item.headElement.parentElement.parentElement); return true; } }); @@ -330,7 +328,6 @@ export const globalShortcut = () => { getAllTabs().find(item => { if (item.id === currentId) { item.parent.switchTab(item.headElement); - setPanelFocus(item.headElement.parentElement.parentElement); return true; } }); @@ -394,8 +391,8 @@ export const globalShortcut = () => { 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"); + 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; @@ -435,6 +432,10 @@ export const globalShortcut = () => { `; }); + let range: Range + if (getSelection().rangeCount > 0) { + range = getSelection().getRangeAt(0).cloneRange(); + } switchDialog = new Dialog({ content: `