Skip to content

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

:art: Move mind map More actions to the right https://github.com/siyuan-note/siyuan/issues/20723

Daniel2c4b0edf859c
diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scss
index 2a2396fd0c..cc347af9b4 100644
--- a/app/src/assets/scss/protyle/_mindmap-view.scss
+++ b/app/src/assets/scss/protyle/_mindmap-view.scss
@@ -118,6 +118,7 @@
&__toolbar-group {
@include protyle-toolbar-surface($shadow: none);
+ position: relative;
align-items: center;
flex-wrap: wrap;
justify-content: flex-end;
@@ -180,9 +181,9 @@
}
&__zoom-control {
- position: relative;
display: flex;
align-items: center;
+ align-self: stretch;
flex-shrink: 0;
pointer-events: auto;
@@ -195,8 +196,8 @@
&__zoom-actions {
@include protyle-toolbar-surface;
position: absolute;
- top: 100%;
- right: 0;
+ top: calc(100% - 4px);
+ right: 4px;
display: none;
align-items: center;
gap: 8px;
@@ -903,6 +904,10 @@
}
}
+ &__node-more {
+ order: 2;
+ }
+
&__tooltip {
// 本地提示保留脑图内的定位和边界约束,供编辑器及导出页面共同使用。
position: absolute;
diff --git a/app/src/protyle/render/listMindmap/clipboard.test.ts b/app/src/protyle/render/listMindmap/clipboard.test.ts
index 44ad267489..160e30f44d 100644
--- a/app/src/protyle/render/listMindmap/clipboard.test.ts
+++ b/app/src/protyle/render/listMindmap/clipboard.test.ts
@@ -126,6 +126,7 @@ const browserCases = async (source: string, css: string) => {
document.body.append(host);
const copied: {ids: string[], cut: boolean}[] = [];
const pasted: {id: string, kind: string}[] = [];
+ const menus: {anchor: HTMLElement, ids: string[]}[] = [];
// Synthetic events have no native pointer capture; geometry and handlers still run in Chromium.
const capture = HTMLElement.prototype.setPointerCapture;
const hasCapture = HTMLElement.prototype.hasPointerCapture;
@@ -134,7 +135,7 @@ const browserCases = async (source: string, css: string) => {
const view = new api.ListMindmapView({host, model, onExit() {},
onCopy: (ids: string[], cut: boolean) => copied.push({ids, cut}),
onPaste: (id: string, kind: string) => pasted.push({id, kind}),
- onClipboardMenu() {}, onDeleteNodes() {}});
+ onClipboardMenu: (anchor: HTMLElement, ids: string[]) => menus.push({anchor, ids}), onDeleteNodes() {}});
const wait = () => new Promise(resolve => setTimeout(resolve, 40));
await wait();
const pointer = (id: string, modifiers: PointerEventInit = {}) => {
@@ -145,8 +146,28 @@ const browserCases = async (source: string, css: string) => {
clientY: rect.top + rect.height / 2, ...modifiers}));
view.viewport.dispatchEvent(new PointerEvent("pointerup", {pointerId: 1, bubbles: true}));
};
+ const checkNodeMenu = async () => {
+ for (const width of [240, 320, 850]) {
+ host.style.width = `${width}px`;
+ view.renderInspector();
+ await wait();
+ const inspector = host.querySelector<HTMLElement>(".mindmap-view__inspector");
+ const more = inspector.querySelector<HTMLButtonElement>('[aria-label="more"]');
+ check.equal(inspector.lastElementChild, more, "More follows the node actions in keyboard order");
+ const right = more.getBoundingClientRect().right;
+ for (const control of Array.from(inspector.children) as HTMLElement[]) {
+ check.ok(control.getBoundingClientRect().right <= right + 1,
+ `More stays rightmost in single and multiple node menus, width=${width}`);
+ }
+ more.click();
+ check.equal(menus.at(-1).anchor, more);
+ check.deepEqual(menus.at(-1).ids, view.getSelectedIds(), "More retains the current node selection");
+ }
+ };
pointer(a.id);
+ await checkNodeMenu();
pointer(b.id, {ctrlKey: true});
+ await checkNodeMenu();
check.deepEqual(new Set(view.getSelectedIds()), new Set([a.id, b.id]));
check.equal(host.querySelectorAll('[aria-selected="true"]').length, 2);
host.dispatchEvent(new ClipboardEvent("copy", {bubbles: true, cancelable: true, clipboardData: new DataTransfer()}));
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index 098d47de67..c97f875100 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -1558,6 +1558,8 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
const viewport = host.querySelector<HTMLElement>(".mindmap-view__viewport");
const settings = host.querySelector<HTMLButtonElement>('[aria-label="more"]');
check.equal(settings.getAttribute("aria-haspopup"), "menu");
+ check.equal(settings.nextElementSibling, null, "More is the last toolbar control");
+ check.equal(settings.previousElementSibling.getAttribute("aria-label"), "fullscreen");
settings.click();
check.equal(settingsOpened, 1, "the editable toolbar opens the shared settings menu");
const toolbarWidth = host.style.width;
@@ -2049,6 +2051,14 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
}
const firstButton = toolbar.querySelector("button").getBoundingClientRect();
const lastButton = toolbarGroup.lastElementChild.getBoundingClientRect();
+ check.equal(toolbarGroup.lastElementChild.getAttribute("aria-label"), "more",
+ "More stays last at every toolbar width");
+ for (const control of Array.from(toolbarGroup.children) as HTMLElement[]) {
+ if (!control.hidden) {
+ check.ok(control.getBoundingClientRect().right <= lastButton.right + 1,
+ `More stays rightmost after wrapping, width=${width}, fontSize=${fontSize}`);
+ }
+ }
check.equal(lastButton.top > firstButton.top, width < 180,
`compact global toolbars wrap only when necessary, width=${width}, fontSize=${fontSize}`);
check.equal(getComputedStyle(toolbarPopup).display, "flex", "zoom popup remains visible");
@@ -3020,7 +3030,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"), "more");
+ check.equal(levelButton.previousElementSibling.getAttribute("aria-label"), "listMindmapLock");
check.equal(levelButton.nextElementSibling.getAttribute("aria-label"), "cursorHand");
check.equal(host.querySelector(".mindmap-view__level-select"), null);
levelView.selectNode(levelChild);
diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.ts
index 7ad74b4016..226725d5a3 100644
--- a/app/src/protyle/render/listMindmap/view.ts
+++ b/app/src/protyle/render/listMindmap/view.ts
@@ -594,16 +594,6 @@ export class ListMindmapView {
add("fullscreen", "fullscreen", "iconFullscreen", () => this.toggleFullscreen());
return;
}
- if (this.options.onSettingsMenu) {
- 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, {active: this.panning, toggle: () => this.togglePanning()});
- });
- this.buttons.get("settings").setAttribute("aria-haspopup", "menu");
- }
if (!this.readOnly) {
add("summary", "listMindmapSummary", "iconGroups", () => {
this.finishThen(() => {
@@ -685,6 +675,16 @@ 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());
+ if (this.options.onSettingsMenu) {
+ 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, {active: this.panning, toggle: () => this.togglePanning()});
+ });
+ this.buttons.get("settings").setAttribute("aria-haspopup", "menu");
+ }
this.updateToolbarLayout();
}
@@ -3581,16 +3581,20 @@ export class ListMindmapView {
select.setAttribute("aria-pressed", String(this.multiSelect));
select.classList.toggle("color__square--current", this.multiSelect);
this.inspector.append(select);
- if (this.options.onClipboardMenu) {
- const more = squareButton("more", "iconMore", () => this.options.onClipboardMenu(more, ids));
- more.setAttribute("aria-haspopup", "menu");
- this.inspector.append(more);
- }
+ const appendMore = () => {
+ if (this.options.onClipboardMenu) {
+ const more = squareButton("more", "iconMore", () => this.options.onClipboardMenu(more, ids));
+ more.classList.add("mindmap-view__node-more");
+ more.setAttribute("aria-haspopup", "menu");
+ this.inspector.append(more);
+ }
+ };
if (multiple) {
const remove = squareButton("delete", "iconTrashcan", () => this.deleteSelection());
remove.disabled = ids.includes(this.model.root.id) ||
this.model.root.virtual && this.model.root.children.every(node => ids.includes(node.id));
this.inspector.append(remove);
+ appendMore();
return;
}
const style = this.model.metadata.nodes[id] || {};
@@ -3628,6 +3632,7 @@ export class ListMindmapView {
if (node && !node.virtual && node !== this.model.root) {
this.inspector.append(squareButton("delete", "iconTrashcan", () => this.deleteSelection()));
}
+ appendMore();
}
private toggleFullscreen() {