An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prevent mind map toolbar content overlap https://github.com/siyuan-note/siyuan/issues/20695
Danielbb69ecb3e79f
diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scssindex 2607fcfe1a..d07472091a 100644--- a/app/src/assets/scss/protyle/_mindmap-view.scss+++ b/app/src/assets/scss/protyle/_mindmap-view.scss@@ -102,10 +102,24 @@&.fullscreen &__toolbar .block__icon,&--active &__toolbar .block__icon,&:hover &__toolbar .block__icon,- &__toolbar:focus-within .block__icon {+ &__toolbar:focus-within .block__icon,+ &.fullscreen &__toolbar-group,+ &--active &__toolbar-group,+ &:hover &__toolbar-group,+ &__toolbar:focus-within &__toolbar-group {pointer-events: auto;}+ &__toolbar-group {+ @include protyle-toolbar-surface($shadow: none);+ align-items: center;+ flex-wrap: wrap;+ justify-content: flex-end;+ min-width: 0;+ gap: 8px;+ padding: 4px;+ }+&__spacer {flex: 1;}diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex 3f4520681d..c0305be28d 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -1451,6 +1451,41 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,const hiddenFitBounds = navigationView.contentBounds();check.ok(Math.abs(hiddenFitBounds.top * navigationView.scale + navigationView.offsetY - 16) < 1,"fitting with a hidden toolbar keeps the normal top margin");+ for (const background of ["rgb(255, 255, 255)", "rgb(30, 30, 30)"]) {+ for (const width of [760, 320, 220]) {+ for (const fullscreen of [false, true]) {+ navigationHost.classList.toggle("fullscreen", fullscreen);+ navigationHost.style.width = `${width}px`;+ navigationHost.style.setProperty("--b3-theme-background", background);+ navigationHost.style.fontSize = width === 220 ? "32px" : "14px";+ navigationView.setReadOnly(false);+ navigationHost.focus();+ navigationView.setInteractionActive(true);+ await settle();+ const group = navigationToolbar.querySelector<HTMLElement>(".mindmap-view__toolbar-group");+ const groupBounds = group.getBoundingClientRect();+ check.equal(getComputedStyle(group).backgroundColor, background,+ "the toolbar masks underlying text and images with the current theme background");+ check.equal(getComputedStyle(navigationToolbar).backgroundColor, "rgba(0, 0, 0, 0)",+ "the unused toolbar area leaves the map visible");+ for (const control of Array.from(group.children)) {+ const rect = control.getBoundingClientRect();+ check.ok(rect.left >= groupBounds.left && rect.right <= groupBounds.right + 1 &&+ rect.top >= groupBounds.top && rect.bottom <= groupBounds.bottom + 1,+ "the opaque group covers every control after wrapping");+ }+ const lock = group.querySelector<HTMLButtonElement>("button");+ lock.disabled = true;+ check.equal(getComputedStyle(group).opacity, "1", "disabled buttons retain an opaque backdrop");+ check.equal(getComputedStyle(group).pointerEvents, "auto", "masked gaps cannot activate underlying nodes");+ lock.disabled = false;+ check.ok(navigationView.getToolbarBounds().some((rect: DOMRect) =>+ rect.left === groupBounds.left && rect.right === groupBounds.right && rect.bottom === groupBounds.bottom),+ "fit and node reveal avoid the complete opaque toolbar group");+ }+ }+ }+ navigationHost.classList.remove("fullscreen");navigationView.destroy();navigationHost.remove();@@ -1908,22 +1943,20 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,const originalHostStyle = host.style.cssText;const toolbarZoom = toolbar.querySelector<HTMLElement>(".mindmap-view__zoom");const toolbarPopup = toolbar.querySelector<HTMLElement>(".mindmap-view__zoom-actions");+ const toolbarGroup = toolbar.querySelector<HTMLElement>(".mindmap-view__toolbar-group");for (const width of [96, 180, 260, 360, 700]) {for (const fontSize of [14, 32]) {host.style.width = `${width}px`;host.style.fontSize = `${fontSize}px`;toolbarZoom.focus();const bounds = host.getBoundingClientRect();- for (const control of Array.from(toolbar.children) as HTMLElement[]) {- if (control.classList.contains("mindmap-view__spacer")) {- continue;- }+ for (const control of Array.from(toolbarGroup.children) as HTMLElement[]) {const rect = control.getBoundingClientRect();check.ok(rect.left >= bounds.left && rect.right <= bounds.right,`toolbar control stays inside the map, width=${width}, fontSize=${fontSize}`);}const firstButton = toolbar.querySelector("button").getBoundingClientRect();- const lastButton = toolbar.lastElementChild.getBoundingClientRect();+ const lastButton = toolbarGroup.lastElementChild.getBoundingClientRect();check.equal(lastButton.top > firstButton.top, width < 360, "narrow toolbars wrap controls");check.equal(getComputedStyle(toolbarPopup).display, "flex", "zoom popup remains visible");if (width === 180) {diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex d982127e2f..5f63848936 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -530,12 +530,13 @@ export class ListMindmapView {}private createToolbar() {+ const controls = createElement("div", "mindmap-view__toolbar-group");const add = (id: string, key: string, icon: string, action: () => void) => {const button = this.makeButton(key, icon, action);this.buttons.set(id, button);- this.toolbar.append(button);+ controls.append(button);};- this.toolbar.append(createElement("span", "mindmap-view__spacer fn__flex-1"));+ this.toolbar.append(createElement("span", "mindmap-view__spacer fn__flex-1"), controls);this.levelSelect = undefined;this.options.host.classList.toggle("mindmap-view--locked", this.locked);add("lock", this.locked ? "listMindmapUnlock" : "listMindmapLock", this.locked ? "iconLock" : "iconUnlock", () => {@@ -640,7 +641,7 @@ export class ListMindmapView {const reset = this.makeButton("reset", "iconRefresh", () => this.zoomAt(1));zoomActions.append(this.zoomSlider, reset);zoomControl.append(this.zoomLabel, zoomActions);- this.toolbar.append(zoomControl);+ controls.append(zoomControl);add("fit", "listMindmapFit", "iconFocus", () => this.fit());add("fullscreen", "fullscreen", "iconFullscreen", () => this.toggleFullscreen());}@@ -912,7 +913,7 @@ export class ListMindmapView {return bounds;}// 顶部遮挡范围只包含可见控件及展开的缩放面板,不包含左侧空白区域。- this.toolbar.querySelectorAll<HTMLElement>(".block__icon, .mindmap-view__zoom, .mindmap-view__zoom-actions")+ this.toolbar.querySelectorAll<HTMLElement>(".mindmap-view__toolbar-group, .mindmap-view__zoom-actions").forEach(control => {const rect = control.getBoundingClientRect();const style = getComputedStyle(control);