Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16624

Vanessa35874e50759e
diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts
index c42fcaebd5..718b5c4d23 100644
--- a/app/src/boot/onGetConfig.ts
+++ b/app/src/boot/onGetConfig.ts
@@ -30,6 +30,7 @@ import {closeWindow} from "../window/closeWin";
import {correctHotkey} from "./globalEvent/commonHotkey";
import {recordBeforeResizeTop} from "../protyle/util/resize";
import {processSYLink} from "../editor/openLink";
+import {getAllEditor} from "../layout/getAll";
export const onGetConfig = (isStart: boolean, app: App) => {
correctHotkey(app);
@@ -88,7 +89,15 @@ export const onGetConfig = (isStart: boolean, app: App) => {
resizeTabs();
resizeTopBar();
firstResize = true;
- }, 200);
+ if (getSelection().rangeCount > 0) {
+ const range = getSelection().getRangeAt(0);
+ getAllEditor().forEach(item => {
+ if (item.protyle.wysiwyg.element.contains(range.startContainer)) {
+ item.protyle.toolbar.render(item.protyle, range);
+ }
+ });
+ }
+ }, Constants.TIMEOUT_RESIZE);
});
};
diff --git a/app/src/constants.ts b/app/src/constants.ts
index f4731c050c..9beeb12d58 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -293,6 +293,7 @@ export abstract class Constants {
// timeout
public static readonly TIMEOUT_OPENDIALOG = 50;
public static readonly TIMEOUT_DBLCLICK = 190;
+ public static readonly TIMEOUT_RESIZE = 200;
public static readonly TIMEOUT_INPUT = 256;
public static readonly TIMEOUT_LOAD = 300;
public static readonly TIMEOUT_TRANSITION = 300;
diff --git a/app/src/window/init.ts b/app/src/window/init.ts
index 442a24b7df..344436227a 100644
--- a/app/src/window/init.ts
+++ b/app/src/window/init.ts
@@ -13,6 +13,7 @@ import {App} from "../index";
import {afterLoadPlugin} from "../plugin/loader";
import {Tab} from "../layout/Tab";
import {initWindowEvent} from "../boot/globalEvent/event";
+import {getAllEditor} from "../layout/getAll";
export const init = (app: App) => {
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
@@ -61,7 +62,15 @@ export const init = (app: App) => {
resizeTimeout = window.setTimeout(() => {
adjustLayout(window.siyuan.layout.centerLayout);
resizeTabs();
- }, 200);
+ if (getSelection().rangeCount > 0) {
+ const range = getSelection().getRangeAt(0);
+ getAllEditor().forEach(item => {
+ if (item.protyle.wysiwyg.element.contains(range.startContainer)) {
+ item.protyle.toolbar.render(item.protyle, range);
+ }
+ });
+ }
+ }, Constants.TIMEOUT_RESIZE);
});
};