Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/7433

Vanessafe6e9c68fc96
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index b4dff742a6..4019d9f7f4 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -31,6 +31,7 @@ import {newFile} from "../util/newFile";
import {MenuItem} from "../menus/Menu";
import {escapeHtml} from "../util/escape";
import {isWindow} from "../util/functions";
+import {hideAllElements} from "../protyle/ui/hideElements";
export class Wnd {
public id: string;
@@ -800,6 +801,7 @@ export class Wnd {
}
tab.parent = this;
resizeTabs();
+ hideAllElements(["toolbar"])
}
public split(direction: TDirection) {
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 9e82449327..c5c100bb8c 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -17,7 +17,7 @@ import {Asset} from "../asset";
import {Search} from "../search";
import {Dock} from "./dock";
import {focusByRange} from "../protyle/util/selection";
-import {hideElements} from "../protyle/ui/hideElements";
+import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
import {fetchPost} from "../util/fetch";
import {hasClosestBlock, hasClosestByClassName} from "../protyle/util/hasClosest";
import {getContenteditableElement} from "../protyle/wysiwyg/getBlock";
@@ -514,10 +514,7 @@ export const resizeTabs = () => {
});
});
pdfResize();
- document.querySelectorAll(".protyle-gutters").forEach(item => {
- item.classList.add("fn__none");
- item.innerHTML = "";
- });
+ hideAllElements(["gutter"])
}, 200);
};
diff --git a/app/src/protyle/ui/hideElements.ts b/app/src/protyle/ui/hideElements.ts
index d7595629eb..0b5efb1731 100644
--- a/app/src/protyle/ui/hideElements.ts
+++ b/app/src/protyle/ui/hideElements.ts
@@ -23,7 +23,7 @@ export const hideElements = (panels: string[], protyle?: IProtyle, focusHide = f
}
if (protyle.toolbar && panels.includes("toolbar")) {
protyle.toolbar.element.classList.add("fn__none");
- protyle.toolbar.element.style.display = "";
+ protyle.toolbar.element.style.display = "";
}
if (protyle.toolbar && panels.includes("util")) {
const pinElement = protyle.toolbar.subElement.querySelector('[data-type="pin"]');
@@ -43,3 +43,24 @@ export const hideElements = (panels: string[], protyle?: IProtyle, focusHide = f
});
}
};
+
+// "toolbar", "pdfutil", "gutter"
+export const hideAllElements = (types: string[]) => {
+ if (types.includes("toolbar")) {
+ document.querySelectorAll(".protyle-toolbar").forEach((item: HTMLElement) => {
+ item.classList.add("fn__none");
+ item.style.display = "";
+ });
+ }
+ if (types.includes("pdfutil")) {
+ document.querySelectorAll(".pdf__util").forEach(item => {
+ item.classList.add("fn__none");
+ });
+ }
+ if (types.includes("gutter")) {
+ document.querySelectorAll(".protyle-gutters").forEach(item => {
+ item.classList.add("fn__none");
+ item.innerHTML = "";
+ });
+ }
+}
diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts
index 11f4fce352..a86acf80bf 100644
--- a/app/src/util/globalShortcut.ts
+++ b/app/src/util/globalShortcut.ts
@@ -18,7 +18,7 @@ import {setEditMode} from "../protyle/util/setEditMode";
import {rename} from "../editor/rename";
import {Files} from "../layout/dock/Files";
import {newDailyNote} from "./mount";
-import {hideElements} from "../protyle/ui/hideElements";
+import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
import {fetchPost} from "./fetch";
import {goBack, goForward} from "./backForward";
import {onGet} from "../protyle/util/onGet";
@@ -825,6 +825,13 @@ export const globalShortcut = () => {
window.siyuan.menus.menu.remove();
}
}
+ // protyle.toolbar 点击空白处时进行隐藏
+ if (!hasClosestByClassName(event.target, "protyle-toolbar")) {
+ hideAllElements(["toolbar"])
+ }
+ if (!hasClosestByClassName(event.target, "pdf__outer")) {
+ hideAllElements(["pdfutil"])
+ }
// dock float 时,点击空白处,隐藏 dock
const floatDockLayoutElement = hasClosestByClassName(event.target, "layout--float", true);
if (floatDockLayoutElement) {
@@ -846,11 +853,6 @@ export const globalShortcut = () => {
window.siyuan.layout.leftDock.hideDock();
window.siyuan.layout.rightDock.hideDock();
}
- if (!hasClosestByClassName(event.target, "pdf__outer")) {
- document.querySelectorAll(".pdf__util").forEach(item => {
- item.classList.add("fn__none");
- });
- }
const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
if (copyElement) {
writeText(copyElement.parentElement.nextElementSibling.textContent.trimEnd());