diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index 169030c17..8be5dc02f 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -1,5 +1,5 @@ .protyle-wysiwyg { - padding: 34px 16px 16px 24px; + padding: 16px 16px 16px 24px; cursor: text; box-sizing: border-box; user-select: auto; diff --git a/app/src/boot/globalShortcut.ts b/app/src/boot/globalShortcut.ts index c6756a403..3d94fdec6 100644 --- a/app/src/boot/globalShortcut.ts +++ b/app/src/boot/globalShortcut.ts @@ -524,10 +524,6 @@ export const globalShortcut = (app: App) => { }); dockHtml = dockHtml + ""; } - let range: Range; - if (getSelection().rangeCount > 0) { - range = getSelection().getRangeAt(0).cloneRange(); - } hideElements(["dialog"]); switchDialog = new Dialog({ title: window.siyuan.languages.switchTab, @@ -538,11 +534,6 @@ export const globalShortcut = (app: App) => {
`, - destroyCallback: () => { - if (range && range.getBoundingClientRect().height !== 0) { - focusByRange(range); - } - } }); // 需移走光标,否则编辑器会继续监听并执行按键操作 switchDialog.element.querySelector("input").focus(); @@ -656,9 +647,6 @@ export const globalShortcut = (app: App) => { const matchDock = getAllDocks().find(item => { if (matchHotKey(item.hotkey, event)) { getDockByType(item.type).toggleModel(item.type); - if (document.activeElement) { - (document.activeElement as HTMLElement).blur(); - } event.preventDefault(); return true; } diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts index 9a5338ff8..4bd77becd 100644 --- a/app/src/layout/dock/index.ts +++ b/app/src/layout/dock/index.ts @@ -4,7 +4,7 @@ import {Wnd} from "../Wnd"; import {Tab} from "../Tab"; import {Files} from "./Files"; import {Outline} from "./Outline"; -import {getAllModels} from "../getAll"; +import {getAllModels, getAllTabs} from "../getAll"; import {Bookmark} from "./Bookmark"; import {Tag} from "./Tag"; import {Graph} from "./Graph"; @@ -312,6 +312,9 @@ export class Dock { } }); if (needFocus) { + if (document.activeElement) { + (document.activeElement as HTMLElement).blur(); + } this.showDock(); return; } @@ -331,6 +334,17 @@ export class Dock { this.resizeElement.classList.add("fn__none"); this.hideDock(); } + // 关闭 dock 后设置光标 + if (!document.querySelector(".layout__center .layout__wnd--active")) { + const currentElement = document.querySelector(".layout__center .layout-tab-bar .item--focus") + getAllTabs().find(item => { + if (item.id === currentElement.getAttribute("data-id")) { + item.parent.switchTab(item.headElement); + return true; + } + }) + } + return; } else { this.element.querySelectorAll(`.dock__item--active[data-index="${index}"]`).forEach(item => { item.classList.remove("dock__item--active", "dock__item--activefocus"); @@ -475,6 +489,9 @@ export class Dock { this.resizeElement.classList.remove("fn__none"); }, 200); // 需等待动画完毕后再出现,否则会出现滚动条 https://ld246.com/article/1676596622064 } + if (document.activeElement) { + (document.activeElement as HTMLElement).blur(); + } } // dock 中两个面板的显示关系 diff --git a/app/src/layout/index.ts b/app/src/layout/index.ts index be8e6a4b8..46013d64e 100644 --- a/app/src/layout/index.ts +++ b/app/src/layout/index.ts @@ -84,9 +84,7 @@ export class Layout { item.element.querySelectorAll(".protyle-content").forEach((element: HTMLElement) => { if (!element.parentElement.classList.contains("fn__none")) { element.classList.remove("protyle-content--transition"); - const wysiwygElement = element.querySelector(".protyle-wysiwyg") as HTMLElement; - wysiwygElement.style.paddingRight = "16px"; - wysiwygElement.style.paddingLeft = "24px"; + (element.querySelector(".protyle-wysiwyg") as HTMLElement).style.padding = ""; element.classList.add("protyle-content--transition"); } });