@tldraw/mermaid 4.6.0-canary.0bcbb3ed5bcb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist-cjs/blueprint.js +17 -0
  2. package/dist-cjs/blueprint.js.map +7 -0
  3. package/dist-cjs/colors.js +173 -0
  4. package/dist-cjs/colors.js.map +7 -0
  5. package/dist-cjs/createMermaidDiagram.js +144 -0
  6. package/dist-cjs/createMermaidDiagram.js.map +7 -0
  7. package/dist-cjs/flowchartDiagram.js +202 -0
  8. package/dist-cjs/flowchartDiagram.js.map +7 -0
  9. package/dist-cjs/index.d.ts +114 -0
  10. package/dist-cjs/index.js +34 -0
  11. package/dist-cjs/index.js.map +7 -0
  12. package/dist-cjs/renderBlueprint.js +314 -0
  13. package/dist-cjs/renderBlueprint.js.map +7 -0
  14. package/dist-cjs/sequenceDiagram.js +686 -0
  15. package/dist-cjs/sequenceDiagram.js.map +7 -0
  16. package/dist-cjs/stateDiagram.js +373 -0
  17. package/dist-cjs/stateDiagram.js.map +7 -0
  18. package/dist-cjs/svgParsing.js +187 -0
  19. package/dist-cjs/svgParsing.js.map +7 -0
  20. package/dist-cjs/utils.js +75 -0
  21. package/dist-cjs/utils.js.map +7 -0
  22. package/dist-esm/blueprint.mjs +1 -0
  23. package/dist-esm/blueprint.mjs.map +7 -0
  24. package/dist-esm/colors.mjs +153 -0
  25. package/dist-esm/colors.mjs.map +7 -0
  26. package/dist-esm/createMermaidDiagram.mjs +114 -0
  27. package/dist-esm/createMermaidDiagram.mjs.map +7 -0
  28. package/dist-esm/flowchartDiagram.mjs +188 -0
  29. package/dist-esm/flowchartDiagram.mjs.map +7 -0
  30. package/dist-esm/index.d.mts +114 -0
  31. package/dist-esm/index.mjs +14 -0
  32. package/dist-esm/index.mjs.map +7 -0
  33. package/dist-esm/renderBlueprint.mjs +298 -0
  34. package/dist-esm/renderBlueprint.mjs.map +7 -0
  35. package/dist-esm/sequenceDiagram.mjs +666 -0
  36. package/dist-esm/sequenceDiagram.mjs.map +7 -0
  37. package/dist-esm/stateDiagram.mjs +359 -0
  38. package/dist-esm/stateDiagram.mjs.map +7 -0
  39. package/dist-esm/svgParsing.mjs +167 -0
  40. package/dist-esm/svgParsing.mjs.map +7 -0
  41. package/dist-esm/utils.mjs +55 -0
  42. package/dist-esm/utils.mjs.map +7 -0
  43. package/package.json +62 -0
  44. package/src/blueprint.ts +75 -0
  45. package/src/colors.ts +215 -0
  46. package/src/createMermaidDiagram.test.ts +31 -0
  47. package/src/createMermaidDiagram.ts +155 -0
  48. package/src/flowchartDiagram.ts +232 -0
  49. package/src/index.ts +18 -0
  50. package/src/mermaidDiagrams.test.ts +880 -0
  51. package/src/renderBlueprint.ts +373 -0
  52. package/src/sequenceDiagram.ts +851 -0
  53. package/src/stateDiagram.ts +477 -0
  54. package/src/svgParsing.ts +240 -0
  55. package/src/utils.ts +73 -0
@@ -0,0 +1,114 @@
1
+ import { Editor } from 'tldraw';
2
+ import type { TLArrowShapeArrowheadStyle } from 'tldraw';
3
+ import type { TLDefaultColorStyle } from 'tldraw';
4
+ import type { TLDefaultDashStyle } from 'tldraw';
5
+ import type { TLDefaultFillStyle } from 'tldraw';
6
+ import type { TLDefaultHorizontalAlignStyle } from 'tldraw';
7
+ import type { TLDefaultSizeStyle } from 'tldraw';
8
+ import type { TLDefaultVerticalAlignStyle } from 'tldraw';
9
+ import type { TLGeoShapeGeoStyle } from 'tldraw';
10
+
11
+ /** @public */
12
+ export declare interface BlueprintRenderingOptions {
13
+ centerOnPosition?: boolean;
14
+ position?: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ }
19
+
20
+ /**
21
+ * Parse mermaid text and create tldraw shapes for supported diagram types.
22
+ * Returns the SVG string for supported diagrams, or `null` when the diagram type
23
+ * is unsupported (after calling `onUnsupportedDiagram` if provided).
24
+ * Throws {@link MermaidDiagramError} if parsing fails.
25
+ * @public
26
+ */
27
+ export declare function createMermaidDiagram(editor: Editor, text: string, options?: MermaidDiagramOptions): Promise<void>;
28
+
29
+ /**
30
+ * An intermediate representation of a parsed mermaid diagram as abstract nodes,
31
+ * edges, and lines with layout positions and tldraw style props. Produced by
32
+ * the diagram-specific converters and consumed by `renderBlueprint` to create
33
+ * actual tldraw shapes on the canvas.
34
+ *
35
+ * @public
36
+ */
37
+ export declare interface DiagramMermaidBlueprint {
38
+ nodes: MermaidBlueprintGeoNode[];
39
+ edges: MermaidBlueprintEdge[];
40
+ lines?: MermaidBlueprintLineNode[];
41
+ groups?: string[][];
42
+ }
43
+
44
+ /** @public */
45
+ export declare interface MermaidBlueprintEdge {
46
+ startNodeId: string;
47
+ endNodeId: string;
48
+ label?: string;
49
+ bend: number;
50
+ arrowheadEnd?: TLArrowShapeArrowheadStyle;
51
+ arrowheadStart?: TLArrowShapeArrowheadStyle;
52
+ dash?: TLDefaultDashStyle;
53
+ size?: TLDefaultSizeStyle;
54
+ color?: TLDefaultColorStyle;
55
+ anchorStartY?: number;
56
+ anchorEndY?: number;
57
+ isExact?: boolean;
58
+ isPrecise?: boolean;
59
+ isExactEnd?: boolean;
60
+ isPreciseEnd?: boolean;
61
+ decoration?: {
62
+ type: 'autonumber';
63
+ value: string;
64
+ };
65
+ }
66
+
67
+ /** @public */
68
+ export declare interface MermaidBlueprintGeoNode {
69
+ id: string;
70
+ x: number;
71
+ y: number;
72
+ w: number;
73
+ h: number;
74
+ geo: TLGeoShapeGeoStyle;
75
+ parentId?: string;
76
+ label?: string;
77
+ fill?: TLDefaultFillStyle;
78
+ color?: TLDefaultColorStyle;
79
+ dash?: TLDefaultDashStyle;
80
+ size?: TLDefaultSizeStyle;
81
+ align?: TLDefaultHorizontalAlignStyle;
82
+ verticalAlign?: TLDefaultVerticalAlignStyle;
83
+ }
84
+
85
+ /** @public */
86
+ export declare interface MermaidBlueprintLineNode {
87
+ id: string;
88
+ x: number;
89
+ y: number;
90
+ endX?: number;
91
+ endY: number;
92
+ dash?: TLDefaultDashStyle;
93
+ size?: TLDefaultSizeStyle;
94
+ color?: TLDefaultColorStyle;
95
+ }
96
+
97
+ /** @public */
98
+ export declare class MermaidDiagramError extends Error {
99
+ diagramType: string;
100
+ type: 'parse' | 'unsupported';
101
+ constructor(diagramType: string, type: 'parse' | 'unsupported');
102
+ }
103
+
104
+ /** @public */
105
+ export declare interface MermaidDiagramOptions {
106
+ mermaidConfig?: Record<string, any>;
107
+ blueprintRender?: BlueprintRenderingOptions;
108
+ onUnsupportedDiagram?(svg: string): Promise<void>;
109
+ }
110
+
111
+ /** @public */
112
+ export declare function renderBlueprint(editor: Editor, blueprint: DiagramMermaidBlueprint, opts?: BlueprintRenderingOptions): void;
113
+
114
+ export { }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ MermaidDiagramError: () => import_createMermaidDiagram.MermaidDiagramError,
22
+ createMermaidDiagram: () => import_createMermaidDiagram.createMermaidDiagram,
23
+ renderBlueprint: () => import_renderBlueprint.renderBlueprint
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_utils = require("@tldraw/utils");
27
+ var import_createMermaidDiagram = require("./createMermaidDiagram");
28
+ var import_renderBlueprint = require("./renderBlueprint");
29
+ (0, import_utils.registerTldrawLibraryVersion)(
30
+ "@tldraw/mermaid",
31
+ "4.6.0-canary.0bcbb3ed5bcb",
32
+ "cjs"
33
+ );
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import { registerTldrawLibraryVersion } from '@tldraw/utils'\n\nexport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintGeoNode,\n\tMermaidBlueprintLineNode,\n} from './blueprint'\nexport { createMermaidDiagram, MermaidDiagramError } from './createMermaidDiagram'\nexport type { MermaidDiagramOptions } from './createMermaidDiagram'\nexport { renderBlueprint } from './renderBlueprint'\nexport type { BlueprintRenderingOptions } from './renderBlueprint'\n\nregisterTldrawLibraryVersion(\n\t(globalThis as any).TLDRAW_LIBRARY_NAME,\n\t(globalThis as any).TLDRAW_LIBRARY_VERSION,\n\t(globalThis as any).TLDRAW_LIBRARY_MODULES\n)\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAQ7C,kCAA0D;AAE1D,6BAAgC;AAAA,IAGhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var renderBlueprint_exports = {};
20
+ __export(renderBlueprint_exports, {
21
+ renderBlueprint: () => renderBlueprint
22
+ });
23
+ module.exports = __toCommonJS(renderBlueprint_exports);
24
+ var import_tldraw = require("tldraw");
25
+ var import_utils = require("./utils");
26
+ const defaultBlueprintRenderingOptions = {
27
+ centerOnPosition: true
28
+ };
29
+ function renderBlueprint(editor, blueprint, opts) {
30
+ const options = { ...defaultBlueprintRenderingOptions, ...opts || {} };
31
+ const { nodes, edges, lines } = blueprint;
32
+ const bounds = computeBlueprintBounds(nodes, lines);
33
+ const center = options.position ? options.position : editor.user.getIsPasteAtCursorMode() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center;
34
+ const offsetX = options.centerOnPosition ? center.x - (bounds.maxX + bounds.minX) / 2 : center.x - bounds.minX;
35
+ const offsetY = options.centerOnPosition ? center.y - (bounds.maxY + bounds.minY) / 2 : center.y - bounds.minY;
36
+ const ordered = (0, import_utils.orderTopDown)(
37
+ nodes,
38
+ (n) => n.id,
39
+ (n) => n.parentId
40
+ );
41
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
42
+ const shapeIds = /* @__PURE__ */ new Map();
43
+ if (lines) {
44
+ for (const line of lines) {
45
+ const lineId = (0, import_tldraw.createShapeId)();
46
+ shapeIds.set(line.id, lineId);
47
+ editor.createShape({
48
+ id: lineId,
49
+ type: "line",
50
+ x: offsetX + line.x,
51
+ y: offsetY + line.y,
52
+ props: {
53
+ dash: line.dash ?? "solid",
54
+ size: line.size ?? "s",
55
+ color: line.color ?? "black",
56
+ spline: "line",
57
+ points: {
58
+ a1: { id: "a1", index: "a1", x: 0, y: 0 },
59
+ a2: { id: "a2", index: "a2", x: line.endX ?? 0, y: line.endY }
60
+ }
61
+ }
62
+ });
63
+ }
64
+ }
65
+ for (const node of ordered) {
66
+ const shapeId = (0, import_tldraw.createShapeId)();
67
+ shapeIds.set(node.id, shapeId);
68
+ const parent = node.parentId ? nodeById.get(node.parentId) : void 0;
69
+ const parentShapeId = node.parentId ? shapeIds.get(node.parentId) : void 0;
70
+ const absoluteX = offsetX + node.x;
71
+ const absoluteY = offsetY + node.y;
72
+ const x = parent ? absoluteX - (offsetX + parent.x) : absoluteX;
73
+ const y = parent ? absoluteY - (offsetY + parent.y) : absoluteY;
74
+ editor.createShape({
75
+ id: shapeId,
76
+ type: "geo",
77
+ x,
78
+ y,
79
+ parentId: parentShapeId,
80
+ props: {
81
+ geo: node.geo,
82
+ w: node.w,
83
+ h: node.h,
84
+ fill: node.fill ?? "none",
85
+ color: node.color ?? "black",
86
+ dash: node.dash ?? "draw",
87
+ size: node.size ?? "m",
88
+ ...node.label && { richText: (0, import_tldraw.toRichText)((0, import_utils.sanitizeDiagramText)(node.label)) },
89
+ ...node.align && { align: node.align },
90
+ ...node.verticalAlign && { verticalAlign: node.verticalAlign }
91
+ }
92
+ });
93
+ }
94
+ const arrowIds = [];
95
+ for (const edge of edges) {
96
+ const arrowId = createArrowFromEdge(editor, edge, shapeIds);
97
+ if (arrowId) arrowIds.push(arrowId);
98
+ }
99
+ const groupedIds = /* @__PURE__ */ new Set();
100
+ const subGroupIds = [];
101
+ if (blueprint.groups) {
102
+ for (const group of blueprint.groups) {
103
+ const members = [];
104
+ for (const blueprintId of group) {
105
+ const memberShapeId = shapeIds.get(blueprintId);
106
+ if (memberShapeId) {
107
+ members.push(memberShapeId);
108
+ groupedIds.add(memberShapeId);
109
+ }
110
+ }
111
+ if (members.length > 1) {
112
+ editor.groupShapes(members);
113
+ const first = editor.getShape(members[0]);
114
+ if (first && first.parentId !== editor.getCurrentPageId()) {
115
+ subGroupIds.push(first.parentId);
116
+ } else {
117
+ subGroupIds.push(members[0]);
118
+ }
119
+ } else if (members.length === 1) {
120
+ subGroupIds.push(members[0]);
121
+ }
122
+ }
123
+ }
124
+ const topLevelIds = [...subGroupIds];
125
+ for (const node of nodes) {
126
+ if (!node.parentId) {
127
+ const nodeShapeId = shapeIds.get(node.id);
128
+ if (nodeShapeId && !groupedIds.has(nodeShapeId)) topLevelIds.push(nodeShapeId);
129
+ }
130
+ }
131
+ if (lines) {
132
+ for (const line of lines) {
133
+ const lineShapeId = shapeIds.get(line.id);
134
+ if (lineShapeId && !groupedIds.has(lineShapeId)) topLevelIds.push(lineShapeId);
135
+ }
136
+ }
137
+ topLevelIds.push(...arrowIds);
138
+ let rootShapeId;
139
+ if (topLevelIds.length > 1) {
140
+ editor.groupShapes(topLevelIds);
141
+ const first = editor.getShape(topLevelIds[0]);
142
+ if (first && first.parentId !== editor.getCurrentPageId()) {
143
+ rootShapeId = first.parentId;
144
+ }
145
+ } else if (topLevelIds.length === 1) {
146
+ rootShapeId = topLevelIds[0];
147
+ }
148
+ if (rootShapeId) {
149
+ const actualBounds = editor.getShapePageBounds(rootShapeId);
150
+ if (actualBounds) {
151
+ const desiredX = options.centerOnPosition ? center.x - actualBounds.w / 2 : center.x;
152
+ const desiredY = options.centerOnPosition ? center.y - actualBounds.h / 2 : center.y;
153
+ const dx = desiredX - actualBounds.x;
154
+ const dy = desiredY - actualBounds.y;
155
+ if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
156
+ const shape = editor.getShape(rootShapeId);
157
+ editor.updateShape({
158
+ id: rootShapeId,
159
+ type: shape.type,
160
+ x: shape.x + dx,
161
+ y: shape.y + dy
162
+ });
163
+ }
164
+ }
165
+ }
166
+ }
167
+ function makeArrowBinding(arrowId, targetId, terminal, anchor, isExact, isPrecise) {
168
+ return {
169
+ fromId: arrowId,
170
+ toId: targetId,
171
+ type: "arrow",
172
+ props: { terminal, normalizedAnchor: anchor, isExact, isPrecise }
173
+ };
174
+ }
175
+ function createArrowFromEdge(editor, edge, shapeIds) {
176
+ const startShapeId = shapeIds.get(edge.startNodeId);
177
+ const endShapeId = shapeIds.get(edge.endNodeId);
178
+ if (!startShapeId || !endShapeId) return void 0;
179
+ const startBounds = editor.getShapePageBounds(startShapeId);
180
+ const endBounds = editor.getShapePageBounds(endShapeId);
181
+ if (!startBounds || !endBounds) return void 0;
182
+ const arrowId = (0, import_tldraw.createShapeId)();
183
+ const isSelfLoop = startShapeId === endShapeId;
184
+ const hasPreciseAnchors = edge.anchorStartY !== void 0 || edge.anchorEndY !== void 0;
185
+ let labelText = edge.label;
186
+ if (edge.decoration?.type === "autonumber") {
187
+ const num = edge.decoration.value;
188
+ labelText = labelText ? `${num} ${labelText}` : num;
189
+ }
190
+ const baseProps = {
191
+ dash: edge.dash ?? "solid",
192
+ size: edge.size ?? "s",
193
+ arrowheadEnd: edge.arrowheadEnd ?? "arrow",
194
+ ...edge.arrowheadStart && { arrowheadStart: edge.arrowheadStart },
195
+ color: edge.color ?? "black",
196
+ ...labelText && { richText: (0, import_tldraw.toRichText)((0, import_utils.sanitizeDiagramText)(labelText)) }
197
+ };
198
+ if (hasPreciseAnchors) {
199
+ const startAnchorY = edge.anchorStartY ?? 0.5;
200
+ const endAnchorY = edge.anchorEndY ?? 0.5;
201
+ const exactStart = edge.isExact ?? true;
202
+ const preciseStart = edge.isPrecise ?? true;
203
+ const exactEnd = edge.isExactEnd ?? exactStart;
204
+ const preciseEnd = edge.isPreciseEnd ?? preciseStart;
205
+ const startPoint = {
206
+ x: startBounds.x + startBounds.w * 0.5,
207
+ y: startBounds.y + startBounds.h * startAnchorY
208
+ };
209
+ const endPoint = {
210
+ x: endBounds.x + endBounds.w * 0.5,
211
+ y: endBounds.y + endBounds.h * endAnchorY
212
+ };
213
+ const origin = {
214
+ x: Math.min(startPoint.x, endPoint.x),
215
+ y: Math.min(startPoint.y, endPoint.y)
216
+ };
217
+ editor.run(() => {
218
+ editor.createShape({
219
+ id: arrowId,
220
+ type: "arrow",
221
+ x: origin.x,
222
+ y: origin.y,
223
+ props: {
224
+ ...baseProps,
225
+ start: { x: startPoint.x - origin.x, y: startPoint.y - origin.y },
226
+ end: { x: endPoint.x - origin.x, y: endPoint.y - origin.y },
227
+ bend: edge.bend
228
+ }
229
+ });
230
+ editor.createBindings([
231
+ makeArrowBinding(
232
+ arrowId,
233
+ startShapeId,
234
+ "start",
235
+ { x: 0.5, y: startAnchorY },
236
+ exactStart,
237
+ preciseStart
238
+ ),
239
+ makeArrowBinding(
240
+ arrowId,
241
+ endShapeId,
242
+ "end",
243
+ { x: 0.5, y: endAnchorY },
244
+ exactEnd,
245
+ preciseEnd
246
+ )
247
+ ]);
248
+ });
249
+ return arrowId;
250
+ }
251
+ if (isSelfLoop) {
252
+ editor.run(() => {
253
+ editor.createShape({
254
+ id: arrowId,
255
+ type: "arrow",
256
+ x: startBounds.x,
257
+ y: startBounds.y,
258
+ props: {
259
+ ...baseProps,
260
+ start: { x: startBounds.w / 2, y: 0 },
261
+ end: { x: startBounds.w, y: startBounds.h / 2 },
262
+ bend: -80
263
+ }
264
+ });
265
+ editor.createBindings([
266
+ makeArrowBinding(arrowId, startShapeId, "start", { x: 0.9, y: 0.5 }, false, false),
267
+ makeArrowBinding(arrowId, endShapeId, "end", { x: 0.85, y: 0.8 }, false, false)
268
+ ]);
269
+ });
270
+ return arrowId;
271
+ }
272
+ const startCenter = startBounds.center;
273
+ const endCenter = endBounds.center;
274
+ const arrowOrigin = import_tldraw.Vec.Min(startCenter, endCenter);
275
+ editor.run(() => {
276
+ editor.createShape({
277
+ id: arrowId,
278
+ type: "arrow",
279
+ x: arrowOrigin.x,
280
+ y: arrowOrigin.y,
281
+ props: {
282
+ ...baseProps,
283
+ start: { x: startCenter.x - arrowOrigin.x, y: startCenter.y - arrowOrigin.y },
284
+ end: { x: endCenter.x - arrowOrigin.x, y: endCenter.y - arrowOrigin.y },
285
+ bend: edge.bend
286
+ }
287
+ });
288
+ editor.createBindings([
289
+ makeArrowBinding(arrowId, startShapeId, "start", { x: 0.5, y: 0.5 }, false, false),
290
+ makeArrowBinding(arrowId, endShapeId, "end", { x: 0.5, y: 0.5 }, false, false)
291
+ ]);
292
+ });
293
+ return arrowId;
294
+ }
295
+ function computeBlueprintBounds(nodes, lines) {
296
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
297
+ for (const node of nodes) {
298
+ if (node.parentId) continue;
299
+ minX = Math.min(minX, node.x);
300
+ minY = Math.min(minY, node.y);
301
+ maxX = Math.max(maxX, node.x + node.w);
302
+ maxY = Math.max(maxY, node.y + node.h);
303
+ }
304
+ if (lines) {
305
+ for (const line of lines) {
306
+ minX = Math.min(minX, line.x);
307
+ minY = Math.min(minY, line.y);
308
+ maxX = Math.max(maxX, line.x);
309
+ maxY = Math.max(maxY, line.y + line.endY);
310
+ }
311
+ }
312
+ return { minX, minY, maxX, maxY };
313
+ }
314
+ //# sourceMappingURL=renderBlueprint.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/renderBlueprint.ts"],
4
+ "sourcesContent": ["import {\n\tcreateShapeId,\n\tEditor,\n\tIndexKey,\n\tTLGeoShape,\n\tTLLineShape,\n\tTLShapeId,\n\ttoRichText,\n\tVec,\n} from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintGeoNode,\n\tMermaidBlueprintLineNode,\n} from './blueprint'\nimport { orderTopDown, sanitizeDiagramText } from './utils'\n\n/** @public */\nexport interface BlueprintRenderingOptions {\n\tcenterOnPosition?: boolean\n\tposition?: { x: number; y: number }\n}\n\nconst defaultBlueprintRenderingOptions = {\n\tcenterOnPosition: true,\n}\n\n/** @public */\nexport function renderBlueprint(\n\teditor: Editor,\n\tblueprint: DiagramMermaidBlueprint,\n\topts?: BlueprintRenderingOptions\n) {\n\tconst options = { ...defaultBlueprintRenderingOptions, ...(opts || {}) }\n\tconst { nodes, edges, lines } = blueprint\n\n\tconst bounds = computeBlueprintBounds(nodes, lines)\n\tconst center = options.position\n\t\t? options.position\n\t\t: editor.user.getIsPasteAtCursorMode()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center\n\tconst offsetX = options.centerOnPosition\n\t\t? center.x - (bounds.maxX + bounds.minX) / 2\n\t\t: center.x - bounds.minX\n\tconst offsetY = options.centerOnPosition\n\t\t? center.y - (bounds.maxY + bounds.minY) / 2\n\t\t: center.y - bounds.minY\n\n\tconst ordered = orderTopDown(\n\t\tnodes,\n\t\t(n) => n.id,\n\t\t(n) => n.parentId\n\t)\n\tconst nodeById = new Map(nodes.map((node) => [node.id, node]))\n\n\tconst shapeIds = new Map<string, TLShapeId>()\n\n\t// Lines first so nodes render on top (z-order = creation order in tldraw)\n\tif (lines) {\n\t\tfor (const line of lines) {\n\t\t\tconst lineId = createShapeId()\n\t\t\tshapeIds.set(line.id, lineId)\n\t\t\teditor.createShape<TLLineShape>({\n\t\t\t\tid: lineId,\n\t\t\t\ttype: 'line',\n\t\t\t\tx: offsetX + line.x,\n\t\t\t\ty: offsetY + line.y,\n\t\t\t\tprops: {\n\t\t\t\t\tdash: line.dash ?? 'solid',\n\t\t\t\t\tsize: line.size ?? 's',\n\t\t\t\t\tcolor: line.color ?? 'black',\n\t\t\t\t\tspline: 'line',\n\t\t\t\t\tpoints: {\n\t\t\t\t\t\ta1: { id: 'a1', index: 'a1' as IndexKey, x: 0, y: 0 },\n\t\t\t\t\t\ta2: { id: 'a2', index: 'a2' as IndexKey, x: line.endX ?? 0, y: line.endY },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t}\n\n\tfor (const node of ordered) {\n\t\tconst shapeId = createShapeId()\n\t\tshapeIds.set(node.id, shapeId)\n\n\t\tconst parent = node.parentId ? nodeById.get(node.parentId) : undefined\n\t\tconst parentShapeId = node.parentId ? shapeIds.get(node.parentId) : undefined\n\n\t\tconst absoluteX = offsetX + node.x\n\t\tconst absoluteY = offsetY + node.y\n\t\tconst x = parent ? absoluteX - (offsetX + parent.x) : absoluteX\n\t\tconst y = parent ? absoluteY - (offsetY + parent.y) : absoluteY\n\n\t\teditor.createShape<TLGeoShape>({\n\t\t\tid: shapeId,\n\t\t\ttype: 'geo',\n\t\t\tx,\n\t\t\ty,\n\t\t\tparentId: parentShapeId,\n\t\t\tprops: {\n\t\t\t\tgeo: node.geo,\n\t\t\t\tw: node.w,\n\t\t\t\th: node.h,\n\t\t\t\tfill: node.fill ?? 'none',\n\t\t\t\tcolor: node.color ?? 'black',\n\t\t\t\tdash: node.dash ?? 'draw',\n\t\t\t\tsize: node.size ?? 'm',\n\t\t\t\t...(node.label && { richText: toRichText(sanitizeDiagramText(node.label)) }),\n\t\t\t\t...(node.align && { align: node.align }),\n\t\t\t\t...(node.verticalAlign && { verticalAlign: node.verticalAlign }),\n\t\t\t},\n\t\t})\n\t}\n\n\tconst arrowIds: TLShapeId[] = []\n\tfor (const edge of edges) {\n\t\tconst arrowId = createArrowFromEdge(editor, edge, shapeIds)\n\t\tif (arrowId) arrowIds.push(arrowId)\n\t}\n\n\t// Create sub-groups and track which shape IDs are consumed by a group\n\tconst groupedIds = new Set<TLShapeId>()\n\tconst subGroupIds: TLShapeId[] = []\n\tif (blueprint.groups) {\n\t\tfor (const group of blueprint.groups) {\n\t\t\tconst members: TLShapeId[] = []\n\t\t\tfor (const blueprintId of group) {\n\t\t\t\tconst memberShapeId = shapeIds.get(blueprintId)\n\t\t\t\tif (memberShapeId) {\n\t\t\t\t\tmembers.push(memberShapeId)\n\t\t\t\t\tgroupedIds.add(memberShapeId)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (members.length > 1) {\n\t\t\t\teditor.groupShapes(members)\n\t\t\t\tconst first = editor.getShape(members[0])\n\t\t\t\tif (first && first.parentId !== editor.getCurrentPageId()) {\n\t\t\t\t\tsubGroupIds.push(first.parentId as TLShapeId)\n\t\t\t\t} else {\n\t\t\t\t\tsubGroupIds.push(members[0])\n\t\t\t\t}\n\t\t\t} else if (members.length === 1) {\n\t\t\t\tsubGroupIds.push(members[0])\n\t\t\t}\n\t\t}\n\t}\n\n\t// Collect ungrouped top-level IDs\n\tconst topLevelIds: TLShapeId[] = [...subGroupIds]\n\tfor (const node of nodes) {\n\t\tif (!node.parentId) {\n\t\t\tconst nodeShapeId = shapeIds.get(node.id)\n\t\t\tif (nodeShapeId && !groupedIds.has(nodeShapeId)) topLevelIds.push(nodeShapeId)\n\t\t}\n\t}\n\tif (lines) {\n\t\tfor (const line of lines) {\n\t\t\tconst lineShapeId = shapeIds.get(line.id)\n\t\t\tif (lineShapeId && !groupedIds.has(lineShapeId)) topLevelIds.push(lineShapeId)\n\t\t}\n\t}\n\ttopLevelIds.push(...arrowIds)\n\n\tlet rootShapeId: TLShapeId | undefined\n\tif (topLevelIds.length > 1) {\n\t\teditor.groupShapes(topLevelIds)\n\t\tconst first = editor.getShape(topLevelIds[0])\n\t\tif (first && first.parentId !== editor.getCurrentPageId()) {\n\t\t\trootShapeId = first.parentId as TLShapeId\n\t\t}\n\t} else if (topLevelIds.length === 1) {\n\t\trootShapeId = topLevelIds[0]\n\t}\n\n\tif (rootShapeId) {\n\t\tconst actualBounds = editor.getShapePageBounds(rootShapeId)\n\t\tif (actualBounds) {\n\t\t\tconst desiredX = options.centerOnPosition ? center.x - actualBounds.w / 2 : center.x\n\t\t\tconst desiredY = options.centerOnPosition ? center.y - actualBounds.h / 2 : center.y\n\t\t\tconst dx = desiredX - actualBounds.x\n\t\t\tconst dy = desiredY - actualBounds.y\n\t\t\tif (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {\n\t\t\t\tconst shape = editor.getShape(rootShapeId)!\n\t\t\t\teditor.updateShape({\n\t\t\t\t\tid: rootShapeId,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x + dx,\n\t\t\t\t\ty: shape.y + dy,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction makeArrowBinding(\n\tarrowId: TLShapeId,\n\ttargetId: TLShapeId,\n\tterminal: 'start' | 'end',\n\tanchor: { x: number; y: number },\n\tisExact: boolean,\n\tisPrecise: boolean\n) {\n\treturn {\n\t\tfromId: arrowId,\n\t\ttoId: targetId,\n\t\ttype: 'arrow' as const,\n\t\tprops: { terminal, normalizedAnchor: anchor, isExact, isPrecise },\n\t}\n}\n\nfunction createArrowFromEdge(\n\teditor: Editor,\n\tedge: MermaidBlueprintEdge,\n\tshapeIds: Map<string, TLShapeId>\n): TLShapeId | undefined {\n\tconst startShapeId = shapeIds.get(edge.startNodeId)\n\tconst endShapeId = shapeIds.get(edge.endNodeId)\n\tif (!startShapeId || !endShapeId) return undefined\n\n\tconst startBounds = editor.getShapePageBounds(startShapeId)\n\tconst endBounds = editor.getShapePageBounds(endShapeId)\n\tif (!startBounds || !endBounds) return undefined\n\n\tconst arrowId = createShapeId()\n\tconst isSelfLoop = startShapeId === endShapeId\n\tconst hasPreciseAnchors = edge.anchorStartY !== undefined || edge.anchorEndY !== undefined\n\n\tlet labelText = edge.label\n\tif (edge.decoration?.type === 'autonumber') {\n\t\tconst num = edge.decoration.value\n\t\tlabelText = labelText ? `${num} ${labelText}` : num\n\t}\n\n\tconst baseProps = {\n\t\tdash: edge.dash ?? ('solid' as const),\n\t\tsize: edge.size ?? ('s' as const),\n\t\tarrowheadEnd: edge.arrowheadEnd ?? ('arrow' as const),\n\t\t...(edge.arrowheadStart && { arrowheadStart: edge.arrowheadStart }),\n\t\tcolor: edge.color ?? ('black' as const),\n\t\t...(labelText && { richText: toRichText(sanitizeDiagramText(labelText)) }),\n\t}\n\n\tif (hasPreciseAnchors) {\n\t\tconst startAnchorY = edge.anchorStartY ?? 0.5\n\t\tconst endAnchorY = edge.anchorEndY ?? 0.5\n\t\tconst exactStart = edge.isExact ?? true\n\t\tconst preciseStart = edge.isPrecise ?? true\n\t\tconst exactEnd = edge.isExactEnd ?? exactStart\n\t\tconst preciseEnd = edge.isPreciseEnd ?? preciseStart\n\n\t\tconst startPoint = {\n\t\t\tx: startBounds.x + startBounds.w * 0.5,\n\t\t\ty: startBounds.y + startBounds.h * startAnchorY,\n\t\t}\n\t\tconst endPoint = {\n\t\t\tx: endBounds.x + endBounds.w * 0.5,\n\t\t\ty: endBounds.y + endBounds.h * endAnchorY,\n\t\t}\n\t\tconst origin = {\n\t\t\tx: Math.min(startPoint.x, endPoint.x),\n\t\t\ty: Math.min(startPoint.y, endPoint.y),\n\t\t}\n\n\t\teditor.run(() => {\n\t\t\teditor.createShape({\n\t\t\t\tid: arrowId,\n\t\t\t\ttype: 'arrow',\n\t\t\t\tx: origin.x,\n\t\t\t\ty: origin.y,\n\t\t\t\tprops: {\n\t\t\t\t\t...baseProps,\n\t\t\t\t\tstart: { x: startPoint.x - origin.x, y: startPoint.y - origin.y },\n\t\t\t\t\tend: { x: endPoint.x - origin.x, y: endPoint.y - origin.y },\n\t\t\t\t\tbend: edge.bend,\n\t\t\t\t},\n\t\t\t})\n\t\t\teditor.createBindings([\n\t\t\t\tmakeArrowBinding(\n\t\t\t\t\tarrowId,\n\t\t\t\t\tstartShapeId,\n\t\t\t\t\t'start',\n\t\t\t\t\t{ x: 0.5, y: startAnchorY },\n\t\t\t\t\texactStart,\n\t\t\t\t\tpreciseStart\n\t\t\t\t),\n\t\t\t\tmakeArrowBinding(\n\t\t\t\t\tarrowId,\n\t\t\t\t\tendShapeId,\n\t\t\t\t\t'end',\n\t\t\t\t\t{ x: 0.5, y: endAnchorY },\n\t\t\t\t\texactEnd,\n\t\t\t\t\tpreciseEnd\n\t\t\t\t),\n\t\t\t])\n\t\t})\n\t\treturn arrowId\n\t}\n\n\tif (isSelfLoop) {\n\t\teditor.run(() => {\n\t\t\teditor.createShape({\n\t\t\t\tid: arrowId,\n\t\t\t\ttype: 'arrow',\n\t\t\t\tx: startBounds.x,\n\t\t\t\ty: startBounds.y,\n\t\t\t\tprops: {\n\t\t\t\t\t...baseProps,\n\t\t\t\t\tstart: { x: startBounds.w / 2, y: 0 },\n\t\t\t\t\tend: { x: startBounds.w, y: startBounds.h / 2 },\n\t\t\t\t\tbend: -80,\n\t\t\t\t},\n\t\t\t})\n\t\t\teditor.createBindings([\n\t\t\t\tmakeArrowBinding(arrowId, startShapeId, 'start', { x: 0.9, y: 0.5 }, false, false),\n\t\t\t\tmakeArrowBinding(arrowId, endShapeId, 'end', { x: 0.85, y: 0.8 }, false, false),\n\t\t\t])\n\t\t})\n\t\treturn arrowId\n\t}\n\n\tconst startCenter = startBounds.center\n\tconst endCenter = endBounds.center\n\tconst arrowOrigin = Vec.Min(startCenter, endCenter)\n\n\teditor.run(() => {\n\t\teditor.createShape({\n\t\t\tid: arrowId,\n\t\t\ttype: 'arrow',\n\t\t\tx: arrowOrigin.x,\n\t\t\ty: arrowOrigin.y,\n\t\t\tprops: {\n\t\t\t\t...baseProps,\n\t\t\t\tstart: { x: startCenter.x - arrowOrigin.x, y: startCenter.y - arrowOrigin.y },\n\t\t\t\tend: { x: endCenter.x - arrowOrigin.x, y: endCenter.y - arrowOrigin.y },\n\t\t\t\tbend: edge.bend,\n\t\t\t},\n\t\t})\n\t\teditor.createBindings([\n\t\t\tmakeArrowBinding(arrowId, startShapeId, 'start', { x: 0.5, y: 0.5 }, false, false),\n\t\t\tmakeArrowBinding(arrowId, endShapeId, 'end', { x: 0.5, y: 0.5 }, false, false),\n\t\t])\n\t})\n\n\treturn arrowId\n}\n\nfunction computeBlueprintBounds(\n\tnodes: MermaidBlueprintGeoNode[],\n\tlines?: MermaidBlueprintLineNode[]\n): { minX: number; minY: number; maxX: number; maxY: number } {\n\tlet minX = Infinity,\n\t\tminY = Infinity,\n\t\tmaxX = -Infinity,\n\t\tmaxY = -Infinity\n\tfor (const node of nodes) {\n\t\tif (node.parentId) continue\n\t\tminX = Math.min(minX, node.x)\n\t\tminY = Math.min(minY, node.y)\n\t\tmaxX = Math.max(maxX, node.x + node.w)\n\t\tmaxY = Math.max(maxY, node.y + node.h)\n\t}\n\tif (lines) {\n\t\tfor (const line of lines) {\n\t\t\tminX = Math.min(minX, line.x)\n\t\t\tminY = Math.min(minY, line.y)\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