Skip to content

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

:art: Refine unnamed mind map roots and node control spacing https://github.com/siyuan-note/siyuan/issues/18831

Vanessaea0f9abadb20
diff --git a/app/src/assets/scss/protyle/_list-mindmap.scss b/app/src/assets/scss/protyle/_list-mindmap.scss
index 5a5cb020ed..00c899459a 100644
--- a/app/src/assets/scss/protyle/_list-mindmap.scss
+++ b/app/src/assets/scss/protyle/_list-mindmap.scss
@@ -168,6 +168,40 @@
&--virtual {
font-weight: 600;
+ background: var(--b3-theme-surface);
+ box-shadow: inset 0 0 0 1px var(--b3-border-color);
+ transition: background-color 120ms ease, box-shadow 120ms ease;
+
+ &:hover:not(.list-mindmap__node--dragging):not(.list-mindmap__node--editing):not(.list-mindmap__node--selected):not(.list-mindmap__node--relation) {
+ background: var(--b3-list-hover);
+ box-shadow: inset 0 0 0 1px var(--b3-border-color);
+ }
+ }
+
+ &--untitled:not(.list-mindmap__node--editing) {
+ width: 28px;
+ min-width: 28px;
+ height: 28px;
+ min-height: 28px;
+ padding: 0;
+
+ > .list-mindmap__content {
+ display: grid;
+ place-items: center;
+ min-width: 0;
+ min-height: 0;
+ width: 100%;
+ height: 100%;
+
+ &::before {
+ content: "";
+ width: 4px;
+ height: 4px;
+ border-radius: 50%;
+ background: currentColor;
+ opacity: .45;
+ }
+ }
}
&--selected:not([data-mindmap-drop])::after {
@@ -342,7 +376,7 @@
&__fold {
position: absolute;
z-index: 1;
- right: -11px;
+ right: -26px;
top: calc(50% - 11px);
min-width: 22px;
width: 22px;
@@ -408,11 +442,11 @@
}
&__node--branch > &__add-child {
- right: -38px;
+ right: -53px;
}
&__node--branch > &__add-bridge {
- width: 38px;
+ width: 53px;
}
&__node:not(.list-mindmap__node--root) {
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index d306a7131d..8087703e66 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -950,8 +950,13 @@ const browserCases = async (sourceCode: string, css: string) => {
titleView.getContentHost(model.root.id).dispatchEvent(new MouseEvent("dblclick", {bubbles: true}));
const input = host.querySelector<HTMLTextAreaElement>(".list-mindmap__root-title");
check.ok(input, "virtual root supports inline title editing");
- check.deepEqual({width: node.offsetWidth, height: node.offsetHeight}, before,
- "entering root title editing preserves dimensions");
+ if (model.metadata.rootTitle) {
+ check.deepEqual({width: node.offsetWidth, height: node.offsetHeight}, before,
+ "entering named root title editing preserves dimensions");
+ } else {
+ check.equal(before.width, before.height, "the unnamed root is a compact square");
+ check.equal(input.value, "", "editing an unnamed root starts with empty text");
+ }
input.value = "A long root title that grows while typing";
input.dispatchEvent(new Event("input", {bubbles: true}));
await settle();
@@ -969,7 +974,9 @@ const browserCases = async (sourceCode: string, css: string) => {
await renameRoot("Canceled title", "Escape");
check.equal(titleView.getContentHost(model.root.id).textContent, "Custom root");
await renameRoot("", "Enter");
- check.equal(titleView.getContentHost(model.root.id).textContent, "listMindmapRoot");
+ check.equal(titleView.getContentHost(model.root.id).textContent, "");
+ check.ok(nodeElement(model.root.id).classList.contains("list-mindmap__node--untitled"));
+ check.equal(nodeElement(model.root.id).offsetWidth, nodeElement(model.root.id).offsetHeight);
titleView.destroy();
const singleList = reset("* Single\n");
diff --git a/app/src/protyle/render/listMindmap/routing.ts b/app/src/protyle/render/listMindmap/routing.ts
index 9e4a93d5c0..ea417479f7 100644
--- a/app/src/protyle/render/listMindmap/routing.ts
+++ b/app/src/protyle/render/listMindmap/routing.ts
@@ -57,7 +57,7 @@ const findRelationRoute = (from: MindmapRouteBox, to: MindmapRouteBox,
const boxes = nodes.flatMap(node => [
{left: node.x - clearance, right: node.x + node.width + clearance,
top: node.y - clearance, bottom: node.y + node.height + clearance},
- {left: node.x + node.width - 19, right: node.x + node.width + 46,
+ {left: node.x + node.width - 19, right: node.x + node.width + 61,
top: (node.controlY ?? node.y + node.height) - 15, bottom: (node.controlY ?? node.y + node.height) + 15},
]);
const ports = (node: MindmapRouteBox, other: MindmapRouteBox) => {
diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.ts
index fceeba794a..948bd8b5fd 100644
--- a/app/src/protyle/render/listMindmap/view.ts
+++ b/app/src/protyle/render/listMindmap/view.ts
@@ -396,6 +396,10 @@ export class ListMindmapView {
this.resizeObserver.observe(element);
}
element.classList.toggle("list-mindmap__node--virtual", node.virtual);
+ element.classList.toggle("list-mindmap__node--untitled", node.virtual && !model.metadata.rootTitle);
+ if (node.virtual) {
+ element.setAttribute("aria-label", model.metadata.rootTitle || this.label("listMindmapRoot"));
+ }
element.classList.toggle("list-mindmap__node--root", id === model.root.id);
element.classList.toggle("list-mindmap__node--branch", node.children.length > 0);
element.style.backgroundColor = model.metadata.nodes[id]?.backgroundColor || "";
@@ -411,7 +415,7 @@ export class ListMindmapView {
const content = this.getContentHost(id);
content.replaceChildren();
if (node.virtual) {
- content.textContent = this.model.metadata.rootTitle || this.label("listMindmapRoot");
+ content.textContent = this.model.metadata.rootTitle || "";
} else {
node.contentBlocks.forEach((block) => {
const clone = block.cloneNode(true) as HTMLElement;
@@ -434,7 +438,7 @@ export class ListMindmapView {
}
const hasBlankLines = node.contentBlocks.length > 1 || content.textContent.includes("\n") ||
content.querySelectorAll("br").length > 1;
- const empty = !hasBlankLines && !content.textContent.replace(/[\u200b\ufeff]/g, "").trim() &&
+ const empty = !node.virtual && !hasBlankLines && !content.textContent.replace(/[\u200b\ufeff]/g, "").trim() &&
!content.querySelector("img, svg, video, audio, iframe, canvas, hr, [data-content]");
content.classList.toggle("list-mindmap__content--empty", empty);
content.dataset.placeholder = this.label("listMindmapPlaceholder");
@@ -492,7 +496,7 @@ export class ListMindmapView {
const element = this.nodeElements.get(id);
return {
id,
- width: Math.max(64, element.offsetWidth),
+ width: Math.max(1, element.offsetWidth),
height: Math.max(1, element.offsetHeight),
collapsed: this.folded.get(id) ?? node.collapsed,
children: node.children.map(child => makeLayoutNode(child.id)),
@@ -1231,7 +1235,8 @@ export class ListMindmapView {
const input = createElement("textarea", "list-mindmap__root-title");
const measure = createElement("span", "list-mindmap__root-title-measure");
input.rows = 1;
- input.value = this.model.metadata.rootTitle || this.label("listMindmapRoot");
+ input.value = this.model.metadata.rootTitle || "";
+ input.placeholder = this.label("listMindmapPlaceholder");
measure.textContent = input.value;
input.setAttribute("aria-label", this.label("text"));
content.classList.add("list-mindmap__root-title-host");