diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 188d674b8..f9411a4c8 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -548,7 +548,10 @@ export class Wnd { public moveTab(tab: Tab, nextId?: string) { this.element.querySelector(".layout-tab-container").append(tab.panelElement); - + if (tab.model instanceof Editor) { + // DOM 移动后 range 会变化,因此置空 + tab.model.editor.protyle.toolbar.range = null; + } if (nextId) { // 只能用 find https://github.com/siyuan-note/siyuan/issues/3455 this.children.find((item, index) => { diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index d8da23090..e68770811 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -37,6 +37,7 @@ import {needSubscribe} from "./needSubscribe"; import {Dialog} from "../dialog"; import {unicode2Emoji} from "../emoji"; import {deleteFile} from "../editor/deleteFile"; +import {escapeHtml} from "./escape"; const getRightBlock = (element: HTMLElement, x: number, y: number) => { let index = 1; @@ -220,7 +221,27 @@ export const globalShortcut = () => { } } } else if (event.key === "Control") { - const currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus"); + let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus"); + // 快速切换时,不触发 Tab + if (currentLiElement.getAttribute("data-original")) { + currentLiElement.classList.remove("b3-list-item--focus"); + if (event.shiftKey) { + if (currentLiElement.previousElementSibling) { + currentLiElement.previousElementSibling.classList.add("b3-list-item--focus"); + } else { + currentLiElement.parentElement.lastElementChild.classList.add("b3-list-item--focus"); + currentLiElement.removeAttribute("data-original"); + } + } else { + if (currentLiElement.nextElementSibling) { + currentLiElement.nextElementSibling.classList.add("b3-list-item--focus"); + } else { + currentLiElement.parentElement.firstElementChild.classList.add("b3-list-item--focus"); + } + } + currentLiElement.removeAttribute("data-original"); + currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus"); + } const currentType = currentLiElement.getAttribute("data-type") as TDockType; if (currentType) { getDockByType(currentType).toggleModel(currentType, true); @@ -305,7 +326,7 @@ export const globalShortcut = () => { if (item.model instanceof Editor) { icon = `${unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE)}`; } - tabHtml += `