From c5371760fd79b78846d10e6452ca8a829f7b09a0 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 29 Jun 2022 18:47:02 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=89=8B=E9=80=9F=E5=A4=AA=E5=BF=AB?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E5=88=87=E6=8D=A2=E9=A1=B5=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/layout/Wnd.ts | 5 ++++- app/src/util/globalShortcut.ts | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) 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 += `
  • ${icon}${item.title}
  • `; + tabHtml += `
  • ${icon}${escapeHtml(item.title)}
  • `; }); } switchDialog = new Dialog({