Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(diagram): refine mind-map hierarchy and branch styling

tianma-if8eb47d39a16f
diff --git a/apps/ios/EditorSource/src/main.ts b/apps/ios/EditorSource/src/main.ts
index 5a5524de..b1c0b934 100644
--- a/apps/ios/EditorSource/src/main.ts
+++ b/apps/ios/EditorSource/src/main.ts
@@ -18,6 +18,8 @@ import {
createNativeUnsupportedContentExtensions,
diagramDocumentToX6Cells,
attachDiagramReader,
+ MIND_MAP_CONNECTOR_NAME,
+ mindMapConnector,
diagramFallbackMarkdown,
docToMarkdown,
NativeAttachmentMetadata,
@@ -50,6 +52,8 @@ const galleryStyle = document.createElement("style");
galleryStyle.textContent = NATIVE_IMAGE_GALLERY_CSS;
document.head.append(galleryStyle);
+Graph.registerConnector(MIND_MAP_CONNECTOR_NAME, mindMapConnector, true);
+
/** Keep in sync with packages/shared MergeDivider (iOS bundle cannot import monorepo shared). */
const MERGE_DIVIDER_MARKDOWN_MARKER = "<!-- edgeever:merge-divider -->";
const MERGE_DIVIDER_TOKENIZER =
diff --git a/apps/mobile/src/components/LocalTiptapEditor.tsx b/apps/mobile/src/components/LocalTiptapEditor.tsx
index 65a0917f..27a80b09 100644
--- a/apps/mobile/src/components/LocalTiptapEditor.tsx
+++ b/apps/mobile/src/components/LocalTiptapEditor.tsx
@@ -36,6 +36,8 @@ import {
getResourceIdFromUrl,
diagramDocumentToX6Cells,
attachDiagramReader,
+ MIND_MAP_CONNECTOR_NAME,
+ mindMapConnector,
type AiAction,
type AiPromptParameterKind,
type AiPromptResultMode,
@@ -452,6 +454,8 @@ const MermaidRenderRuntime = (props: MermaidRendererProps) => {
return null;
};
+Graph.registerConnector(MIND_MAP_CONNECTOR_NAME, mindMapConnector, true);
+
const ReadOnlyX6Diagram = ({
diagram,
locale,
diff --git a/apps/web/src/components/DiagramEditorPane.test.mjs b/apps/web/src/components/DiagramEditorPane.test.mjs
index 5a3dd146..01510c7f 100644
--- a/apps/web/src/components/DiagramEditorPane.test.mjs
+++ b/apps/web/src/components/DiagramEditorPane.test.mjs
@@ -138,7 +138,10 @@ describe("diagram editor canvas surface", () => {
});
test("uses restrained rounded edges and fits the complete diagram without clipping", () => {
- expect(source).toContain('connector: { name: kind === "mind-map" ? "smooth" : "rounded"');
+ expect(source).toContain("Graph.registerConnector(MIND_MAP_CONNECTOR_NAME, mindMapConnector, true)");
+ expect(source).toContain("name: MIND_MAP_CONNECTOR_NAME, args: { sourceWidth: mindEdge?.sourceWidth, targetWidth: mindEdge?.targetWidth }");
+ expect(source).toContain('{ fill: "none" }');
+ expect(source).toContain('if (kind !== "mind-map") edge.attr("line/fill", "none")');
expect(source).toContain('name: "manhattan"');
expect(source).toContain("maxScale: policy.maxScale");
expect(source).not.toContain("minScale: policy.minScale");
diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsx
index 2ba85dc1..088ff28c 100644
--- a/apps/web/src/components/DiagramEditorPane.tsx
+++ b/apps/web/src/components/DiagramEditorPane.tsx
@@ -68,6 +68,16 @@ import {
DIAGRAM_SCHEMA_VERSION,
diagramFallbackMarkdown,
markdownToDoc,
+ MIND_MAP_CONNECTOR_NAME,
+ MIND_MAP_HORIZONTAL_GAP,
+ MIND_MAP_VERTICAL_GAP,
+ mindMapBranchSides,
+ mindMapConnector,
+ mindMapEdgeVisual,
+ mindMapNodePresentation,
+ mindMapNodeRole,
+ mindMapNodeVisual,
+ mindMapRootRadius,
parseDiagramDocument,
serializeDiagramDocument,
type ArchitectureResourceIcon,
@@ -105,7 +115,6 @@ import {
compactArchitectureNodeSize,
compactFlowchartNodeSize,
flowchartNodePresentation,
- compactMindMapNodeSize,
computeDiagramLayout,
computeDiagramLayoutResult,
getDiagramLayoutViewport,
@@ -118,6 +127,8 @@ import { statusSettleMotion } from "@/lib/motion";
import type { EdgeEverRepository } from "@/lib/repository";
import { cn, formatDateTime, parseTagsText } from "@/lib/utils";
+Graph.registerConnector(MIND_MAP_CONNECTOR_NAME, mindMapConnector, true);
+
type DiagramEditorPaneProps = {
memo: MemoDetail;
notebooks: Notebook[];
@@ -658,7 +669,15 @@ const nodeEditorState = (
const bottomRight = graph.localToClient({ x: bbox.x + bbox.width, y: bbox.y + bbox.height });
const origin = (host ?? graph.container).getBoundingClientRect();
const isRootTopic = data?.shape === "topic" && !data.parentId;
- const attrs = nodeAttrs(data?.shape ?? "process", theme, appearance, isRootTopic);
+ const mindRole = data?.shape === "topic"
+ ? mindMapNodeRole(graph.getNodes().map((item) => ({
+ id: item.id,
+ parentId: item.getData<NodeData>()?.parentId,
+ })), node.id)
+ : null;
+ const attrs = mindRole
+ ? mindMapNodeVisual(mindRole, resolveDiagramPalette(theme, appearance))
+ : nodeAttrs(data?.shape ?? "process", theme, appearance, isRootTopic);
return {
nodeId: node.id,
originalValue: data?.label ?? "",
@@ -668,7 +687,7 @@ const nodeEditorState = (
top: topLeft.y - origin.top,
width: Math.max(1, bottomRight.x - topLeft.x),
height: Math.max(1, bottomRight.y - topLeft.y),
- fontSize: (data?.shape === "topic" ? 14 : 13) * graph.scale().sx,
+ fontSize: (mindRole ? attrs.label.fontSize : data?.shape === "topic" ? 14 : 13) * graph.scale().sx,
color: String(attrs.label.fill),
background: String(attrs.body.fill),
borderColor: String(attrs.body.stroke),
@@ -813,15 +832,15 @@ const architectureNodeVisuals = (
const diagramNodePresentation = (
node: DiagramDocument["nodes"][number],
kind: DiagramDocument["kind"],
+ allNodes: Array<{ id: string; parentId?: string }> = [node],
) => {
if (kind === "flowchart") return flowchartNodePresentation(node.shape, node.label);
- const size = kind === "mind-map"
- ? compactMindMapNodeSize(node.label, !node.parentId)
- : kind === "architecture"
- ? compactArchitectureNodeSize(node.shape, node)
- : compactFlowchartNodeSize(node.shape);
+ if (kind === "mind-map") return mindMapNodePresentation(node.label, mindMapNodeRole(allNodes, node.id));
+ const size = kind === "architecture"
+ ? compactArchitectureNodeSize(node.shape, node)
+ : compactFlowchartNodeSize(node.shape);
if (node.shape === "boundary") return { ...size, text: node.label };
- const fontSize = kind === "mind-map" ? 14 : 13;
+ const fontSize = 13;
const lineHeight = 18;
const text = Dom.breakText(node.label, { width: size.width - (kind === "architecture" ? 66 : 24), height: 10000 }, {
fontSize, 'font-size': fontSize, 'font-weight': kind === "architecture" || !node.parentId ? 650 : 500,
@@ -886,9 +905,14 @@ const nodeMetadata = (
) => {
const isDecision = node.shape === "decision";
const isRootTopic = node.shape === "topic" && !node.parentId;
- const visualAttrs = nodeAttrs(node.shape, theme, appearance, isRootTopic);
+ const mindRole = kind === "mind-map" ? mindMapNodeRole([node], node.id) : null;
const palette = resolveDiagramPalette(theme, appearance);
+ const visualAttrs = mindRole ? mindMapNodeVisual(mindRole, palette) : nodeAttrs(node.shape, theme, appearance, isRootTopic);
const size = diagramNodeSize(node, kind);
+ if (mindRole === "root") {
+ visualAttrs.body.rx = mindMapRootRadius(size.height);
+ visualAttrs.body.ry = visualAttrs.body.rx;
+ }
const hasPorts = isConnectableDiagram(kind) && node.shape !== "boundary";
const architectureVisuals = kind === "architecture" && node.shape !== "boundary"
? architectureNodeVisuals(node.shape, size, appearance, node.resourceIcon)
@@ -913,7 +937,7 @@ const nodeMetadata = (
label: {
...visualAttrs.label,
text: diagramNodePresentation(node, kind).text,
- lineHeight: 18,
+ lineHeight: mindRole === "root" ? 20 : 18,
...(architectureVisuals ? { refX: 54, refY: "50%", textAnchor: "start", textVerticalAnchor: "middle" } : {}),
},
...(architectureVisuals?.attrs ?? {}),
@@ -947,25 +971,33 @@ const edgeMetadata = (
) => {
const palette = resolveDiagramPalette(theme, appearance);
const edgeKind = edge.kind ?? (kind === "architecture" ? "dependency" : undefined);
+ const mindEdge = kind === "mind-map" ? mindMapEdgeVisual("primary", palette) : null;
const edgeStroke = edgeKind === "data"
? "#7C3AED"
: edgeKind === "async"
? "#EA580C"
- : kind === "mind-map" ? palette.mindMapEdge : palette.flowEdge;
+ : mindEdge?.stroke ?? palette.flowEdge;
return {
id: edge.id,
source: { cell: edge.source },
target: { cell: edge.target },
router: kind === "flowchart" ? { name: "manhattan", args: { padding: 28, step: 10 } } : undefined,
- connector: { name: kind === "mind-map" ? "smooth" : "rounded", args: { radius: 10 } },
+ connector: kind === "mind-map"
+ ? { name: MIND_MAP_CONNECTOR_NAME, args: { sourceWidth: mindEdge?.sourceWidth, targetWidth: mindEdge?.targetWidth } }
+ : { name: "rounded", args: { radius: 10 } },
data: { ...(edgeKind ? { kind: edgeKind } : {}), ...(edge.bidirectional ? { bidirectional: true } : {}) } satisfies EdgeData,
attrs: {
line: {
stroke: edgeStroke,
- strokeWidth: kind === "mind-map" ? 2 : 1.5,
+ strokeWidth: mindEdge ? 0.5 : 1.5,
strokeDasharray: edgeKind === "async" ? "7 5" : undefined,
sourceMarker: edge.bidirectional ? { name: "block", width: 8, height: 6 } : null,
targetMarker: kind === "mind-map" ? null : { name: "block", width: 8, height: 6 },
+ ...(mindEdge ? {
+ fill: edgeStroke,
+ strokeLinejoin: "round",
+ strokeLinecap: "round",
+ } : { fill: "none" }),
},
},
labels: edge.label ? [diagramEdgeLabel(edge.label, palette, kind)] : undefined,
@@ -1072,16 +1104,47 @@ const readFlowchart = (graph: Graph, document: DiagramDocument, container: HTMLE
const applyMindMapHierarchy = (graph: Graph, theme: DiagramTheme, appearance: DiagramAppearance) => {
const palette = resolveDiagramPalette(theme, appearance);
- const roots = new Set(graph.getNodes().filter((node) => !node.getData<NodeData>()?.parentId).map((node) => node.id));
+ const nodes = graph.getNodes().map((node) => ({
+ id: node.id,
+ parentId: node.getData<NodeData>()?.parentId,
+ ...node.getPosition(),
+ ...node.getSize(),
+ }));
for (const node of graph.getNodes()) {
- const parentId = node.getData<NodeData>()?.parentId;
- const primary = Boolean(parentId && roots.has(parentId));
- node.attr("label/fontWeight", !parentId || primary ? 650 : 500);
- node.attr("body/strokeWidth", !parentId ? 2 : primary ? 1.5 : 1);
- if (primary) node.attr("body/stroke", palette.topicStroke);
+ const role = mindMapNodeRole(nodes, node.id);
+ const visual = mindMapNodeVisual(role, palette);
+ if (role === "root") {
+ visual.body.rx = mindMapRootRadius(node.getSize().height);
+ visual.body.ry = visual.body.rx;
+ }
+ node.attr("body/fill", visual.body.fill);
+ node.attr("body/stroke", visual.body.stroke);
+ node.attr("body/strokeWidth", visual.body.strokeWidth);
+ node.attr("body/rx", visual.body.rx);
+ node.attr("body/ry", visual.body.ry);
+ node.attr("label/fill", visual.label.fill);
+ node.attr("label/fontSize", visual.label.fontSize);
+ node.attr("label/fontWeight", visual.label.fontWeight);
+ node.attr("label/fontFamily", visual.label.fontFamily);
}
for (const edge of graph.getEdges()) {
- edge.attr("line/strokeWidth", roots.has(edge.getSourceCellId()) ? 2.5 : 1.25);
+ const sourceId = edge.getSourceCellId();
+ const targetId = edge.getTargetCellId();
+ const source = nodes.find((node) => node.id === sourceId);
+ const target = nodes.find((node) => node.id === targetId);
+ if (!source || !target) continue;
+ const visual = mindMapEdgeVisual(mindMapNodeRole(nodes, source.id), palette);
+ const sides = mindMapBranchSides(source, target);
+ edge.setSource({ cell: sourceId, anchor: { name: sides.source } });
+ edge.setTarget({ cell: targetId, anchor: { name: sides.target } });
+ edge.setConnector(MIND_MAP_CONNECTOR_NAME, { sourceWidth: visual.sourceWidth, targetWidth: visual.targetWidth });
+ edge.attr("line/stroke", visual.stroke);
+ edge.attr("line/fill", visual.stroke);
+ edge.attr("line/strokeWidth", 0.5);
+ edge.attr("line/strokeLinejoin", "round");
+ edge.attr("line/strokeLinecap", "round");
+ edge.attr("line/targetMarker", null);
+ edge.attr("line/sourceMarker", null);
}
};
@@ -1119,6 +1182,7 @@ const applyGraphPalette = (
for (const edge of graph.getEdges()) {
const edgeKind = edge.getData<EdgeData>()?.kind;
edge.attr("line/stroke", edgeKind === "data" ? "#7C3AED" : edgeKind === "async" ? "#EA580C" : kind === "mind-map" ? palette.mindMapEdge : palette.flowEdge);
+ if (kind !== "mind-map") edge.attr("line/fill", "none");
if (edge.getLabels().length > 0) {
edge.setLabels(edge.getLabels().map((label) => diagramEdgeLabel(String(label.attrs?.label?.text ?? ""), palette, kind)));
}
@@ -1274,6 +1338,9 @@ export const DiagramEditorPane = ({
graph.startBatch("edit-label");
cell.setData({ ...cell.getData<NodeData>(), label });
refreshNodeLabel(cell, label);
+ if (cell.getData<NodeData>()?.shape === "topic") {
+ applyMindMapHierarchy(graph, themeRef.current, appearanceRef.current);
+ }
graph.stopBatch("edit-label");
setSelectedNodeLabel(label);
}
@@ -1407,7 +1474,7 @@ export const DiagramEditorPane = ({
highlight: isConnectableDiagram(document.kind),
snap: { radius: 24 },
router: document.kind === "flowchart" ? { name: "manhattan", args: { padding: 28, step: 10 } } : "normal",
- connector: document.kind === "mind-map" ? "smooth" : "rounded",
+ connector: document.kind === "mind-map" ? MIND_MAP_CONNECTOR_NAME : "rounded",
validateConnection: ({ sourceCell, targetCell, sourcePort, targetPort }) => {
if (!isConnectableDiagram(document.kind) || !sourceCell || !sourcePort) return false;
if (!targetCell) return true;
@@ -1473,6 +1540,7 @@ export const DiagramEditorPane = ({
}
}
graph.addEdges(document.edges.map((edge) => edgeMetadata(edge, document.kind, documentTheme, appearance)));
+ applyGraphPalette(graph, documentTheme, document.kind, appearance);
graph.on("scale", () => setZoomPercent(Math.round(graph.scale().sx * 100)));
graph.cleanHistory();
fitDiagramContent(graph, document, containerRef.current);
@@ -1525,6 +1593,16 @@ export const DiagramEditorPane = ({
setHasSelection(true);
});
graph.on("node:dblclick", ({ node }: { node: Node }) => beginNodeEdit(node));
+ graph.on("node:mouseup", () => {
+ if (document.kind !== "mind-map") return;
+ const historyEnabled = graph.isHistoryEnabled();
+ if (historyEnabled) graph.disableHistory();
+ try {
+ applyMindMapHierarchy(graph, themeRef.current, appearanceRef.current);
+ } finally {
+ if (historyEnabled) graph.enableHistory();
+ }
+ });
graph.on("edge:click", ({ edge }: { edge: Edge }) => {
dismissFlowQuickCreate();
if (isConnectableDiagram(document.kind)) setOnlyFlowNodePortsActive(graph);
@@ -1931,12 +2009,14 @@ export const DiagramEditorPane = ({
const nextPosition = requestedPosition ?? (requestedSibling
? {
x: selectedPosition.x,
- y: Math.max(selectedPosition.y, ...siblings.map((node) => node.getPosition().y)) + 52,
+ y: Math.max(selectedPosition.y, ...siblings.map((node) => node.getPosition().y))
+ + selectedSize.height + (isMindMap ? MIND_MAP_VERTICAL_GAP : 16),
}
: {
- x: selectedPosition.x + selectedSize.width + (isMindMap ? 72 : 110),
+ x: selectedPosition.x + selectedSize.width + (isMindMap ? MIND_MAP_HORIZONTAL_GAP : 110),
y: childNodes.length > 0
- ? Math.max(...childNodes.map((node) => node.getPosition().y)) + 52
+ ? Math.max(...childNodes.map((node) => node.getPosition().y))
+ + selectedSize.height + (isMindMap ? MIND_MAP_VERTICAL_GAP : 16)
: selectedPosition.y,
});
const id = createId(isMindMap ? "topic" : "node");
@@ -1979,6 +2059,7 @@ export const DiagramEditorPane = ({
const position = positions[graphNode.id];
if (position) graphNode.position(position.x, position.y);
}
+ applyMindMapHierarchy(graph, themeRef.current, appearanceRef.current);
}
graph.stopBatch("add");
settleScroller();
@@ -2192,6 +2273,7 @@ export const DiagramEditorPane = ({
node.resize(geometry.width, geometry.height);
}
}
+ if (document.kind === "mind-map") applyMindMapHierarchy(graph, themeRef.current, appearanceRef.current);
graph.stopBatch("layout");
fitDiagramContent(graph, document, containerRef.current, 40, layout.viewport);
if (changed) {
diff --git a/apps/web/src/lib/diagram-layout.test.mjs b/apps/web/src/lib/diagram-layout.test.mjs
index 674893c1..0f3d7859 100644
--- a/apps/web/src/lib/diagram-layout.test.mjs
+++ b/apps/web/src/lib/diagram-layout.test.mjs
@@ -19,9 +19,9 @@ describe("diagram auto layout", () => {
});
test("uses compact topic sizes while allowing longer labels to grow within a cap", () => {
- expect(compactMindMapNodeSize("分支主题", false)).toEqual({ width: 92, height: 36 });
- expect(compactMindMapNodeSize("核心主题", true)).toEqual({ width: 112, height: 42 });
- expect(compactMindMapNodeSize("A much longer topic label", false).width).toBeLessThanOrEqual(156);
+ expect(compactMindMapNodeSize("分支主题", false)).toEqual({ width: 96, height: 36 });
+ expect(compactMindMapNodeSize("核心主题", true)).toEqual({ width: 124, height: 46 });
+ expect(compactMindMapNodeSize("A much longer topic label", false).width).toBeLessThanOrEqual(168);
});
test("inserts a sibling after the selected branch and pushes following subtrees down", () => {
@@ -45,7 +45,7 @@ describe("diagram auto layout", () => {
for (let index = 1; index < orderedSiblings.length; index += 1) {
const previous = document.nodes.find((node) => node.id === orderedSiblings[index - 1]);
expect(positions[orderedSiblings[index]].y).toBeGreaterThanOrEqual(
- positions[orderedSiblings[index - 1]].y + previous.height + 16,
+ positions[orderedSiblings[index - 1]].y + previous.height + 20,
);
}
expect(positions["topic-1-child"].x).toBeGreaterThan(positions["topic-1"].x);
@@ -54,7 +54,7 @@ describe("diagram auto layout", () => {
positions["topic-1-child"].y + 36,
positions["topic-1-child-2"].y + 36,
);
- expect(positions["topic-new"].y).toBeGreaterThanOrEqual(selectedSubtreeBottom + 16);
+ expect(positions["topic-new"].y).toBeGreaterThanOrEqual(selectedSubtreeBottom + 20);
});
test("orders a connected flow from top to bottom and places detached nodes afterwards", () => {
diff --git a/packages/shared/src/diagram-layout.ts b/packages/shared/src/diagram-layout.ts
index 16e95b43..5f492a95 100644
--- a/packages/shared/src/diagram-layout.ts
+++ b/packages/shared/src/diagram-layout.ts
@@ -1,5 +1,12 @@
-import { visualTextUnits, compactFlowchartNodeSize, flowchartNodePresentation } from "./diagram-node-presentation";
+import { compactFlowchartNodeSize, flowchartNodePresentation } from "./diagram-node-presentation";
export { compactFlowchartNodeSize, flowchartNodePresentation } from "./diagram-node-presentation";
+import {
+ MIND_MAP_HORIZONTAL_GAP,
+ MIND_MAP_VERTICAL_GAP,
+ mindMapNodePresentation,
+ mindMapNodeRole,
+} from "./diagram-mindmap-style";
+export { compactMindMapNodeSize } from "./diagram-mindmap-style";
import { graphlib, layout as runDagreLayout } from "@dagrejs/dagre";
import {
ARCHITECTURE_DIAGRAM_SCHEMA_VERSION,
@@ -76,8 +83,6 @@ export type DiagramIr = {
}>;
};
-const MIND_MAP_HORIZONTAL_GAP = 72;
-const MIND_MAP_VERTICAL_GAP = 16;
const MIND_MAP_TWO_SIDED_THRESHOLD = 5;
const FLOWCHART_DETACHED_GAP = 72;
const FLOWCHART_DETACHED_ROW_GAP = 24;
@@ -86,11 +91,6 @@ const ARCHITECTURE_LAYOUT_ROW_WIDTH = 1480;
const ARCHITECTURE_GROUP_HORIZONTAL_GAP = 72;
const ARCHITECTURE_GROUP_VERTICAL_GAP = 88;
-export const compactMindMapNodeSize = (label: string, isRoot: boolean) => ({
- width: Math.round(Math.min(isRoot ? 168 : 156, Math.max(isRoot ? 112 : 92, visualTextUnits(label) * 13 + 28))),
- height: isRoot ? 42 : 36,
-});
-
export const compactArchitectureNodeSize = (
shape: DiagramNodeShape,
authored?: { width: number; height: number },
@@ -545,7 +545,7 @@ export const compileDiagramIr = (ir: DiagramIr): DiagramDocument => {
const nodes = ir.nodes.map((node, index) => {
const shape = irNodeShape(ir.kind, node.type);
const size = ir.kind === "mind-map"
- ? compactMindMapNodeSize(node.label, !node.parentId)
+ ? mindMapNodePresentation(node.label, mindMapNodeRole(ir.nodes, node.id))
: ir.kind === "architecture"
? compactArchitectureNodeSize(shape)
: flowchartNodePresentation(shape, node.label);
diff --git a/packages/shared/src/diagram-mindmap-style.test.mjs b/packages/shared/src/diagram-mindmap-style.test.mjs
new file mode 100644
index 00000000..3ccad47e
--- /dev/null
+++ b/packages/shared/src/diagram-mindmap-style.test.mjs
@@ -0,0 +1,82 @@
+import { describe, expect, test } from "bun:test";
+import {
+ compactMindMapNodeSize,
+ mindMapBranchSides,
+ mindMapConnectorPath,
+ mindMapEdgeVisual,
+ mindMapNodePresentation,
+ mindMapNodeRole,
+ mindMapNodeVisual,
+ mindMapRootRadius,
+ MIND_MAP_CONNECTOR_NAME,
+ MIND_MAP_VERTICAL_GAP,
+} from "./diagram-mindmap-style.ts";
+
+const palette = {
+ topicFill: "#16A06E",
+ topicText: "#FFFFFF",
+ nodeFill: "#F0F8F4",
+ nodeText: "#173B2E",
+ nodeStroke: "#B8DFD0",
+ topicStroke: "#12845B",
+ mindMapEdge: "#55B891",
+ canvas: "#F8FAF9",
+};
+
+describe("mind map presentation", () => {
+ test("classifies root, first-level, and nested topics from parent links", () => {
+ const nodes = [
+ { id: "root" },
+ { id: "one", parentId: "root" },
+ { id: "one-a", parentId: "one" },
+ ];
+ expect(mindMapNodeRole(nodes, "root")).toBe("root");
+ expect(mindMapNodeRole(nodes, "one")).toBe("primary");
+ expect(mindMapNodeRole(nodes, "one-a")).toBe("nested");
+ });
+
+ test("keeps compact topic sizes while allowing longer labels to grow within a cap", () => {
+ expect(compactMindMapNodeSize("分支主题", false)).toEqual({ width: 96, height: 36 });
+ expect(compactMindMapNodeSize("核心主题", true)).toEqual({ width: 124, height: 46 });
+ expect(compactMindMapNodeSize("A much longer topic label", false).width).toBeLessThanOrEqual(168);
+ expect(mindMapNodePresentation("核心主题", "root").fontSize).toBe(15);
+ expect(MIND_MAP_VERTICAL_GAP).toBe(20);
+ });
+
+ test("uses a capsule root, rounded first-level topics, and lighter nested topics", () => {
+ const root = mindMapNodeVisual("root", palette);
+ const primary = mindMapNodeVisual("primary", palette);
+ const nested = mindMapNodeVisual("nested", palette);
+ expect(root.body.fill).toBe(palette.topicFill);
+ expect(root.body.rx).toBe(23);
+ expect(primary.body.fill).toBe(palette.nodeFill);
+ expect(primary.body.stroke).toBe(palette.topicStroke);
+ expect(nested.body.fill).toBe(palette.canvas);
+ expect(nested.label.fontWeight).toBe(500);
+ expect(mindMapRootRadius(46)).toBe(23);
+ });
+
+ test("tapers branches from the parent and anchors them to the nearer side", () => {
+ const fromRoot = mindMapEdgeVisual("root", palette);
+ const fromNested = mindMapEdgeVisual("nested", palette);
+ expect(fromRoot.sourceWidth).toBeGreaterThan(fromRoot.targetWidth);
+ expect(fromRoot.sourceWidth).toBeGreaterThan(fromNested.sourceWidth);
+ expect(mindMapBranchSides(
+ { x: 0, y: 0, width: 120, height: 46 },
+ { x: 200, y: 0, width: 96, height: 36 },
+ )).toEqual({ source: "right", target: "left" });
+ expect(mindMapBranchSides(
+ { x: 200, y: 0, width: 120, height: 46 },
+ { x: 0, y: 0, width: 96, height: 36 },
+ )).toEqual({ source: "left", target: "right" });
+ expect(MIND_MAP_CONNECTOR_NAME).toBe("edgeever-mindmap");
+ });
+
+ test("builds a closed horizontal cubic ribbon that is thicker at the source", () => {
+ const path = mindMapConnectorPath({ x: 0, y: 0 }, { x: 80, y: 0 }, 4, 1);
+ expect(path.startsWith("M 0.00 2.00")).toBe(true);
+ expect(path.includes("Z")).toBe(true);
+ expect(path).toContain("L 0.00 -2.00");
+ expect(path).toContain("L 80.00 0.50");
+ });
+});
diff --git a/packages/shared/src/diagram-mindmap-style.ts b/packages/shared/src/diagram-mindmap-style.ts
new file mode 100644
index 00000000..17c07930
--- /dev/null
+++ b/packages/shared/src/diagram-mindmap-style.ts
@@ -0,0 +1,221 @@
+import { visualTextUnits } from "./diagram-node-presentation";
+
+export type MindMapRole = "root" | "primary" | "nested";
+
+export type MindMapPalette = {
+ topicFill: string;
+ topicText: string;
+ nodeFill: string;
+ nodeText: string;
+ nodeStroke: string;
+ topicStroke: string;
+ mindMapEdge: string;
+ canvas: string;
+};
+
+export type MindMapPoint = { x: number; y: number };
+export type MindMapBox = { x: number; y: number; width: number; height: number };
+
+export const MIND_MAP_CONNECTOR_NAME = "edgeever-mindmap";
+export const MIND_MAP_HORIZONTAL_GAP = 72;
+export const MIND_MAP_VERTICAL_GAP = 20;
+export const MIND_MAP_LABEL_FONT =
+ 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
+
+type MindMapSizedNode = { id: string; parentId?: string };
+
+const wrapVisualText = (label: string, capacity: number) => label.split("\n").flatMap((paragraph) => {
+ const lines: string[] = [];
+ let line = "";
+ for (const character of Array.from(paragraph)) {
+ if (line && visualTextUnits(line + character) > capacity) {
+ lines.push(line);
+ line = "";
+ }
+ line += character;
+ }
+ lines.push(line);
+ return lines;
+});
+
+export const mindMapNodeRole = (
+ nodes: MindMapSizedNode[],
+ nodeId: string,
+): MindMapRole => {
+ const byId = new Map(nodes.map((node) => [node.id, node]));
+ const node = byId.get(nodeId);
+ if (!node?.parentId) return "root";
+ const parent = byId.get(node.parentId);
+ if (!parent?.parentId) return "primary";
+ return "nested";
+};
+
+export const mindMapNodeSize = (label: string, role: MindMapRole = "primary") => {
+ const isRoot = role === "root";
+ return {
+ width: Math.round(Math.min(
+ isRoot ? 180 : 168,
+ Math.max(isRoot ? 124 : 96, visualTextUnits(label) * 13 + (isRoot ? 36 : 28)),
+ )),
+ height: isRoot ? 46 : 36,
+ };
+};
+
+export const compactMindMapNodeSize = (label: string, isRoot: boolean) => (
+ mindMapNodeSize(label, isRoot ? "root" : "primary")
+);
+
+export const mindMapNodePresentation = (label: string, role: MindMapRole) => {
+ const size = mindMapNodeSize(label, role);
+ const lineHeight = role === "root" ? 20 : 18;
+ const padX = role === "root" ? 36 : 28;
+ const lines = wrapVisualText(label, Math.max(4, (size.width - padX) / 13));
+ return {
+ ...size,
+ height: Math.max(size.height, lines.length * lineHeight + (role === "root" ? 18 : 14)),
+ text: lines.join("\n"),
+ fontSize: role === "root" ? 15 : role === "primary" ? 14 : 13,
+ };
+};
+
+export const mindMapRootRadius = (height: number) => Math.round(Math.max(1, height / 2));
+
+export const mindMapNodeVisual = (role: MindMapRole, palette: MindMapPalette) => {
+ if (role === "root") {
+ return {
+ body: {
+ fill: palette.topicFill,
+ stroke: palette.topicStroke,
+ strokeWidth: 1.5,
+ rx: 23,
+ ry: 23,
+ },
+ label: {
+ fill: palette.topicText,
+ fontSize: 15,
+ fontWeight: 650,
+ fontFamily: MIND_MAP_LABEL_FONT,
+ },
+ };
+ }
+ if (role === "primary") {
+ return {
+ body: {
+ fill: palette.nodeFill,
+ stroke: palette.topicStroke,
+ strokeWidth: 1.5,
+ rx: 10,
+ ry: 10,
+ },
+ label: {
+ fill: palette.nodeText,
+ fontSize: 14,
+ fontWeight: 650,
+ fontFamily: MIND_MAP_LABEL_FONT,
+ },
+ };
+ }
+ return {
+ body: {
+ fill: palette.canvas,
+ stroke: palette.nodeStroke,
+ strokeWidth: 1,
+ rx: 8,
+ ry: 8,
+ },
+ label: {
+ fill: palette.nodeText,
+ fontSize: 13,
+ fontWeight: 500,
+ fontFamily: MIND_MAP_LABEL_FONT,
+ },
+ };
+};
+
+export const mindMapEdgeVisual = (sourceRole: MindMapRole, palette: MindMapPalette) => (
+ sourceRole === "root"
+ ? { stroke: palette.mindMapEdge, sourceWidth: 3.1, targetWidth: 1.55 }
+ : sourceRole === "primary"
+ ? { stroke: palette.mindMapEdge, sourceWidth: 1.85, targetWidth: 1.15 }
+ : { stroke: palette.mindMapEdge, sourceWidth: 1.25, targetWidth: 0.9 }
+);
+
+export const mindMapBranchSides = (source: MindMapBox, target: MindMapBox) => {
+ const sourceCenter = source.x + source.width / 2;
+ const targetCenter = target.x + target.width / 2;
+ return targetCenter >= sourceCenter
+ ? { source: "right" as const, target: "left" as const }
+ : { source: "left" as const, target: "right" as const };
+};
+
+const formatPoint = (value: number) => (Math.round(value * 100) / 100).toFixed(2);
+
+const cubicPoint = (p0: MindMapPoint, p1: MindMapPoint, p2: MindMapPoint, p3: MindMapPoint, t: number) => {
+ const u = 1 - t;
+ return {
+ x: u * u * u * p0.x + 3 * u * u * t * p1.x + 3 * u * t * t * p2.x + t * t * t * p3.x,
+ y: u * u * u * p0.y + 3 * u * u * t * p1.y + 3 * u * t * t * p2.y + t * t * t * p3.y,
+ };
+};
+
+const cubicTangent = (p0: MindMapPoint, p1: MindMapPoint, p2: MindMapPoint, p3: MindMapPoint, t: number) => {
+ const u = 1 - t;
+ return {
+ x: 3 * u * u * (p1.x - p0.x) + 6 * u * t * (p2.x - p1.x) + 3 * t * t * (p3.x - p2.x),
+ y: 3 * u * u * (p1.y - p0.y) + 6 * u * t * (p2.y - p1.y) + 3 * t * t * (p3.y - p2.y),
+ };
+};
+
+export const mindMapConnectorPath = (
+ sourcePoint: MindMapPoint,
+ targetPoint: MindMapPoint,
+ sourceWidth = 2.4,
+ targetWidth = 1.15,
+) => {
+ const dx = targetPoint.x - sourcePoint.x;
+ const dy = targetPoint.y - sourcePoint.y;
+ if (Math.abs(dx) < 0.01 && Math.abs(dy) < 0.01) {
+ return `M ${formatPoint(sourcePoint.x)} ${formatPoint(sourcePoint.y)} L ${formatPoint(targetPoint.x)} ${formatPoint(targetPoint.y)}`;
+ }
+ const controlX = (sourcePoint.x + targetPoint.x) / 2;
+ const p0 = sourcePoint;
+ const p1 = { x: controlX, y: sourcePoint.y };
+ const p2 = { x: controlX, y: targetPoint.y };
+ const p3 = targetPoint;
+ const samples = 20;
+ const left: MindMapPoint[] = [];
+ const right: MindMapPoint[] = [];
+ for (let index = 0; index <= samples; index += 1) {
+ const t = index / samples;
+ const point = cubicPoint(p0, p1, p2, p3, t);
+ const tangent = cubicTangent(p0, p1, p2, p3, t);
+ const length = Math.hypot(tangent.x, tangent.y) || 1;
+ const half = ((1 - t) * sourceWidth + t * targetWidth) / 2;
+ const nx = -tangent.y / length;
+ const ny = tangent.x / length;
+ left.push({ x: point.x + nx * half, y: point.y + ny * half });
+ right.push({ x: point.x - nx * half, y: point.y - ny * half });
+ }
+ const start = left[0];
+ const commands = [`M ${formatPoint(start.x)} ${formatPoint(start.y)}`];
+ for (let index = 1; index < left.length; index += 1) {
+ commands.push(`L ${formatPoint(left[index].x)} ${formatPoint(left[index].y)}`);
+ }
+ for (let index = right.length - 1; index >= 0; index -= 1) {
+ commands.push(`L ${formatPoint(right[index].x)} ${formatPoint(right[index].y)}`);
+ }
+ commands.push("Z");
+ return commands.join(" ");
+};
+
+export const mindMapConnector = (
+ sourcePoint: MindMapPoint,
+ targetPoint: MindMapPoint,
+ _routePoints?: MindMapPoint[],
+ options: { sourceWidth?: number; targetWidth?: number; raw?: boolean } = {},
+) => mindMapConnectorPath(
+ sourcePoint,
+ targetPoint,
+ options.sourceWidth,
+ options.targetWidth,
+);
diff --git a/packages/shared/src/diagram-view.ts b/packages/shared/src/diagram-view.ts
index 4779e93c..26b33ed5 100644
--- a/packages/shared/src/diagram-view.ts
+++ b/packages/shared/src/diagram-view.ts
@@ -1,5 +1,14 @@
import { flowchartNodePresentation } from "./diagram-node-presentation";
import type { ArchitectureResourceIcon, DiagramDocument, DiagramNodeShape, DiagramTheme } from "./diagram";
+import {
+ MIND_MAP_CONNECTOR_NAME,
+ mindMapBranchSides,
+ mindMapEdgeVisual,
+ mindMapNodePresentation,
+ mindMapNodeRole,
+ mindMapNodeVisual,
+ mindMapRootRadius,
+} from "./diagram-mindmap-style";
export type DiagramAppearance = "light" | "dark";
@@ -81,18 +90,29 @@ export const diagramDocumentToX6Cells = (
) => {
const palette = resolvePortableDiagramPalette(document.theme ?? "brand", appearance);
const nodes = document.nodes.map((node) => {
- const presentation = document.kind === "flowchart" ? flowchartNodePresentation(node.shape, node.label) : { width: node.width, height: node.height, text: node.label };
+ const mindMapRole = document.kind === "mind-map" ? mindMapNodeRole(document.nodes, node.id) : null;
+ const mindVisual = mindMapRole ? mindMapNodeVisual(mindMapRole, palette) : null;
+ const presentation = document.kind === "flowchart"
+ ? flowchartNodePresentation(node.shape, node.label)
+ : mindMapRole
+ ? mindMapNodePresentation(node.label, mindMapRole)
+ : { width: node.width, height: node.height, text: node.label };
const isRootTopic = node.shape === "topic" && !node.parentId;
const isTerminator = node.shape === "terminator";
const isBoundary = node.shape === "boundary";
const accent = architectureAccent[node.shape];
const emphasized = isRootTopic || isTerminator;
- const fill = isBoundary
- ? "transparent"
- : accent
- ? (appearance === "dark" ? palette.nodeFill : `${accent}12`)
- : emphasized ? palette.topicFill : palette.nodeFill;
- const stroke = isBoundary ? palette.nodeStroke : accent ?? (emphasized ? palette.topicStroke : palette.nodeStroke);
+ const fill = mindVisual
+ ? mindVisual.body.fill
+ : isBoundary
+ ? "transparent"
+ : accent
+ ? (appearance === "dark" ? palette.nodeFill : `${accent}12`)
+ : emphasized ? palette.topicFill : palette.nodeFill;
+ const stroke = mindVisual
+ ? mindVisual.body.stroke
+ : isBoundary ? palette.nodeStroke : accent ?? (emphasized ? palette.topicStroke : palette.nodeStroke);
+ const rootRadius = mindMapRole === "root" ? mindMapRootRadius(presentation.height) : undefined;
const usesArchitectureIcon = document.kind === "architecture" && !isBoundary;
const iconGlyph = node.resourceIcon
? architectureResourceGlyphs[node.resourceIcon]
@@ -115,18 +135,19 @@ export const diagramDocumentToX6Cells = (
body: {
fill,
stroke,
- strokeWidth: isBoundary || emphasized || accent ? 1.5 : 1,
+ strokeWidth: mindVisual?.body.strokeWidth ?? (isBoundary || emphasized || accent ? 1.5 : 1),
strokeDasharray: isBoundary || node.shape === "external" ? "7 5" : undefined,
- rx: isTerminator ? 24 : node.shape === "database" ? 24 : 11,
- ry: isTerminator ? 24 : node.shape === "database" ? 24 : 11,
+ rx: rootRadius ?? mindVisual?.body.rx ?? (isTerminator ? 24 : node.shape === "database" ? 24 : 11),
+ ry: rootRadius ?? mindVisual?.body.ry ?? (isTerminator ? 24 : node.shape === "database" ? 24 : 11),
...(node.shape === "decision" ? { refPoints: "0,10 10,0 20,10 10,20" } : {}),
},
label: {
text: presentation.text,
- lineHeight: 18,
- fill: emphasized ? palette.topicText : palette.nodeText,
- fontSize: node.shape === "topic" ? 14 : isBoundary ? 12 : 13,
- fontWeight: emphasized || isBoundary || accent ? 650 : 500,
+ lineHeight: mindMapRole === "root" ? 20 : 18,
+ fill: mindVisual?.label.fill ?? (emphasized ? palette.topicText : palette.nodeText),
+ fontSize: mindVisual?.label.fontSize ?? (node.shape === "topic" ? 14 : isBoundary ? 12 : 13),
+ fontWeight: mindVisual?.label.fontWeight ?? (emphasized || isBoundary || accent ? 650 : 500),
+ ...(mindVisual ? { fontFamily: mindVisual.label.fontFamily } : {}),
...(isBoundary ? { refX: 18, refY: 22, textAnchor: "start", textVerticalAnchor: "middle" } : {}),
...(usesArchitectureIcon ? { refX: 54, refY: "50%", textAnchor: "start", textVerticalAnchor: "middle" } : {}),
},
@@ -155,21 +176,36 @@ export const diagramDocumentToX6Cells = (
},
};
});
+ const projectedById = new Map(nodes.map((node) => [node.id, node]));
const edges = document.edges.map((edge) => {
const edgeKind = edge.kind ?? (document.kind === "architecture" ? "dependency" : undefined);
- const stroke = edgeKind === "data" ? "#7C3AED" : edgeKind === "async" ? "#EA580C" : document.kind === "mind-map" ? palette.mindMapEdge : palette.flowEdge;
+ const sourceNode = projectedById.get(edge.source);
+ const targetNode = projectedById.get(edge.target);
+ const mindMapSourceRole = document.kind === "mind-map" ? mindMapNodeRole(document.nodes, edge.source) : null;
+ const mindEdge = mindMapSourceRole ? mindMapEdgeVisual(mindMapSourceRole, palette) : null;
+ const sides = sourceNode && targetNode
+ ? mindMapBranchSides(sourceNode, targetNode)
+ : { source: "right" as const, target: "left" as const };
+ const stroke = edgeKind === "data" ? "#7C3AED" : edgeKind === "async" ? "#EA580C" : mindEdge?.stroke ?? palette.flowEdge;
return {
id: edge.id,
- source: { cell: edge.source },
- target: { cell: edge.target },
+ source: document.kind === "mind-map" ? { cell: edge.source, anchor: { name: sides.source } } : { cell: edge.source },
+ target: document.kind === "mind-map" ? { cell: edge.target, anchor: { name: sides.target } } : { cell: edge.target },
router: document.kind === "flowchart" ? { name: "manhattan", args: { padding: 28, step: 10 } } : undefined,
- connector: { name: document.kind === "mind-map" ? "smooth" : "rounded", args: { radius: 10 } },
+ connector: document.kind === "mind-map"
+ ? { name: MIND_MAP_CONNECTOR_NAME, args: { sourceWidth: mindEdge?.sourceWidth, targetWidth: mindEdge?.targetWidth } }
+ : { name: "rounded", args: { radius: 10 } },
attrs: { line: {
stroke,
- strokeWidth: document.kind === "mind-map" ? 2 : 1.5,
+ strokeWidth: mindEdge ? 0.5 : 1.5,
strokeDasharray: edgeKind === "async" ? "7 5" : undefined,
sourceMarker: edge.bidirectional ? { name: "block", width: 8, height: 6 } : null,
targetMarker: document.kind === "mind-map" ? null : { name: "block", width: 8, height: 6 },
+ ...(mindEdge ? {
+ fill: stroke,
+ strokeLinejoin: "round",
+ strokeLinecap: "round",
+ } : { fill: "none" }),
} },
labels: edge.label ? [{ attrs: {
label: { text: edge.label, fill: palette.nodeText, fontSize: 12, lineHeight: 16, textWrap: { width: 140, height: 512 } },
diff --git a/packages/shared/src/diagram.test.mjs b/packages/shared/src/diagram.test.mjs
index 6151ea37..2632e575 100644
--- a/packages/shared/src/diagram.test.mjs
+++ b/packages/shared/src/diagram.test.mjs
@@ -62,9 +62,13 @@ describe("diagram document", () => {
const light = diagramDocumentToX6Cells(document, "light");
expect(light.canvas).toBe("#F8FAF9");
expect(light.nodes[0].attrs.body.fill).toBe("#16A06E");
+ expect(light.nodes[0].attrs.body.rx).toBe(23);
expect(light.nodes[1].attrs.body.fill).toBe("#F0F8F4");
+ expect(light.nodes.find((node) => node.id === "topic-1-a").attrs.body.fill).toBe("#F8FAF9");
expect(light.edges[0].attrs.line.stroke).toBe("#55B891");
expect(light.edges[0].attrs.line.targetMarker).toBeNull();
+ expect(light.edges[0].connector.name).toBe("edgeever-mindmap");
+ expect(light.edges[0].source.anchor.name).toBe("right");
const dark = diagramDocumentToX6Cells(document, "dark");
expect(dark.canvas).toBe("#101311");
@@ -77,7 +81,8 @@ describe("diagram document", () => {
const source = diagramDocumentToMermaid(document);
expect(source).toContain("flowchart LR");
expect(source).toContain("核心 &lt;主题&gt; &quot;A&amp;B&quot;");
- expect(source).toContain("n0 --> n1");
+ expect(source).toContain("n0 --- n1");
+ expect(source).toContain("class n0 mindRoot");
});
test("round-trips architecture components, boundaries, and semantic connections", () => {
@@ -143,5 +148,6 @@ test('native flowchart projection shares label sizing and obstacle routing witho
expect(projection.nodes[1].height).toBeGreaterThan(document.nodes[1].height);
expect(projection.nodes[1].attrs.label.text.replaceAll('\n', '')).toBe(document.nodes[1].label.replaceAll('\n', ''));
expect(projection.edges[0].router.name).toBe('manhattan');
+ expect(projection.edges[0].attrs.line.fill).toBe('none');
expect(document).toEqual(original);
});
diff --git a/packages/shared/src/diagram.ts b/packages/shared/src/diagram.ts
index b5202aab..ebf1348e 100644
--- a/packages/shared/src/diagram.ts
+++ b/packages/shared/src/diagram.ts
@@ -304,7 +304,17 @@ export const diagramDocumentToMermaid = (document: DiagramDocument) => {
const target = nodeIds.get(edge.target);
if (!source || !target) continue;
const label = edge.label ? `|"${escapeMermaidLabel(edge.label)}"|` : "";
- lines.push(` ${source} -->${label} ${target}`);
+ const connector = document.kind === "mind-map" ? "---" : "-->";
+ lines.push(` ${source} ${connector}${label} ${target}`);
+ }
+
+ if (document.kind === "mind-map") {
+ const root = document.nodes.find((node) => node.shape === "topic" && !node.parentId);
+ const rootId = root ? nodeIds.get(root.id) : undefined;
+ if (rootId) {
+ lines.push(" classDef mindRoot fill:#16A06E,stroke:#12845B,color:#fff,stroke-width:1.5px");
+ lines.push(` class ${rootId} mindRoot`);
+ }
}
return lines.join("\n");
@@ -319,15 +329,23 @@ export const createDefaultDiagramDocument = (kind: DiagramKind): DiagramDocument
schemaVersion: DIAGRAM_SCHEMA_VERSION,
kind,
nodes: [
- { id: "topic-root", label: "核心主题", x: 72, y: 150, width: 112, height: 42, shape: "topic" },
- { id: "topic-1", label: "分支主题", x: 256, y: 88, width: 92, height: 36, shape: "topic", parentId: "topic-root" },
- { id: "topic-2", label: "分支主题", x: 256, y: 153, width: 92, height: 36, shape: "topic", parentId: "topic-root" },
- { id: "topic-3", label: "分支主题", x: 256, y: 218, width: 92, height: 36, shape: "topic", parentId: "topic-root" },
+ { id: "topic-root", label: "核心主题", x: 72, y: 168, width: 124, height: 46, shape: "topic" },
+ { id: "topic-1", label: "采集想法", x: 268, y: 117, width: 96, height: 36, shape: "topic", parentId: "topic-root" },
+ { id: "topic-2", label: "整理结构", x: 268, y: 201, width: 96, height: 36, shape: "topic", parentId: "topic-root" },
+ { id: "topic-3", label: "输出分享", x: 268, y: 257, width: 96, height: 36, shape: "topic", parentId: "topic-root" },
+ { id: "topic-1-a", label: "快速记录", x: 436, y: 89, width: 96, height: 36, shape: "topic", parentId: "topic-1" },
+ { id: "topic-1-b", label: "跨设备同步", x: 436, y: 145, width: 96, height: 36, shape: "topic", parentId: "topic-1" },
+ { id: "topic-2-a", label: "笔记本", x: 436, y: 201, width: 96, height: 36, shape: "topic", parentId: "topic-2" },
+ { id: "topic-3-a", label: "公开链接", x: 436, y: 257, width: 96, height: 36, shape: "topic", parentId: "topic-3" },
],
edges: [
{ id: "branch-1", source: "topic-root", target: "topic-1" },
{ id: "branch-2", source: "topic-root", target: "topic-2" },
{ id: "branch-3", source: "topic-root", target: "topic-3" },
+ { id: "branch-1-a", source: "topic-1", target: "topic-1-a" },
+ { id: "branch-1-b", source: "topic-1", target: "topic-1-b" },
+ { id: "branch-2-a", source: "topic-2", target: "topic-2-a" },
+ { id: "branch-3-a", source: "topic-3", target: "topic-3-a" },
],
};
}
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts
index 71f2d4a5..651004cc 100644
--- a/packages/shared/src/index.ts
+++ b/packages/shared/src/index.ts
@@ -30,6 +30,7 @@ export * from "./sync";
export * from "./desktop-rpc";
export * from "./deployment-metadata";
export * from "./diagram";
+export * from "./diagram-mindmap-style";
export * from "./diagram-view";
export * from "./file-attachment";
export * from "./note-image-card";