An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Reveal hidden dock bars with floating side panels https://github.com/siyuan-note/siyuan/issues/20833
Daniele6ee88256ecc
diff --git a/app/src/assets/scss/business/_layout.scss b/app/src/assets/scss/business/_layout.scssindex 0e1cc3e773..040d8dc7bc 100644--- a/app/src/assets/scss/business/_layout.scss+++ b/app/src/assets/scss/business/_layout.scss@@ -435,6 +435,20 @@overscroll-behavior-y: contain;scrollbar-width: none;+ &--float {+ position: fixed;+ left: 0;+ height: auto;+ border-radius: var(--b3-border-radius-b) 0 0 var(--b3-border-radius-b);+ background-color: var(--b3-body-background);++ &#dockRight {+ left: auto;+ right: 0;+ border-radius: 0 var(--b3-border-radius-b) var(--b3-border-radius-b) 0;+ }+ }+&::-webkit-scrollbar {display: none;}diff --git a/app/src/boot/globalEvent/mousemove.ts b/app/src/boot/globalEvent/mousemove.tsindex cc98a4e66a..efe9aa6ee5 100644--- a/app/src/boot/globalEvent/mousemove.ts+++ b/app/src/boot/globalEvent/mousemove.ts@@ -109,21 +109,25 @@ export const windowMouseMove = (event: MouseEvent) => {!hasClosestByClassName(target, "protyle-toolbar") &&!hasClosestByClassName(target, "protyle-util");const leftDock = window.siyuan.layout.leftDock;+ const leftBar = document.getElementById("dockLeft");+ const leftBarWidth = leftBar.classList.contains("dock--float") ? 0 : leftBar.clientWidth;const leftTrigger = canTrigger && inYRange && leftDock.isFloating() && leftDock.layout.element.clientWidth > 0 &&- event.clientX < Math.max(document.getElementById("dockLeft").clientWidth + 1, 16) &&+ event.clientX < Math.max(leftBarWidth + 1, 16) &&// 隐藏停靠栏会导致点击两侧内容触发浮动面板弹出,因此需减小鼠标范围- (leftDock.elements[0].clientWidth > 0 || event.clientX < 8);- if (leftTrigger || leftDock.layout.element.contains(target)) {+ (leftBarWidth > 0 || event.clientX < 8);+ if (leftTrigger || leftDock.layout.element.contains(target) || leftBar.contains(target)) {leftDock.showDockByHover();} else {leftDock.hideDockByHover();}const rightDock = window.siyuan.layout.rightDock;+ const rightBar = document.getElementById("dockRight");+ const rightBarWidth = rightBar.classList.contains("dock--float") ? 0 : rightBar.clientWidth;const rightTrigger = canTrigger && inYRange && rightDock.isFloating() && rightDock.layout.element.clientWidth > 0 &&- event.clientX > window.innerWidth - Math.max(document.getElementById("dockRight").clientWidth - 2, 16) &&- (rightDock.elements[0].clientWidth > 0 || event.clientX > window.innerWidth - 8);- if (rightTrigger || rightDock.layout.element.contains(target)) {+ event.clientX > window.innerWidth - Math.max(rightBarWidth - 2, 16) &&+ (rightBarWidth > 0 || event.clientX > window.innerWidth - 8);+ if (rightTrigger || rightDock.layout.element.contains(target) || rightBar.contains(target)) {rightDock.showDockByHover();} else {rightDock.hideDockByHover();diff --git a/app/src/layout/dock/barVisibility.test.ts b/app/src/layout/dock/barVisibility.test.tsindex e62b8da69c..39b449db95 100644--- a/app/src/layout/dock/barVisibility.test.ts+++ b/app/src/layout/dock/barVisibility.test.ts@@ -60,10 +60,16 @@ describe("dock bar visibility", () => {assert.equal(shouldShowDockBar(false, false), false);});- it("keeps dock bars hidden when they are globally disabled", () => {+ it("keeps dock bars hidden without an expanded floating panel when they are globally disabled", () => {assert.equal(shouldShowDockBar(true, true), false);assert.equal(shouldShowDockBar(true, false), false);});++ it("temporarily shows a non-empty dock bar for an expanded floating panel", () => {+ assert.equal(shouldShowDockBar(true, true, true), true);+ assert.equal(shouldShowDockBar(true, false, true), false);+ assert.equal(shouldShowDockBar(false, true, true), true);+ });});describe("dock split visibility", () => {diff --git a/app/src/layout/dock/barVisibility.ts b/app/src/layout/dock/barVisibility.tsindex 66ab6ca88b..dd1f758727 100644--- a/app/src/layout/dock/barVisibility.ts+++ b/app/src/layout/dock/barVisibility.ts@@ -1,9 +1,11 @@-export const shouldShowDockBar = (globallyHidden: boolean, hasVisibleEntry: boolean) =>- !globallyHidden && hasVisibleEntry;+export const shouldShowDockBar = (globallyHidden: boolean, hasVisibleEntry: boolean, floatingPanelOpen = false) =>+ (!globallyHidden || floatingPanelOpen) && hasVisibleEntry;export const shouldShowDockSplit = (hasVisibleEntryBefore: boolean, hasVisibleEntryAfter: boolean) =>hasVisibleEntryBefore && hasVisibleEntryAfter;+let floatingBarResizeObserver: ResizeObserver;+export const adjustDockPadding = () => {const layoutElement = window.siyuan.layout?.layout?.children[0]?.element;const leftDockElement = window.siyuan.layout?.leftDock?.elements[0]?.parentElement;@@ -12,12 +14,12 @@ export const adjustDockPadding = () => {if (!layoutElement || !leftDockElement || !rightDockElement) {return;}- if (leftDockElement.classList.contains("fn__none")) {+ if (leftDockElement.classList.contains("fn__none") || leftDockElement.classList.contains("dock--float")) {layoutElement.style.marginLeft = "var(--b3-layout-space)";} else {layoutElement.style.marginLeft = "";}- if (rightDockElement.classList.contains("fn__none")) {+ if (rightDockElement.classList.contains("fn__none") || rightDockElement.classList.contains("dock--float")) {layoutElement.style.marginRight = "var(--b3-layout-space)";} else {layoutElement.style.marginRight = "";@@ -30,6 +32,7 @@ export const adjustDockPadding = () => {};export const syncDockBarVisibility = () => {+ const floatingBars: HTMLElement[] = [];document.querySelectorAll<HTMLElement>(".dock").forEach((item) => {const sections = Array.from(item.querySelectorAll<HTMLElement>(":scope > .dock__items"));const sectionVisibility = sections.map((section) =>@@ -39,10 +42,49 @@ export const syncDockBarVisibility = () => {sectionVisibility[0],sectionVisibility[1],));+ const dock = item.id === "dockLeft" ? window.siyuan.layout?.leftDock :+ item.id === "dockRight" ? window.siyuan.layout?.rightDock : undefined;+ const floatingPanelOpen = Boolean(dock?.isFloating() && dock.isPanelVisible() &&+ !dock.layout.element.classList.contains("fn__none") && dock.layout.element.style.opacity === "1");+ const floating = window.siyuan.config.uiLayout.hideDock && floatingPanelOpen && sectionVisibility.some(Boolean);+ const wasFloating = item.classList.contains("dock--float");+ item.classList.toggle("dock--float", floating);item.classList.toggle("fn__none", !shouldShowDockBar(window.siyuan.config.uiLayout.hideDock,sectionVisibility.some(Boolean),+ floatingPanelOpen,));+ if (floating) {+ floatingBars.push(item);+ // 临时停靠栏脱离主布局,层级低于面板,避免遮挡面板内的全屏内容。+ const panelRect = dock.layout.element.getBoundingClientRect();+ item.style.top = panelRect.top + "px";+ item.style.bottom = (window.innerHeight - panelRect.bottom) + "px";+ item.style.zIndex = (Number(dock.layout.element.style.zIndex) - 1).toString();+ } else if (wasFloating) {+ item.style.top = "";+ item.style.bottom = "";+ item.style.zIndex = "";+ }});adjustDockPadding();+ // 面板范围和界面密度变化后,同步临时停靠栏的范围及面板偏移。+ if (floatingBars.length > 0 && !floatingBarResizeObserver) {+ floatingBarResizeObserver = new ResizeObserver(() => {+ for (const dock of [window.siyuan.layout?.leftDock, window.siyuan.layout?.rightDock]) {+ if (dock?.elements[0].parentElement.classList.contains("dock--float")) {+ dock.showDock(true);+ }+ }+ });+ for (const element of [window.siyuan.layout?.leftDock?.layout.element, window.siyuan.layout?.rightDock?.layout.element,+ document.getElementById("dockLeft"), document.getElementById("dockRight")]) {+ if (element) {+ floatingBarResizeObserver.observe(element);+ }+ }+ } else if (floatingBars.length === 0 && floatingBarResizeObserver) {+ floatingBarResizeObserver.disconnect();+ floatingBarResizeObserver = undefined;+ }};diff --git a/app/src/layout/dock/index.test.ts b/app/src/layout/dock/index.test.tsindex 0c228c9ed7..4e3006618a 100644--- a/app/src/layout/dock/index.test.ts+++ b/app/src/layout/dock/index.test.ts@@ -41,6 +41,9 @@ const loadDockPrototype = (frames: Array<() => void>, document: object, adjustLaif (name.endsWith("/panelTransition")) {return {bindPanelTransitionGuard() {}};}+ if (name.endsWith("/barVisibility")) {+ return {syncDockBarVisibility() {}};+ }return {};},});diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.tsindex 7451c9698f..8788626f3f 100644--- a/app/src/layout/dock/index.ts+++ b/app/src/layout/dock/index.ts@@ -34,6 +34,7 @@ import {syncDockEntryOrders} from "../../config/entryVisibility/runtime";import {isWindow} from "../../util/functions";import {bindPanelTransitionGuard} from "../../util/panelTransition";import {isTouchHoverInput} from "../../util/hoverInput";+import {syncDockBarVisibility} from "./barVisibility";const TYPES = ["file", "outline", "inbox", "bookmark", "tag", "graph", "globalGraph", "backlink", "agentChat"];const DEFAULT_DOCK_SIZE = 232;@@ -261,10 +262,8 @@ export class Dock {event.toElement?.classList.contains("tooltip")) {return;}- if (this.position === "Left" && event.clientX < 43) {- return;- }- if (this.position === "Right" && event.clientX > window.innerWidth - 43) {+ if (this.position !== "Bottom" && event.relatedTarget instanceof Node &&+ this.elements[0].parentElement.contains(event.relatedTarget)) {return;}if (this.position === "Bottom" && event.clientY > window.innerHeight - 73) {@@ -424,6 +423,7 @@ export class Dock {this.collapsedPanelSize = "";this.layout.element.classList.remove("fn__none");this.resizeElement.classList.add("fn__none");+ syncDockBarVisibility();return false;}@@ -475,6 +475,7 @@ export class Dock {}}}+ syncDockBarVisibility();resizeTabs(false);setTabPosition(true);if (resolution.visible) {@@ -524,6 +525,7 @@ export class Dock {if (!hasActive && !this.isFloating()) {this.layout.element.style[this.position === "Bottom" ? "height" : "width"] = "0px";}+ syncDockBarVisibility();resizeTabs(isSaveLayout);setTabPosition(true);}@@ -616,14 +618,15 @@ export class Dock {this.layout.element.style.opacity = "1";}this.layout.element.style.zIndex = (++window.siyuan.zIndex).toString();+ syncDockBarVisibility();if (this.position === "Left") {this.layout.element.style.transform = `translateX(${this.elements[0].clientWidth}px)`;} else if (this.position === "Right") {this.layout.element.style.transform = `translateX(-${this.elements[0].clientWidth}px)`;} else if (this.position === "Bottom") {this.layout.element.style.transform = `translateY(-${document.getElementById("status").offsetHeight}px)`;- this.layout.element.style.left = this.elements[0].clientWidth + "px";- this.layout.element.style.right = this.elements[1].clientWidth + "px";+ this.layout.element.style.left = (window.siyuan.config.uiLayout.hideDock ? 0 : this.elements[0].clientWidth) + "px";+ this.layout.element.style.right = (window.siyuan.config.uiLayout.hideDock ? 0 : this.elements[1].clientWidth) + "px";}// 全屏面板以窗口定位,浮动位移保留到退出全屏时恢复。const fullscreenElement = this.layout.element.querySelector(".fullscreen");@@ -680,6 +683,7 @@ export class Dock {this.elements[0].querySelector(".dock__item--activefocus")?.classList.remove("dock__item--activefocus");this.elements[1].querySelector(".dock__item--activefocus")?.classList.remove("dock__item--activefocus");this.layout.element.querySelector(".layout__tab--active")?.classList.remove("layout__tab--active");+ syncDockBarVisibility();}public toggleModel(type: TDock | string, show = false, close = false, removeDock = false, isSaveLayout = true,@@ -1012,6 +1016,7 @@ export class Dock {anotherWnd.element.style.height = "";anotherWnd.element.style.width = "";}+ syncDockBarVisibility();resizeTabs(isSaveLayout);if (target.classList.contains("dock__item--active") && !removeDock && this.panelVisible) {this.showDockAfterResponsiveLayout();diff --git a/app/tests/dockBarVisibility.test.js b/app/tests/dockBarVisibility.test.jsnew file mode 100644index 0000000000..8e8cda34aa--- /dev/null+++ b/app/tests/dockBarVisibility.test.js@@ -0,0 +1,297 @@+const assert = require("node:assert/strict");+const {mkdtempSync, readFileSync, rmSync, writeFileSync} = require("node:fs");+const path = require("node:path");+const os = require("node:os");+const {test} = require("node:test");+const {ModuleKind, ScriptTarget, transpileModule} = require("typescript");+const sass = require("sass");++const browserCases = async (sources, css, template) => {+ const check = require("node:assert/strict");+ const load = (name, dependencies = {}) => {+ const exports = {};+ new Function("exports", "require", sources[name])(exports, () => dependencies);+ return exports;+ };+ document.head.innerHTML = "<style></style>";+ document.querySelector("style").textContent = css;+ document.body.innerHTML = '<div id="toolbar" class="toolbar"></div>' + template ++ '<div id="status" class="status"></div><div id="commonMenu" class="fn__none"></div>';+ const layouts = document.getElementById("layouts");+ layouts.classList.add("fn__flex-column");+ layouts.innerHTML = '<div id="outer" class="fn__flex fn__flex-1">' ++ '<div id="left" class="layout fn__flex-column"></div><div class="layout__resize"></div>' ++ '<div id="center" class="layout__center fn__flex-1">Editor</div><div class="layout__resize"></div>' ++ '<div id="right" class="layout fn__flex-column"></div></div><div class="layout__resize"></div>' ++ '<div id="bottom" class="layout fn__flex"></div>';+ const makeLayout = (id) => {+ const element = document.getElementById(id);+ element.innerHTML = '<div class="fn__flex-1"><div class="layout-tab-container"></div></div>' ++ '<div class="layout__resize"></div><div class="fn__flex-1"><div class="layout-tab-container"></div></div>';+ return {element, children: [element.children[0], element.children[2]].map(child => ({element: child}))};+ };+ const left = makeLayout("left");+ const right = makeLayout("right");+ const bottom = makeLayout("bottom");+ const center = {element: document.getElementById("center")};+ const outer = {element: document.getElementById("outer"), children: [left, center, right]};+ window.siyuan = {zIndex: 10, config: {uiLayout: {hideDock: true}, appearance: {hideStatusBar: false}, system: {os: "linux"}},+ layout: {layout: {children: [outer, bottom]}, centerLayout: center}};+ const bar = load("barVisibility");+ const dependencies = {+ ...bar, ...load("panelVisibility"),+ Constants: {TIMEOUT_DOCK_TOGGLE: 20, TIMEOUT_TRANSITION: 20, ATTRIBUTE_DOCK_WIDTH: "data-width"},+ bindPanelTransitionGuard() {}, isTouchHoverInput: () => false,+ isWindow: () => false, isAbove: (a, b) => Number(a.style.zIndex) > Number(b.style.zIndex),+ resizeTabs() {}, setTabPosition() {}, adjustLayout() {}, setPanelFocus() {},+ recordBeforeResizeTop() {}, clearBeforeResizeTop() {},+ hasClosestByClassName: (element, name) => element?.closest?.("." + name),+ };+ const {Dock} = load("index", dependencies);+ const docks = {};+ for (const position of ["Left", "Right", "Bottom"]) {+ docks[position] = window.siyuan.layout[position.toLowerCase() + "Dock"] =+ new Dock({app: {plugins: []}, data: {pin: false, data: []}, position});+ }+ const settle = () => new Promise(resolve => setTimeout(resolve, 350));+ await settle();+ for (const position of ["Left", "Right", "Bottom"]) {+ const dock = docks[position];+ for (const suffix of ["one", "two"]) {+ const type = position + suffix;+ dock.elements[0].insertAdjacentHTML("beforeend", `<button class="dock__item" data-type="${type}"+ data-entry-id="plugin:test:${type}" data-id="${type}" data-index="0" data-width="240" data-height="180">${suffix}</button>`);+ dock.layout.children[0].element.firstElementChild.insertAdjacentHTML("beforeend",+ `<div data-id="${type}" class="fn__none"><input class="b3-text-field"></div>`);+ }+ }+ const open = (position, suffix = "one") => docks[position].toggleModel(position + suffix, true, false, false, false);+ const hidden = element => getComputedStyle(element).display === "none";+ const rect = element => {+ const {x, y, width, height} = element.getBoundingClientRect();+ return {x, y, width, height};+ };+ bar.syncDockBarVisibility();+ const initialEditor = rect(center.element);+ const leftBar = document.getElementById("dockLeft");+ const rightBar = document.getElementById("dockRight");+ check.ok(hidden(leftBar) && hidden(rightBar));+ for (const position of ["Left", "Right"]) {+ const dock = docks[position];+ const element = position === "Left" ? leftBar : rightBar;+ const otherBar = position === "Left" ? rightBar : leftBar;+ const entries = Array.from(element.querySelectorAll(".dock__item"));+ const order = entries.map(item => item.dataset.entryId);+ open(position);+ await settle();+ check.ok(!hidden(element) && hidden(otherBar), "only the expanded side reveals its bar");+ check.equal(getComputedStyle(element).position, "fixed");+ check.deepEqual(rect(center.element), initialEditor, "revealing a bar does not reflow the editor");+ const panelRect = dock.layout.element.getBoundingClientRect();+ const barRect = element.getBoundingClientRect();+ check.equal(position === "Left" ? panelRect.left : panelRect.right,+ position === "Left" ? barRect.right : barRect.left, "panel stays beside the bar");+ check.ok(element.contains(document.elementFromPoint(barRect.x + barRect.width / 2, barRect.bottom - 20)),+ "the temporary bar is above the editor");+ check.equal(barRect.top, panelRect.top, "bar starts at the floating panel top");+ check.equal(barRect.bottom, panelRect.bottom, "bar ends at the floating panel bottom");+ const barStyle = getComputedStyle(element);+ const surface = document.createElement("div");+ surface.style.backgroundColor = "var(--b3-body-background)";+ document.body.append(surface);+ check.equal(barStyle.backgroundColor, getComputedStyle(surface).backgroundColor);+ surface.remove();+ check.notEqual(position === "Left" ? barStyle.borderTopLeftRadius : barStyle.borderTopRightRadius, "0px");+ check.equal(position === "Left" ? barStyle.borderTopRightRadius : barStyle.borderTopLeftRadius, "0px");+ if (process.env.SIYUAN_DOCK_TEST_SCREENSHOTS) {+ await require("electron").ipcRenderer.invoke("dock-bar-capture", position);+ }++ const {windowMouseMove} = load("mousemove", dependencies);+ const move = event => windowMouseMove(event);+ document.addEventListener("mousemove", move);+ dock.hideDockByHover();+ // 覆盖停靠栏最外侧像素,不能因旧的边缘范围少两个像素而收起。+ element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,+ clientX: position === "Left" ? 1 : window.innerWidth - 1, clientY: 200}));+ dock.layout.element.dispatchEvent(new MouseEvent("mouseleave", {relatedTarget: entries[0],+ clientX: position === "Left" ? barRect.right - 1 : barRect.left + 1, clientY: 200}));+ await settle();+ check.equal(dock.layout.element.style.opacity, "1", "moving from panel to bar keeps the panel open");+ check.ok(!hidden(element));++ entries[1].addEventListener("click", () => dock.toggleModel(position + "two", false, true, false, false));+ entries[1].click();+ await settle();+ check.ok(entries[1].classList.contains("dock__item--active"));+ check.ok(!hidden(dock.layout.element.querySelector(`[data-id="${position}two"]`)));+ check.deepEqual(entries.map(item => item.dataset.entryId), order, "plugin entry identifiers and order are preserved");+ check.deepEqual(rect(center.element), initialEditor);+ entries[0].classList.add("fn__none");+ bar.syncDockBarVisibility();+ check.ok(hidden(entries[0]) && !hidden(element), "profile-hidden entries stay hidden during refresh");+ entries[0].classList.remove("fn__none");++ const input = dock.layout.element.querySelector(`[data-id="${position}two"] input`);+ input.focus();+ dock.hideDock();+ check.ok(!hidden(element), "focused input keeps both panel and bar open");+ input.blur();+ const menu = document.getElementById("commonMenu");+ menu.style.zIndex = "9999";+ menu.classList.remove("fn__none");+ dock.hideDock();+ check.ok(!hidden(element), "open menu keeps both panel and bar open");+ menu.classList.add("fn__none");++ center.element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,+ clientX: position === "Left" ? 20 : window.innerWidth - 20, clientY: barRect.top - 10}));+ await settle();+ check.ok(hidden(element), "the area above the temporary bar does not keep the panel open");+ check.equal(dock.layout.element.style.opacity, "0");+ document.removeEventListener("mousemove", move);+ dock.showDock();+ dock.togglePanel(false);+ check.ok(hidden(element), "explicitly collapsing a panel clears its temporary bar");+ dock.togglePanel(true);+ await settle();+ check.ok(!hidden(element));+ dock.togglePin();+ check.ok(hidden(element), "pinning does not reveal a globally hidden bar");+ dock.togglePin();+ dock.showDock();+ await settle();+ check.ok(!hidden(element));+ dock.toggleModel(position + "two", false, true, false, false);+ await settle();+ check.ok(hidden(element), "closing the final active item hides the temporary bar");+ }++ open("Left");+ open("Right");+ open("Bottom");+ await settle();+ check.ok(!hidden(leftBar) && !hidden(rightBar));+ docks.Left.hideDock();+ check.ok(hidden(leftBar) && !hidden(rightBar), "each side closes independently");+ check.equal(bottom.element.style.left, "0px");+ check.equal(bottom.element.style.right, "0px", "side overlays do not narrow the bottom panel");+ docks.Right.hideDock();+ check.ok(hidden(leftBar) && hidden(rightBar), "the bottom panel alone reveals no side bars");+ docks.Bottom.hideDock();++ docks.Right.togglePin();+ docks.Right.setResponsiveFloating(true, 240);+ docks.Right.showDock();+ await settle();+ check.ok(!hidden(rightBar), "responsive floating uses the same temporary bar");+ docks.Right.setResponsiveFloating(false, 240);+ check.ok(hidden(rightBar), "restoring fixed layout clears the temporary bar");+ docks.Right.togglePin();+ docks.Right.showDock();+ await settle();++ document.getElementById("toolbar").classList.add("fn__none");+ document.getElementById("status").classList.add("fn__none");+ await settle();+ check.equal(rightBar.getBoundingClientRect().top, right.element.getBoundingClientRect().top);+ check.equal(rightBar.getBoundingClientRect().bottom, right.element.getBoundingClientRect().bottom);+ document.body.style.setProperty("--b3-ui-dock-width", "64px");+ await settle();+ check.equal(rightBar.clientWidth, 64);+ check.equal(right.element.getBoundingClientRect().right, rightBar.getBoundingClientRect().left,+ "density changes update the panel offset");++ const fullscreen = right.element.querySelector('[data-id="Rightone"]');+ fullscreen.classList.add("fullscreen");+ docks.Right.showDock(true);+ await settle();+ const hit = document.elementFromPoint(innerWidth - 10, 200);+ check.ok(fullscreen.contains(hit), "the bar does not cover fullscreen panel content");+ docks.Right.hideDock();+ check.equal(right.element.style.opacity, "1");+ fullscreen.classList.remove("fullscreen");+ docks.Right.showDock(true);++ window.siyuan.config.uiLayout.hideDock = false;+ bar.syncDockBarVisibility();+ docks.Right.showDock(true);+ check.ok(!hidden(leftBar) && !hidden(rightBar));+ check.ok(!rightBar.classList.contains("dock--float"));+ check.equal(rightBar.style.top, "");+ check.equal(rightBar.style.zIndex, "");+ docks.Right.hideDock();+ check.ok(!hidden(rightBar), "globally visible bars remain visible after floating panels close");+ window.siyuan.config.uiLayout.hideDock = true;+ bar.syncDockBarVisibility();+ check.ok(hidden(leftBar) && hidden(rightBar));+ check.equal(window.siyuan.config.uiLayout.hideDock, true);+ return "Floating dock bar cases passed";+};++if (process.versions.electron && process.type === "browser") {+ const {app, BrowserWindow, ipcMain} = require("electron");+ app.setPath("userData", process.argv[2]);+ app.whenReady().then(async () => {+ const win = new BrowserWindow({show: false, frame: false, webPreferences: {+ nodeIntegration: true, contextIsolation: false, offscreen: true, backgroundThrottling: false,+ }});+ let captureName;+ if (process.env.SIYUAN_DOCK_TEST_SCREENSHOTS) {+ ipcMain.handle("dock-bar-capture", async (_event, position) => {+ assert.ok(["Left", "Right"].includes(position));+ writeFileSync(path.join(process.env.SIYUAN_DOCK_TEST_SCREENSHOTS, `${captureName}-${position}.png`),+ (await win.webContents.capturePage()).toPNG());+ });+ }+ try {+ const sources = Object.fromEntries([+ ["barVisibility", "layout/dock/barVisibility"], ["panelVisibility", "layout/dock/panelVisibility"],+ ["index", "layout/dock/index"], ["mousemove", "boot/globalEvent/mousemove"],+ ].map(([name, file]) => [name, transpileModule(readFileSync(path.join(__dirname, `../src/${file}.ts`), "utf8"), {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+ }).outputText]));+ const template = readFileSync(path.join(__dirname, "../src/assets/template/desktop/index.tpl"), "utf8")+ .split('<div class="fn__flex-1 fn__flex">')[1].split('<div id="status"')[0];+ const html = '<div class="fn__flex-1 fn__flex">' + template;+ const styles = sass.compile(path.join(__dirname, "../src/assets/scss/base.scss"), {logger: sass.Logger.silent}).css;+ for (const theme of ["daylight", "midnight"]) {+ const css = readFileSync(path.join(__dirname, `../appearance/themes/${theme}/theme.css`), "utf8") + styles;+ for (const width of [1200, 700]) {+ captureName = `${theme}-${width}`;+ win.setContentSize(width, 800);+ await win.loadURL("data:text/html,<html><body class='fn__flex-column'></body></html>");+ const result = await win.webContents.executeJavaScript(`(${browserCases.toString()})(${[+ sources, css, html,+ ].map(value => JSON.stringify(value)).join(",")})`);+ assert.equal(result, "Floating dock bar cases passed", `${theme}, ${width}px`);+ }+ }+ console.log("Floating dock bar cases passed");+ win.destroy();+ app.exit(0);+ } catch (error) {+ console.error(error);+ win.destroy();+ app.exit(1);+ }+ });+} else {+ test("floating side panels reveal hidden dock bars without changing layout or preferences", {+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,+ timeout: 60000,+ }, async () => {+ const env = {...process.env};+ delete env.ELECTRON_RUN_AS_NODE;+ const profile = mkdtempSync(path.join(os.tmpdir(), "siyuan-dock-bar-"));+ try {+ const {stdout} = await require("node:util").promisify(require("node:child_process").execFile)(+ require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 55000});+ assert.match(stdout, /Floating dock bar cases passed/);+ } finally {+ assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));+ assert.ok(path.basename(profile).startsWith("siyuan-dock-bar-"));+ rmSync(profile, {recursive: true, force: true, maxRetries: 5, retryDelay: 100});+ }+ });+}