This commit is contained in:
Vanessa 2023-08-04 22:10:55 +08:00
parent 7c688751be
commit 3f0a49dcae
4 changed files with 20 additions and 17 deletions

View file

@ -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;

View file

@ -524,10 +524,6 @@ export const globalShortcut = (app: App) => {
});
dockHtml = dockHtml + "</ul>";
}
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) => {
</div>
<div class="switch-doc__path"></div>
</div>`,
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;
}

View file

@ -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 中两个面板的显示关系

View file

@ -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");
}
});