Skip to content

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

:sparkles: Simplify mind map toolbars across viewport sizes https://github.com/siyuan-note/siyuan/issues/20723

Daniel147fc9e8183e
diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scss
index dda68a8039..69102b17ac 100644
--- a/app/src/assets/scss/protyle/_mindmap-view.scss
+++ b/app/src/assets/scss/protyle/_mindmap-view.scss
@@ -93,6 +93,8 @@
}
&.fullscreen &__toolbar,
+ &--locked &__toolbar,
+ &--pan &__toolbar,
&--active &__toolbar,
&:hover &__toolbar,
&__toolbar:focus-within {
@@ -100,10 +102,14 @@
}
&.fullscreen &__toolbar .block__icon,
+ &--locked &__toolbar .block__icon,
+ &--pan &__toolbar .block__icon,
&--active &__toolbar .block__icon,
&:hover &__toolbar .block__icon,
&__toolbar:focus-within .block__icon,
&.fullscreen &__toolbar-group,
+ &--locked &__toolbar-group,
+ &--pan &__toolbar-group,
&--active &__toolbar-group,
&:hover &__toolbar-group,
&__toolbar:focus-within &__toolbar-group {
@@ -859,6 +865,13 @@
box-sizing: border-box;
overflow-x: auto;
overflow-y: hidden;
+ align-items: center;
+ flex-wrap: nowrap;
+
+ > button,
+ > select {
+ flex-shrink: 0;
+ }
}
&__relation-editor {
@@ -882,12 +895,6 @@
.mindmap-view__palette {
margin: 0;
- flex-shrink: 0;
- }
-
- > button,
- > select {
- flex-shrink: 0;
}
}
@@ -911,6 +918,14 @@
&__palette {
display: flex;
flex-wrap: nowrap;
+ order: 1;
+ min-width: 0;
+ overflow-x: auto;
+ flex-shrink: 1;
+
+ .color__square {
+ flex-shrink: 0;
+ }
}
}
diff --git a/app/src/protyle/render/listMindmap/connectorMenu.test.ts b/app/src/protyle/render/listMindmap/connectorMenu.test.ts
index a9ca4adcf0..fb969b6e59 100644
--- a/app/src/protyle/render/listMindmap/connectorMenu.test.ts
+++ b/app/src/protyle/render/listMindmap/connectorMenu.test.ts
@@ -4,6 +4,7 @@ import test from "node:test";
import {runInNewContext} from "node:vm";
import {createSourceFile, isClassDeclaration, isPropertyAssignment, ScriptTarget, transpileModule} from "typescript";
import {getListMindmapConnectorMenuItem} from "./connectorMenu";
+import {getListMindmapFoldMenuItems} from "./foldMenu";
const source = createSourceFile("index.ts", readFileSync("src/protyle/render/listMindmap/index.ts", "utf8"),
ScriptTarget.ES2021, true);
@@ -35,6 +36,7 @@ test("desktop and mobile connector menus persist one undoable change and preserv
let editable = true;
let item: IMenu;
let defaultItem: IMenu;
+ let expandItem: IMenu;
let defaultStyle = "bezier";
const defaults: string[] = [];
const placements: unknown[] = [];
@@ -43,6 +45,7 @@ test("desktop and mobile connector menus persist one undoable change and preserv
owner: {}, list,
canEdit: () => editable,
getListMindmapConnectorMenuItem,
+ getListMindmapFoldMenuItems,
getDefaultListMindmapConnectorStyle: () => defaultStyle,
setDefaultListMindmapConnectorStyle: (style: string) => { defaultStyle = style; defaults.push(style); },
getListMindmapSiblingIDs: () => new Map(),
@@ -62,12 +65,13 @@ test("desktop and mobile connector menus persist one undoable change and preserv
Menu: class {
addItem(value: IMenu) {
if (value.id === "defaultConnectorStyle") { defaultItem = value; }
+ else if (value.id === "expandLevel") { expandItem = value; }
else { item = value; }
}
open(position: unknown) { placements.push(position); }
fullscreen(position: unknown) { placements.push(position); }
},
- window: {siyuan: {languages: {}}}, console,
+ window: {siyuan: {languages: {listMindmapExpandToLevel: "Level ${level}"}}}, console,
};
runInNewContext(compiled, context);
const target = new context.Controller();
@@ -76,6 +80,13 @@ test("desktop and mobile connector menus persist one undoable change and preserv
target.onSettingsMenu(anchor);
assert.equal((item.submenu as IMenu[]).find(entry => entry.checked).id, "bezier");
assert.deepEqual(JSON.parse(JSON.stringify(placements)), [mobile ? "bottom" : {x: 20, y: 100, h: 24}]);
+ assert.equal(expandItem, undefined, "wide views keep expansion in the direct toolbar");
+ let selectedLevel: unknown;
+ target.onSettingsMenu(anchor, (level: unknown) => selectedLevel = level);
+ assert.deepEqual((expandItem.submenu as IMenu[]).map(entry => entry.id),
+ ["level1", "level2", "level3", "level4", "level5", "level6", "separator_all", "expandAll", "foldAll"]);
+ (expandItem.submenu as IMenu[])[2].click(undefined, undefined);
+ assert.equal(selectedLevel, 3, "narrow desktop and mobile views retain global expansion in More");
(defaultItem.submenu as IMenu[]).find(entry => entry.id === "rounded").click(undefined, undefined);
assert.deepEqual(defaults, ["rounded"]);
assert.equal(transactions.length, 0, "changing the preference must not enter document undo history");
diff --git a/app/src/protyle/render/listMindmap/fold.test.ts b/app/src/protyle/render/listMindmap/fold.test.ts
index 5a90a54c8f..9442872732 100644
--- a/app/src/protyle/render/listMindmap/fold.test.ts
+++ b/app/src/protyle/render/listMindmap/fold.test.ts
@@ -4,6 +4,7 @@ import test from "node:test";
import {runInNewContext} from "node:vm";
import {createSourceFile, isClassDeclaration, isPropertyAssignment, ScriptTarget, transpileModule} from "typescript";
import {getListMindmapFoldStates, getListMindmapSiblingFoldStates} from "./fold";
+import {getListMindmapFoldMenuItems} from "./foldMenu";
import type {ListMindmapFoldTarget} from "./fold";
import type {ListMindmapNode} from "./model";
const {loadMenuToggle} = require("../../../../tests/menu-toggle-fixture.cjs");
@@ -77,6 +78,7 @@ test("desktop and mobile menus offer six levels without icon placeholders follow
const positions: unknown[] = [];
const selected: ListMindmapFoldTarget[] = [];
const context = {
+ getListMindmapFoldMenuItems,
Menu: class {
addItem(item: typeof entries[number]) { entries.push(item); }
addSeparator(item: typeof entries[number]) { entries.push(item); }
diff --git a/app/src/protyle/render/listMindmap/foldMenu.ts b/app/src/protyle/render/listMindmap/foldMenu.ts
new file mode 100644
index 0000000000..92a718c92a
--- /dev/null
+++ b/app/src/protyle/render/listMindmap/foldMenu.ts
@@ -0,0 +1,13 @@
+import type {ListMindmapFoldTarget} from "./fold";
+
+export const getListMindmapFoldMenuItems = (select: (level: ListMindmapFoldTarget) => void,
+ labels: Record<string, string>): IMenu[] => [
+ ...Array.from({length: 6}, (_, index): IMenu => ({
+ id: `level${index + 1}`, iconHTML: "",
+ label: labels.listMindmapExpandToLevel.replace("${level}", String(index + 1)),
+ click: () => select(index + 1),
+ })),
+ {id: "separator_all", type: "separator"},
+ {id: "expandAll", icon: "iconExpand", label: labels.expandAll, click: () => select("expandAll")},
+ {id: "foldAll", icon: "iconContract", label: labels.foldAll, click: () => select("foldAll")},
+];
diff --git a/app/src/protyle/render/listMindmap/index.ts b/app/src/protyle/render/listMindmap/index.ts
index 7116e425ad..855c826240 100644
--- a/app/src/protyle/render/listMindmap/index.ts
+++ b/app/src/protyle/render/listMindmap/index.ts
@@ -44,6 +44,7 @@ import {ListMindmapView} from "./view";
import {openListMindmapEditor} from "./editor";
import {focusListMindmap} from "./create";
import {getListMindmapFoldStates, getListMindmapSiblingFoldStates} from "./fold";
+import {getListMindmapFoldMenuItems} from "./foldMenu";
import {isMobile} from "../../../util/functions";
import {addListMindmapSummaryRanges, getListMindmapSiblingIDs, getListMindmapSummaryParentID, getListMindmapSummaryRange,
getListMindmapSummarySnapshot} from "./summary";
@@ -242,7 +243,7 @@ class ListMindmapController {
onLockChange: locked => canEdit(owner, list) ? this.metadata(metadata => {
metadata.viewLocked = locked;
}) : Promise.resolve(true),
- onSettingsMenu: anchor => {
+ onSettingsMenu: (anchor, expand) => {
toggleMenu({
target: anchor,
build: (_menu, session) => {
@@ -268,6 +269,12 @@ class ListMindmapController {
setDefaultListMindmapConnectorStyle(style);
}
}, window.siyuan.languages, "default"));
+ if (expand) {
+ menu.addItem({
+ id: "expandLevel", icon: "iconExpandLevel", label: window.siyuan.languages.expandLevel,
+ submenu: getListMindmapFoldMenuItems(expand, window.siyuan.languages),
+ });
+ }
if (isMobile()) {
session.show(() => menu.fullscreen("bottom"));
} else {
@@ -282,23 +289,7 @@ class ListMindmapController {
target: anchor,
build: (_menu, session) => {
const menu = new Menu();
- for (let level = 1; level <= 6; level++) {
- menu.addItem({
- id: `level${level}`,
- iconHTML: "",
- label: window.siyuan.languages.listMindmapExpandToLevel.replace("${level}", String(level)),
- click: () => select(level),
- });
- }
- menu.addSeparator({id: "separator_all"});
- menu.addItem({
- id: "expandAll", icon: "iconExpand", label: window.siyuan.languages.expandAll,
- click: () => select("expandAll")
- });
- menu.addItem({
- id: "foldAll", icon: "iconContract", label: window.siyuan.languages.foldAll,
- click: () => select("foldAll")
- });
+ getListMindmapFoldMenuItems(select, window.siyuan.languages).forEach(item => menu.addItem(item));
if (isMobile()) {
session.show(() => menu.fullscreen("bottom"));
} else {
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index 3263fb1fed..1ace0e6356 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -1161,6 +1161,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
let undo = 0;
let redo = 0;
let settingsOpened = 0;
+ let overflowExpand: ((level: number | "expandAll" | "foldAll") => void) | undefined;
let finishAllowed: boolean | Promise<boolean> = true;
const options = {
host, model,
@@ -1188,7 +1189,10 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
onFold: (id: string) => folds.push(id),
onUndo: () => undo++,
onRedo: () => redo++,
- onSettingsMenu: () => settingsOpened++,
+ onSettingsMenu: (_anchor: HTMLElement, expand?: typeof overflowExpand) => {
+ settingsOpened++;
+ overflowExpand = expand;
+ },
onNodeStyle: (...args: unknown[]) => nodeStyles.push(args),
onRelationAdd: (...args: unknown[]) => relationAdditions.push(args),
onRelationChange: (...args: unknown[]) => relationChanges.push(args),
@@ -1512,10 +1516,29 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
const view = new api.ListMindmapView(options);
await settle();
const viewport = host.querySelector<HTMLElement>(".mindmap-view__viewport");
- const settings = host.querySelector<HTMLButtonElement>('[aria-label="listMindmapConnectors"]');
+ const settings = host.querySelector<HTMLButtonElement>('[aria-label="more"]');
check.equal(settings.getAttribute("aria-haspopup"), "menu");
settings.click();
check.equal(settingsOpened, 1, "the editable toolbar opens the shared settings menu");
+ const toolbarWidth = host.style.width;
+ for (const width of [320, 760]) {
+ host.style.width = `${width}px`;
+ await settle();
+ settings.click();
+ check.equal(typeof overflowExpand === "function", width < 360,
+ "More includes global expansion only when its direct entry is hidden");
+ check.equal(view.buttons.get("expandLevel").hidden, width < 360);
+ if (overflowExpand) {
+ let level: unknown;
+ const expandToLevel = view.expandToLevel;
+ view.expandToLevel = async (value: unknown) => { level = value; };
+ overflowExpand(3);
+ check.equal(level, 3, "the overflow entry invokes the same global folding action");
+ view.expandToLevel = expandToLevel;
+ }
+ }
+ host.style.width = toolbarWidth;
+ await settle();
const originalConnectorPositions = JSON.stringify([...view.positions]);
const connectorSource = list.getAttribute("custom-sy-list-mindmap-data");
for (const connectorStyle of ["spline", "orthogonal", "bezier", "rounded"]) {
@@ -1544,7 +1567,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
check.equal(view.findLine(branch).id, child.id, "the real canvas hit test selects each horizontal branch");
}
view.setReadOnly(true);
- check.equal(host.querySelector('[aria-label="listMindmapConnectors"]'), null, "read-only views render saved styles without an edit menu");
+ check.equal(host.querySelector('[aria-label="more"]'), null, "read-only views render saved styles without an edit menu");
check.equal(view.linePaths.filter((line: {relation: boolean}) => !line.relation).length, view.edges.length);
view.setReadOnly(false);
}
@@ -1951,10 +1974,11 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
const toolbar = host.querySelector(".mindmap-view__toolbar");
["listMindmapChild", "delete", "fold"].forEach(label =>
check.equal(toolbar.querySelector(`[aria-label="${label}"]`), null));
- const relationButton = toolbar.querySelector<HTMLButtonElement>('[aria-label="connect"]');
+ const relationButton = host.querySelector<HTMLButtonElement>('.mindmap-view__inspector [aria-label="connect"]');
const toolbarPanButton = toolbar.querySelector<HTMLButtonElement>('[aria-label="cursorHand"]');
- check.ok(relationButton.nextElementSibling.classList.contains("mindmap-view__level-control"));
- check.equal(relationButton.nextElementSibling.nextElementSibling, toolbarPanButton);
+ check.equal(toolbar.querySelector('[aria-label="connect"]'), null);
+ check.equal(toolbar.querySelector('[aria-label="listMindmapSummary"]'), null);
+ check.ok(toolbarPanButton.previousElementSibling.classList.contains("mindmap-view__level-control"));
check.ok(toolbarPanButton.nextElementSibling.classList.contains("mindmap-view__zoom-control"));
check.equal(relationButton.querySelector("use").getAttribute("xlink:href"), "#iconRoute");
const inspector = host.querySelector<HTMLElement>(".mindmap-view__inspector");
@@ -1968,6 +1992,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
for (const fontSize of [14, 32]) {
host.style.width = `${width}px`;
host.style.fontSize = `${fontSize}px`;
+ await settle();
toolbarZoom.focus();
const bounds = host.getBoundingClientRect();
for (const control of Array.from(toolbarGroup.children) as HTMLElement[]) {
@@ -1980,7 +2005,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
}
const firstButton = toolbar.querySelector("button").getBoundingClientRect();
const lastButton = toolbarGroup.lastElementChild.getBoundingClientRect();
- check.equal(lastButton.top > firstButton.top, width < 360, "narrow toolbars wrap controls");
+ check.equal(lastButton.top > firstButton.top, width < 260, "compact global toolbars wrap only when necessary");
check.equal(getComputedStyle(toolbarPopup).display, "flex", "zoom popup remains visible");
if (width === 180) {
const popupBounds = toolbarPopup.getBoundingClientRect();
@@ -2012,6 +2037,28 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
check.ok(Math.abs(nodeMenuBounds.left + nodeMenuBounds.width / 2 - panelBounds.left - panelBounds.width / 2) < 2);
check.ok(nodeMenuBounds.width < panelBounds.width / 2);
check.ok(panelBounds.bottom - nodeMenuBounds.bottom >= 8);
+ const originalNodeColors = options.nodeColors;
+ options.nodeColors = () => Array.from({length: 30}, (_, i) => ({
+ label: `Color ${i}`, color: `rgb(${i}, 0, 0)`, backgroundColor: "",
+ preview: {color: `rgb(${i}, 0, 0)`, backgroundColor: ""},
+ }));
+ for (const width of [240, 320, 760]) {
+ host.style.width = `${width}px`;
+ view.renderInspector();
+ await settle();
+ const palette = inspector.querySelector<HTMLElement>(".mindmap-view__palette");
+ check.ok(palette.scrollWidth > palette.clientWidth, "long palettes scroll independently");
+ palette.scrollLeft = palette.scrollWidth;
+ const bounds = inspector.getBoundingClientRect();
+ for (const key of ["connect", "listMindmapSummary", "delete"]) {
+ const action = inspector.querySelector<HTMLElement>(`[aria-label="${key}"]`).getBoundingClientRect();
+ check.ok(action.left >= bounds.left && action.right <= bounds.right,
+ `node action ${key} stays visible at width ${width} while the palette scrolls`);
+ }
+ }
+ host.style.cssText = originalHostStyle;
+ options.nodeColors = originalNodeColors;
+ view.renderInspector();
for (const borderColor of ["#d4d4d4", "#484848"]) {
host.style.setProperty("--b3-border-color", borderColor);
check.equal(getComputedStyle(inspector).boxShadow,
@@ -2755,6 +2802,8 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
check.equal(view.isLocked(), true);
check.equal(getComputedStyle(viewport).touchAction, "pan-y");
check.ok(host.querySelector('[aria-label="listMindmapUnlock"]'));
+ check.equal(getComputedStyle(toolbar).opacity, "1", "locked maps keep the unlock entry visible");
+ check.equal(host.querySelector('[aria-label="listMindmapUnlock"]').getAttribute("aria-pressed"), "true");
check.equal(host.querySelector('[aria-label="cursorHand"]'), null);
for (const ctrlKey of [false, true]) {
const wheel = new WheelEvent("wheel", {bubbles: true, cancelable: true, deltaY: 120, ctrlKey});
@@ -2913,7 +2962,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
});
await settle();
const levelButton = host.querySelector<HTMLButtonElement>('.mindmap-view__toolbar button[aria-label="expandLevel"]');
- check.equal(levelButton.previousElementSibling.getAttribute("aria-label"), "connect");
+ check.equal(levelButton.previousElementSibling.getAttribute("aria-label"), "more");
check.equal(levelButton.nextElementSibling.getAttribute("aria-label"), "cursorHand");
check.equal(host.querySelector(".mindmap-view__level-select"), null);
levelView.selectNode(levelChild);
@@ -4660,10 +4709,10 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
return added;
}});
await settle();
- const batchButton = batchHost.querySelector<HTMLButtonElement>('[aria-label="listMindmapSummary"]');
+ batchView.focusNode(api.readListMindmap(batchList).root.id);
+ const batchButton = batchHost.querySelector<HTMLButtonElement>('.mindmap-view__inspector [aria-label="listMindmapSummary"]');
const batchViewport = batchHost.querySelector<HTMLElement>(".mindmap-view__viewport");
- batchView.clearSelection();
- check.equal(batchButton.disabled, false, "batch selection can start without choosing a parent");
+ check.equal(batchButton.disabled, false, "the root node menu starts batch selection without choosing a parent range");
batchButton.click();
const batchModel = api.readListMindmap(batchList);
const leafIDs = batchModel.root.children.flatMap((node: ListMindmapNode) => node.children.map(child => child.id));
@@ -4838,7 +4887,8 @@ test("list mindmap mutations preserve block data in the real DOM and Lute", {
readFileSync(path.join(__dirname, "../../wysiwyg/transaction.ts"), "utf8"), typescript.ScriptTarget.Latest, true);
const updateTransaction = transactionSource.statements.find(statement => typescript.isVariableStatement(statement) &&
statement.declarationList.declarations.some(item => item.name.getText(transactionSource) === "updateTransaction"));
- const controllerSource = compile(path.join(__dirname, "../../util/hasClosest.ts")) +
+ const controllerSource = compile(path.join(__dirname, "foldMenu.ts")) +
+ compile(path.join(__dirname, "../../util/hasClosest.ts")) +
compile(path.join(__dirname, "../../wysiwyg/getBlock.ts")) + compile(path.join(__dirname, "index.ts")) +
typescript.transpileModule(updateTransaction.getText(transactionSource).replace(/^export /, ""), {
compilerOptions: {target: typescript.ScriptTarget.ES2021},
diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.ts
index 4a49a66c8e..8658996451 100644
--- a/app/src/protyle/render/listMindmap/view.ts
+++ b/app/src/protyle/render/listMindmap/view.ts
@@ -55,7 +55,7 @@ export interface ListMindmapViewOptions {
onFoldSiblings?: (id: string) => Promise<boolean>;
onFoldLevel?: (level: ListMindmapFoldTarget) => Promise<boolean>;
onExpandLevelMenu?: (anchor: HTMLElement, select: (level: ListMindmapFoldTarget) => void) => void;
- onSettingsMenu?: (anchor: HTMLElement) => void;
+ onSettingsMenu?: (anchor: HTMLElement, expand?: (level: ListMindmapFoldTarget) => void) => void;
onTaskToggle?: (id: string, cycle?: boolean) => void;
onTaskMenu?: (id: string, anchor: HTMLElement) => void;
onTabTaskToggle?: (id: string, itemId: string) => void;
@@ -338,7 +338,10 @@ export class ListMindmapView {
}
}
});
- this.resizeObserver = new ResizeObserver(() => this.refreshLayout());
+ this.resizeObserver = new ResizeObserver(() => {
+ this.updateToolbarLayout();
+ this.refreshLayout();
+ });
this.resizeObserver.observe(this.viewport);
this.update(this.model);
}
@@ -541,10 +544,15 @@ export class ListMindmapView {
private createToolbar() {
const controls = createElement("div", "mindmap-view__toolbar-group");
- const add = (id: string, key: string, icon: string, action: () => void) => {
+ const add = (id: string, key: string, icon: string, action: () => void, nodeAction = false) => {
const button = this.makeButton(key, icon, action);
this.buttons.set(id, button);
- controls.append(button);
+ if (nodeAction) {
+ button.className = "color__square";
+ button.querySelector("svg").classList.add("svg--mid");
+ } else {
+ controls.append(button);
+ }
};
this.toolbar.append(createElement("span", "mindmap-view__spacer fn__flex-1"), controls);
this.levelSelect = undefined;
@@ -562,6 +570,7 @@ export class ListMindmapView {
}).catch(error => console.error(error)).finally(() => button.disabled = false);
});
this.buttons.get("lock").setAttribute("aria-pressed", String(this.locked));
+ this.buttons.get("lock").classList.toggle("block__icon--active", this.locked);
this.buttons.get("lock").setAttribute("data-subtype", this.locked ? "lock" : "unlock");
if (this.locked) {
add("fullscreen", "fullscreen", "iconFullscreen", () => this.toggleFullscreen());
@@ -569,7 +578,13 @@ export class ListMindmapView {
}
if (!this.readOnly) {
if (this.options.onSettingsMenu) {
- add("settings", "listMindmapConnectors", "iconLine", () => this.options.onSettingsMenu(this.buttons.get("settings")));
+ add("settings", "more", "iconMore", () => {
+ const selectedId = this.selectedId;
+ this.options.onSettingsMenu(this.buttons.get("settings"),
+ this.buttons.get("expandLevel").hidden ? level => this.finishThen(() => {
+ void this.expandToLevel(level, selectedId).catch(error => console.error(error));
+ }) : undefined);
+ });
this.buttons.get("settings").setAttribute("aria-haspopup", "menu");
}
add("summary", "listMindmapSummary", "iconGroups", () => {
@@ -589,7 +604,7 @@ export class ListMindmapView {
}
this.updateSelection();
});
- });
+ }, true);
add("relation", "connect", "iconRoute", () => {
this.setInteractionActive(true);
this.cancelSummarySelection();
@@ -598,7 +613,7 @@ export class ListMindmapView {
this.relationFrom = this.relationFrom ? undefined : this.selectedId;
this.relationPreview = undefined;
this.updateSelection();
- });
+ }, true);
}
add("expandLevel", "expandLevel", "iconExpandLevel", () => {
const selectedId = this.selectedId;
@@ -662,6 +677,17 @@ export class ListMindmapView {
this.buttons.get("documentLayout").hidden = !this.fullscreenMarker;
this.buttons.get("documentLayout").setAttribute("aria-pressed", String(!this.documentFrame.hidden));
add("fullscreen", "fullscreen", "iconFullscreen", () => this.toggleFullscreen());
+ this.updateToolbarLayout();
+ }
+
+ private updateToolbarLayout() {
+ const expand = this.buttons.get("expandLevel");
+ if (expand && this.options.onSettingsMenu && !this.readOnly) {
+ expand.hidden = this.viewport.clientWidth > 0 && this.viewport.clientWidth < 360;
+ if (this.levelSelect) {
+ this.levelSelect.parentElement.hidden = expand.hidden;
+ }
+ }
}
private setPanning(value: boolean) {
@@ -669,6 +695,7 @@ export class ListMindmapView {
this.cancelSummarySelection();
}
this.panning = value;
+ this.options.host.classList.toggle("mindmap-view--pan", value);
this.viewport.classList.toggle("mindmap-view__viewport--pan", value);
const button = this.buttons.get("pan");
button?.classList.toggle("block__icon--active", value);
@@ -3370,7 +3397,8 @@ export class ListMindmapView {
const id = this.selectedId;
const style = this.model.metadata.nodes[id] || {};
const change = (patch: Partial<ListMindmapNodeStyle>) => this.options.onNodeStyle?.(id, patch);
- const nodePalette = createElement("div", "fn__flex");
+ this.inspector.append(this.buttons.get("relation"), this.buttons.get("summary"));
+ const nodePalette = createElement("div", "mindmap-view__palette");
nodePalette.setAttribute("role", "group");
nodePalette.setAttribute("aria-label", this.label("color"));
const nodeColors: ReturnType<NonNullable<ListMindmapViewOptions["nodeColors"]>> = [
@@ -3397,10 +3425,10 @@ export class ListMindmapView {
const node = this.model.nodes.get(id);
if (node?.taskMarker !== undefined && this.options.onTaskMenu) {
const task = squareButton("checkToggle", "iconCheck", () => this.openTaskMenu(id, task));
- nodePalette.append(task);
+ this.inspector.append(task);
}
if (node && !node.virtual && node !== this.model.root) {
- nodePalette.append(squareButton("delete", "iconTrashcan", () => this.deleteSelection()));
+ this.inspector.append(squareButton("delete", "iconTrashcan", () => this.deleteSelection()));
}
}