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: Allow editing short mind map connection labels from the toolbar https://github.com/siyuan-note/siyuan/issues/19902
Daniel6aecd983f8a6
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex 83f7ca5471..c7c99cfdca 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -1651,6 +1651,28 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,view.selectedRelation = "drag-route";view.updateSelection();relationChanges.length = 0;+ for (const scale of [.5, 1, 2]) {+ view.scale = scale;+ view.draw();+ host.querySelector<HTMLButtonElement>('.mindmap-view__relation[data-relation-id="drag-route"]').click();+ const edit = inspector.querySelector<HTMLButtonElement>('[aria-label="edit"]');+ check.ok(edit, "short relations expose text editing outside their route handles");+ edit.click();+ const input = host.querySelector<HTMLInputElement>(".mindmap-view__relation-editor");+ check.equal(document.activeElement, input);+ check.equal(input.value, "");+ input.value = "Short connection";+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter", bubbles: true}));+ check.deepEqual(relationChanges.pop(), ["drag-route", {label: "Short connection"}]);+ check.equal(host.querySelector(".mindmap-view__relation-editor"), null);+ host.querySelector<HTMLButtonElement>('.mindmap-view__relation[data-relation-id="drag-route"]').click();+ inspector.querySelector<HTMLButtonElement>('[aria-label="edit"]').click();+ host.querySelector<HTMLInputElement>(".mindmap-view__relation-editor")+ .dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));+ check.equal(relationChanges.length, 0);+ }+ view.scale = 1;+ view.draw();const automaticRoute = JSON.stringify(view.relationRoutes.get("drag-route"));const screenNodes = () => [alpha, beta].map(id => {const bounds = nodeElement(id).getBoundingClientRect();diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex b13e996158..5e68d28fe4 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -2236,14 +2236,14 @@ export class ListMindmapView {}}- private editRelationLabel(event: MouseEvent) {+ private editRelationLabel(event?: MouseEvent) {const relation = this.model.metadata.relations.find(item => item.id === this.selectedRelation);const element = this.relationElements.get(this.selectedRelation);if (!relation || !element) {return;}- event.preventDefault();- event.stopPropagation();+ event?.preventDefault();+ event?.stopPropagation();this.finishRelationEdit?.(true);this.inspector.hidden = true;const input = createElement("input", "b3-text-field mindmap-view__relation mindmap-view__relation-editor");@@ -2626,8 +2626,8 @@ export class ListMindmapView {}const change = (patch: Partial<ListMindmapRelation>) => this.options.onRelationChange?.(relation.id, patch);color(relation.color, value => change({color: value}));- const remove = squareButton("delete", "iconTrashcan", () => this.options.onRelationDelete?.(relation.id));- this.inspector.append(remove);+ this.inspector.append(squareButton("edit", "iconEdit", () => this.editRelationLabel()),+ squareButton("delete", "iconTrashcan", () => this.options.onRelationDelete?.(relation.id)));return;}if (this.selectedEdge) {