@node-projects/web-component-designer-mermaid 0.1.0

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.
@@ -0,0 +1,18 @@
1
+ import { IDesignItem, IPropertiesService } from "@node-projects/web-component-designer";
2
+ import { MermaidDocumentPropertiesService } from "./MermaidDocumentPropertiesService.js";
3
+
4
+ export class MermaidPropertyGroupsService {
5
+ private readonly _documentPropertiesService = new MermaidDocumentPropertiesService();
6
+
7
+ getPropertygroups(designItems: IDesignItem[]): { name: string; propertiesService: IPropertiesService; }[] {
8
+ const designItem = designItems?.[0];
9
+ if (!designItem)
10
+ return [];
11
+
12
+ if (designItem.isRootItem)
13
+ return [{ name: "mermaid", propertiesService: this._documentPropertiesService }];
14
+
15
+ const propertiesService = designItem.serviceContainer.getLastServiceWhere("propertyService", service => service.isHandledElement(designItem));
16
+ return propertiesService ? [{ name: "properties", propertiesService }] : [];
17
+ }
18
+ }
@@ -0,0 +1,131 @@
1
+ export type Point = {
2
+ x: number;
3
+ y: number;
4
+ }
5
+
6
+ export type Rect = Point & {
7
+ width: number;
8
+ height: number;
9
+ }
10
+
11
+ export type FlowchartDirection = "TB" | "TD" | "BT" | "RL" | "LR";
12
+
13
+ export function encodeWaypoints(waypoints: Point[]) {
14
+ return waypoints.map(point => `${Math.round(point.x)},${Math.round(point.y)}`).join(" ");
15
+ }
16
+
17
+ export function decodeWaypoints(value: string) {
18
+ if (!value)
19
+ return [];
20
+
21
+ return value.split(/\s+/).map(part => {
22
+ const [x, y] = part.split(",").map(Number);
23
+ return { x, y };
24
+ }).filter(point => Number.isFinite(point.x) && Number.isFinite(point.y));
25
+ }
26
+
27
+ export function boundsFromWaypoints(waypoints: Point[]) {
28
+ const xs = waypoints.map(point => point.x);
29
+ const ys = waypoints.map(point => point.y);
30
+ const minX = Math.min(...xs);
31
+ const maxX = Math.max(...xs);
32
+ const minY = Math.min(...ys);
33
+ const maxY = Math.max(...ys);
34
+ return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
35
+ }
36
+
37
+ export function pathDataFromWaypoints(waypoints: Point[]) {
38
+ if (!waypoints.length)
39
+ return "";
40
+
41
+ return waypoints.map((point, index) => `${index === 0 ? "M" : "L"} ${point.x} ${point.y}`).join(" ");
42
+ }
43
+
44
+ export function midpointFromWaypoints(waypoints: Point[]) {
45
+ if (!waypoints.length)
46
+ return { x: 0, y: 0 };
47
+ if (waypoints.length === 1)
48
+ return waypoints[0];
49
+
50
+ const segmentLengths: number[] = [];
51
+ let totalLength = 0;
52
+ for (let i = 1; i < waypoints.length; i++) {
53
+ const length = distance(waypoints[i - 1], waypoints[i]);
54
+ segmentLengths.push(length);
55
+ totalLength += length;
56
+ }
57
+
58
+ let remaining = totalLength / 2;
59
+ for (let i = 1; i < waypoints.length; i++) {
60
+ const segmentLength = segmentLengths[i - 1];
61
+ if (remaining <= segmentLength) {
62
+ const ratio = segmentLength === 0 ? 0 : remaining / segmentLength;
63
+ return {
64
+ x: waypoints[i - 1].x + (waypoints[i].x - waypoints[i - 1].x) * ratio,
65
+ y: waypoints[i - 1].y + (waypoints[i].y - waypoints[i - 1].y) * ratio,
66
+ };
67
+ }
68
+ remaining -= segmentLength;
69
+ }
70
+
71
+ return waypoints[waypoints.length - 1];
72
+ }
73
+
74
+ export function routeBetweenBounds(source: Rect, target: Rect, direction?: FlowchartDirection) {
75
+ const sourceCenter = center(source);
76
+ const targetCenter = center(target);
77
+ if (direction === "LR" || direction === "RL")
78
+ return [getHorizontalAnchor(source, targetCenter), getHorizontalAnchor(target, sourceCenter)];
79
+ if (direction === "TD" || direction === "TB" || direction === "BT")
80
+ return [getVerticalAnchor(source, targetCenter), getVerticalAnchor(target, sourceCenter)];
81
+ return [getAnchor(source, targetCenter), getAnchor(target, sourceCenter)];
82
+ }
83
+
84
+ export function routeBetweenPoints(source: Point, target: Point) {
85
+ return [source, target];
86
+ }
87
+
88
+ export function getAnchor(rect: Rect, target: Point) {
89
+ const c = center(rect);
90
+ const dx = target.x - c.x;
91
+ const dy = target.y - c.y;
92
+
93
+ if (Math.abs(dx / rect.width) > Math.abs(dy / rect.height)) {
94
+ return {
95
+ x: dx >= 0 ? rect.x + rect.width : rect.x,
96
+ y: c.y,
97
+ };
98
+ }
99
+
100
+ return {
101
+ x: c.x,
102
+ y: dy >= 0 ? rect.y + rect.height : rect.y,
103
+ };
104
+ }
105
+
106
+ function center(rect: Rect) {
107
+ return {
108
+ x: rect.x + rect.width / 2,
109
+ y: rect.y + rect.height / 2,
110
+ };
111
+ }
112
+
113
+ function getHorizontalAnchor(rect: Rect, target: Point) {
114
+ const c = center(rect);
115
+ return {
116
+ x: target.x >= c.x ? rect.x + rect.width : rect.x,
117
+ y: c.y,
118
+ };
119
+ }
120
+
121
+ function getVerticalAnchor(rect: Rect, target: Point) {
122
+ const c = center(rect);
123
+ return {
124
+ x: c.x,
125
+ y: target.y >= c.y ? rect.y + rect.height : rect.y,
126
+ };
127
+ }
128
+
129
+ function distance(a: Point, b: Point) {
130
+ return Math.hypot(b.x - a.x, b.y - a.y);
131
+ }
@@ -0,0 +1,123 @@
1
+ import { AbsolutePlacementService, AltToEnterContainerExtensionProvider, BaseCustomWebComponentPropertiesService, CopyPasteContextMenu, DefaultEditorTypeService, DefaultHtmlParserService, DefaultInstanceService, DefaultModelCommandService, DefaultPropertyEditorTypesService, DeletionService, DesignItemDocumentPositionService, DesignItemService, DragDropService, ElementAtPointService, ElementDragTitleExtensionProvider, ExtensionType, GrayOutDragOverContainerExtensionProvider, GrayOutExtensionProvider, HighlightElementExtensionProvider, IDesignerCanvas, ItemsBelowContextMenu, MagicWandSelectorTool, MultipleItemsSelectedContextMenu, NamedTools, PanTool, PointerTool, PointerToolButtonProvider, PositionExtensionProvider, RectangleSelectorTool, ResizeExtensionProvider, SelectionDefaultExtensionProvider, SelectionService, SelectorToolButtonProvider, SeperatorToolProvider, ServiceContainer, SimpleToolButtonProvider, SnaplinesProviderService, TransformToolButtonProvider, UndoService, ZMoveContextMenu, ZoomTool, ZoomToolButtonProvider } from "@node-projects/web-component-designer";
2
+ import { MermaidLayoutCopyPasteService } from "./services/MermaidLayoutCopyPasteService.js";
3
+ import { MermaidLayoutPlacementService } from "./services/MermaidLayoutPlacementService.js";
4
+ import { MermaidParserService } from "./services/MermaidParserService.js";
5
+ import { rerouteConnectedMermaidEdges } from "./services/MermaidConnectionRouting.js";
6
+ import { ConnectMermaidNodesTool, mermaidFlowIcon } from "./toolbar/ConnectMermaidNodesTool.js";
7
+ import { MermaidDemoView } from "./widgets/views/mermaid-demo-view.js";
8
+ import { MermaidPropertyGroupsService } from "./services/MermaidPropertyGroupsService.js";
9
+ import { MermaidElementsService } from "./services/MermaidElementsService.js";
10
+
11
+ export function createMermaidDesignerServiceContainer() {
12
+ const serviceContainer = new ServiceContainer();
13
+ const parserService = new MermaidParserService();
14
+ const elementsService = new MermaidElementsService("mermaid", new URL("./widgets/elements.json", import.meta.url));
15
+
16
+ serviceContainer.register("instanceService", new DefaultInstanceService());
17
+ serviceContainer.register("containerService", new AbsolutePlacementService());
18
+ serviceContainer.register("containerService", new MermaidLayoutPlacementService());
19
+ serviceContainer.register("snaplinesProviderService", new SnaplinesProviderService());
20
+ serviceContainer.register("htmlParserService", new DefaultHtmlParserService());
21
+ serviceContainer.register("htmlParserService", parserService);
22
+ serviceContainer.register("htmlWriterService", parserService);
23
+ serviceContainer.register("elementAtPointService", new ElementAtPointService());
24
+ serviceContainer.register("dragDropService", new DragDropService());
25
+ serviceContainer.register("copyPasteService", new MermaidLayoutCopyPasteService());
26
+ serviceContainer.register("modelCommandService", new DefaultModelCommandService());
27
+ serviceContainer.register("propertyEditorTypesService", new DefaultPropertyEditorTypesService());
28
+ serviceContainer.register("editorTypeService", new DefaultEditorTypeService());
29
+ serviceContainer.register("propertyGroupsService", new MermaidPropertyGroupsService());
30
+ serviceContainer.register("propertyService", new BaseCustomWebComponentPropertiesService(true));
31
+ serviceContainer.register("designItemService", new DesignItemService());
32
+ serviceContainer.register("deletionService", new DeletionService());
33
+
34
+ serviceContainer.register("undoService", (designerCanvas: IDesignerCanvas) => new UndoService(designerCanvas));
35
+ serviceContainer.register("selectionService", (designerCanvas: IDesignerCanvas) => new SelectionService(designerCanvas, false));
36
+ serviceContainer.register("designItemDocumentPositionService", (designerCanvas: IDesignerCanvas) => new DesignItemDocumentPositionService(designerCanvas));
37
+
38
+ serviceContainer.instanceServiceContainerCreatedCallbacks.push(instanceServiceContainer => {
39
+ const designerCanvas = instanceServiceContainer.designerCanvas;
40
+ elementsService.setInstanceServiceContainer(instanceServiceContainer);
41
+ instanceServiceContainer.selectionService.setSelectedElements([designerCanvas.rootDesignItem]);
42
+ const previousRaiseDesignItemsChanged = designerCanvas.raiseDesignItemsChanged.bind(designerCanvas);
43
+ designerCanvas.raiseDesignItemsChanged = (designItems, action, operationFinished) => {
44
+ previousRaiseDesignItemsChanged(designItems, action, operationFinished);
45
+ if (action === "place" || action === "resize")
46
+ rerouteConnectedMermaidEdges(instanceServiceContainer, designItems, operationFinished);
47
+ };
48
+ });
49
+
50
+ serviceContainer.designerExtensions.set(ExtensionType.Permanent, []);
51
+ serviceContainer.designerExtensions.set(ExtensionType.PrimarySelection, [
52
+ new class extends ElementDragTitleExtensionProvider {
53
+ override shouldExtend(extensionManager: any, designerView: any, designItem: any) {
54
+ if (designItem.element?.localName === "mermaid-edge")
55
+ return false;
56
+ return super.shouldExtend(extensionManager, designerView, designItem);
57
+ }
58
+ }(),
59
+ new class extends PositionExtensionProvider {
60
+ override shouldExtend(extensionManager: any, designerView: any, designItem: any) {
61
+ if (designItem.element?.localName === "mermaid-edge")
62
+ return false;
63
+ return super.shouldExtend(extensionManager, designerView, designItem);
64
+ }
65
+ }(),
66
+ new class extends ResizeExtensionProvider {
67
+ override shouldExtend(extensionManager: any, designerView: any, designItem: any) {
68
+ if (designItem.element?.localName === "mermaid-edge")
69
+ return false;
70
+ return super.shouldExtend(extensionManager, designerView, designItem);
71
+ }
72
+ }(true)
73
+ ]);
74
+ serviceContainer.designerExtensions.set(ExtensionType.Selection, [
75
+ new SelectionDefaultExtensionProvider()
76
+ ]);
77
+ serviceContainer.designerExtensions.set(ExtensionType.PrimarySelectionContainer, []);
78
+ serviceContainer.designerExtensions.set(ExtensionType.MouseOver, [
79
+ new HighlightElementExtensionProvider()
80
+ ]);
81
+ serviceContainer.designerExtensions.set(ExtensionType.ContainerDrag, [
82
+ new GrayOutExtensionProvider()
83
+ ]);
84
+ serviceContainer.designerExtensions.set(ExtensionType.ContainerDragOverAndCanBeEntered, [
85
+ new AltToEnterContainerExtensionProvider(),
86
+ new GrayOutDragOverContainerExtensionProvider(),
87
+ ]);
88
+ serviceContainer.designerExtensions.set(ExtensionType.ContainerExternalDragOverAndCanBeEntered, [
89
+ new GrayOutDragOverContainerExtensionProvider(),
90
+ ]);
91
+
92
+ serviceContainer.designerTools.set(NamedTools.Pointer, new PointerTool());
93
+ serviceContainer.designerTools.set(NamedTools.DrawSelection, new RectangleSelectorTool());
94
+ serviceContainer.designerTools.set(NamedTools.Zoom, new ZoomTool());
95
+ serviceContainer.designerTools.set(NamedTools.Pan, new PanTool());
96
+ serviceContainer.designerTools.set(NamedTools.RectangleSelector, new RectangleSelectorTool());
97
+ serviceContainer.designerTools.set(NamedTools.MagicWandSelector, new MagicWandSelectorTool());
98
+ serviceContainer.designerTools.set("MermaidFlow", new ConnectMermaidNodesTool());
99
+
100
+ serviceContainer.designerContextMenuExtensions = [
101
+ new CopyPasteContextMenu(),
102
+ new ZMoveContextMenu(),
103
+ new MultipleItemsSelectedContextMenu(),
104
+ new ItemsBelowContextMenu()
105
+ ];
106
+
107
+ serviceContainer.designViewToolbarButtons.push(
108
+ new PointerToolButtonProvider(),
109
+ new SeperatorToolProvider(22),
110
+ new SelectorToolButtonProvider(),
111
+ new SeperatorToolProvider(22),
112
+ new SimpleToolButtonProvider("MermaidFlow", mermaidFlowIcon),
113
+ new SeperatorToolProvider(22),
114
+ new ZoomToolButtonProvider(),
115
+ new SeperatorToolProvider(22),
116
+ new TransformToolButtonProvider()
117
+ );
118
+
119
+ serviceContainer.config.demoViewWidget = MermaidDemoView;
120
+ serviceContainer.register("elementsService", elementsService);
121
+
122
+ return serviceContainer;
123
+ }
@@ -0,0 +1,197 @@
1
+ import { DesignItem, EventNames, IDesignerCanvas, InsertAction, ITool, OverlayLayer, ServiceContainer } from "@node-projects/web-component-designer";
2
+ import { encodeWaypoints, FlowchartDirection, getAnchor, Rect, routeBetweenBounds, routeBetweenPoints, pathDataFromWaypoints } from "../services/mermaidGeometry.js";
3
+ import { MermaidNode } from "../widgets/mermaid-node.js";
4
+ import { MermaidRequirementNode } from "../widgets/mermaid-requirement-node.js";
5
+ import { getMermaidDocumentDiagramType } from "../services/MermaidDocumentPropertiesService.js";
6
+
7
+ function createIcon(markup: string) {
8
+ return `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${markup}</svg>`)}`;
9
+ }
10
+
11
+ function findNode(event: PointerEvent, currentElement: Element | null | undefined) {
12
+ if (currentElement instanceof HTMLElement && isConnectableNode(currentElement))
13
+ return currentElement;
14
+
15
+ for (const part of event.composedPath()) {
16
+ if (part instanceof HTMLElement && isConnectableNode(part))
17
+ return part;
18
+ }
19
+
20
+ return null;
21
+ }
22
+
23
+ function isConnectableNode(element: HTMLElement) {
24
+ return element.localName === MermaidNode.is || element.localName === MermaidRequirementNode.is;
25
+ }
26
+
27
+ function getElementBounds(designerCanvas: IDesignerCanvas, element: HTMLElement): Rect {
28
+ const canvasRect = designerCanvas.canvas.getBoundingClientRect();
29
+ const elementRect = element.getBoundingClientRect();
30
+ const zoom = designerCanvas.zoomFactor ?? 1;
31
+
32
+ return {
33
+ x: (elementRect.left - canvasRect.left) / zoom,
34
+ y: (elementRect.top - canvasRect.top) / zoom,
35
+ width: elementRect.width / zoom,
36
+ height: elementRect.height / zoom,
37
+ };
38
+ }
39
+
40
+ function getNodeId(element: HTMLElement) {
41
+ if (element.localName === MermaidRequirementNode.is) {
42
+ let id = element.getAttribute("label");
43
+ if (!id) {
44
+ id = `Req_${Math.random().toString(36).slice(2, 8)}`;
45
+ element.setAttribute("label", id);
46
+ }
47
+ return id;
48
+ }
49
+
50
+ let id = element.getAttribute("node-id");
51
+ if (!id) {
52
+ id = `Node_${Math.random().toString(36).slice(2, 8)}`;
53
+ element.setAttribute("node-id", id);
54
+ }
55
+ return id;
56
+ }
57
+
58
+ export const mermaidFlowIcon = createIcon('<path d="M4 12h12"/><path d="M12 8l4 4-4 4"/>');
59
+
60
+ export class ConnectMermaidNodesTool implements ITool {
61
+ readonly cursor = "crosshair";
62
+
63
+ private _captureElement?: Element;
64
+ private _pointerId?: number;
65
+ private _previewPath?: SVGPathElement;
66
+ private _sourceElement?: HTMLElement;
67
+ private _sourceBounds?: Rect;
68
+
69
+ activated(_serviceContainer: ServiceContainer) {
70
+ }
71
+
72
+ dispose() {
73
+ }
74
+
75
+ pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element) {
76
+ switch (event.type) {
77
+ case EventNames.PointerDown:
78
+ this._begin(designerCanvas, event, currentElement);
79
+ break;
80
+ case EventNames.PointerMove:
81
+ this._update(designerCanvas, event, currentElement);
82
+ break;
83
+ case EventNames.PointerUp:
84
+ this._finish(designerCanvas, event, currentElement);
85
+ break;
86
+ }
87
+ }
88
+
89
+ keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent) {
90
+ if (event.key === "Escape")
91
+ this._cleanup(designerCanvas, true);
92
+ }
93
+
94
+ private _begin(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element) {
95
+ const source = findNode(event, currentElement);
96
+ if (!source)
97
+ return;
98
+
99
+ this._sourceElement = source;
100
+ this._sourceBounds = getElementBounds(designerCanvas, source);
101
+ this._captureElement = event.target as Element;
102
+ this._pointerId = event.pointerId;
103
+ this._captureElement?.setPointerCapture?.(this._pointerId);
104
+ designerCanvas.captureActiveTool(this);
105
+
106
+ this._previewPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
107
+ this._previewPath.setAttribute("fill", "none");
108
+ this._previewPath.setAttribute("stroke", "#333");
109
+ this._previewPath.setAttribute("stroke-width", "2.5");
110
+ designerCanvas.overlayLayer.addOverlay(this.constructor.name, this._previewPath, OverlayLayer.Foreground);
111
+ this._update(designerCanvas, event, currentElement);
112
+ event.preventDefault();
113
+ event.stopPropagation();
114
+ }
115
+
116
+ private _update(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element) {
117
+ if (!this._sourceBounds || !this._previewPath)
118
+ return;
119
+
120
+ const pointer = designerCanvas.getNormalizedEventCoordinates(event);
121
+ const target = findNode(event, currentElement);
122
+ const direction = this._getDirection();
123
+ const waypoints = target && target !== this._sourceElement
124
+ ? routeBetweenBounds(this._sourceBounds, getElementBounds(designerCanvas, target), direction)
125
+ : routeBetweenPoints(getAnchor(this._sourceBounds, pointer), pointer);
126
+
127
+ this._previewPath.setAttribute("d", pathDataFromWaypoints(waypoints));
128
+ event.preventDefault();
129
+ event.stopPropagation();
130
+ }
131
+
132
+ private _finish(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element) {
133
+ if (!this._sourceElement || !this._sourceBounds)
134
+ return;
135
+
136
+ const target = findNode(event, currentElement);
137
+ if (!target || target === this._sourceElement) {
138
+ this._cleanup(designerCanvas, true);
139
+ event.preventDefault();
140
+ event.stopPropagation();
141
+ return;
142
+ }
143
+
144
+ const direction = this._getDirection(target);
145
+ const waypoints = routeBetweenBounds(this._sourceBounds, getElementBounds(designerCanvas, target), direction);
146
+ const edge = document.createElement(this._getRelationshipTag(designerCanvas)) as HTMLElement;
147
+ edge.style.position = "absolute";
148
+ edge.style.zIndex = "4";
149
+ edge.setAttribute("from", getNodeId(this._sourceElement));
150
+ edge.setAttribute("to", getNodeId(target));
151
+ if (edge.localName === "mermaid-edge")
152
+ edge.setAttribute("edge-type", "arrow");
153
+ else
154
+ edge.setAttribute("relationship-type", "satisfies");
155
+ if (direction && edge.localName === "mermaid-edge")
156
+ edge.setAttribute("diagram-direction", direction);
157
+ edge.setAttribute("waypoints", encodeWaypoints(waypoints));
158
+
159
+ const designItem = DesignItem.createDesignItemFromInstance(edge, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
160
+ designerCanvas.instanceServiceContainer.undoService.execute(
161
+ new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, designItem)
162
+ );
163
+ this._cleanup(designerCanvas, true);
164
+ event.preventDefault();
165
+ event.stopPropagation();
166
+ }
167
+
168
+ private _cleanup(designerCanvas: IDesignerCanvas, finished: boolean) {
169
+ if (this._previewPath) {
170
+ designerCanvas.overlayLayer.removeOverlay(this._previewPath);
171
+ this._previewPath = undefined;
172
+ }
173
+ if (this._captureElement && this._pointerId !== undefined)
174
+ this._captureElement.releasePointerCapture?.(this._pointerId);
175
+
176
+ this._captureElement = undefined;
177
+ this._pointerId = undefined;
178
+ this._sourceElement = undefined;
179
+ this._sourceBounds = undefined;
180
+ designerCanvas.releaseActiveTool();
181
+ if (finished)
182
+ designerCanvas.serviceContainer.globalContext.finishedWithTool(this);
183
+ }
184
+
185
+ private _getDirection(target?: HTMLElement): FlowchartDirection {
186
+ const direction = this._sourceElement?.getAttribute("diagram-direction") ?? target?.getAttribute("diagram-direction");
187
+ if (direction === "TB" || direction === "TD" || direction === "BT" || direction === "RL" || direction === "LR")
188
+ return direction;
189
+ return undefined;
190
+ }
191
+
192
+ private _getRelationshipTag(designerCanvas: IDesignerCanvas) {
193
+ return getMermaidDocumentDiagramType(designerCanvas.rootDesignItem) === "requirementDiagram"
194
+ ? "mermaid-requirement-relationship"
195
+ : "mermaid-edge";
196
+ }
197
+ }
@@ -0,0 +1,198 @@
1
+ {
2
+ "elements": [
3
+ {
4
+ "name": "node",
5
+ "tag": "mermaid-node",
6
+ "type": "polymer",
7
+ "diagramTypes": ["flowchart"],
8
+ "defaultWidth": "120px",
9
+ "defaultHeight": "54px",
10
+ "defaultAttributes": {
11
+ "node-id": "A",
12
+ "label": "Node",
13
+ "shape": "rectangle"
14
+ }
15
+ },
16
+ {
17
+ "name": "decision",
18
+ "tag": "mermaid-node",
19
+ "type": "polymer",
20
+ "diagramTypes": ["flowchart"],
21
+ "defaultWidth": "120px",
22
+ "defaultHeight": "80px",
23
+ "defaultAttributes": {
24
+ "node-id": "Decision",
25
+ "label": "Decision",
26
+ "shape": "decision"
27
+ }
28
+ },
29
+ {
30
+ "name": "subgraph",
31
+ "tag": "mermaid-subgraph",
32
+ "type": "polymer",
33
+ "diagramTypes": ["flowchart"],
34
+ "defaultWidth": "360px",
35
+ "defaultHeight": "240px",
36
+ "defaultAttributes": {
37
+ "subgraph-id": "Group",
38
+ "title": "Group"
39
+ }
40
+ },
41
+ {
42
+ "name": "document",
43
+ "tag": "mermaid-node",
44
+ "type": "polymer",
45
+ "diagramTypes": ["flowchart"],
46
+ "defaultWidth": "140px",
47
+ "defaultHeight": "64px",
48
+ "defaultAttributes": { "node-id": "Document", "label": "Document", "shape": "doc" }
49
+ },
50
+ {
51
+ "name": "database",
52
+ "tag": "mermaid-node",
53
+ "type": "polymer",
54
+ "diagramTypes": ["flowchart"],
55
+ "defaultWidth": "120px",
56
+ "defaultHeight": "64px",
57
+ "defaultAttributes": { "node-id": "Database", "label": "Database", "shape": "cylinder" }
58
+ },
59
+ {
60
+ "name": "cloud",
61
+ "tag": "mermaid-node",
62
+ "type": "polymer",
63
+ "diagramTypes": ["flowchart"],
64
+ "defaultWidth": "140px",
65
+ "defaultHeight": "64px",
66
+ "defaultAttributes": { "node-id": "Cloud", "label": "Cloud", "shape": "cloud" }
67
+ },
68
+ {
69
+ "name": "junction",
70
+ "tag": "mermaid-node",
71
+ "type": "polymer",
72
+ "diagramTypes": ["flowchart"],
73
+ "defaultWidth": "80px",
74
+ "defaultHeight": "80px",
75
+ "defaultAttributes": { "node-id": "Junction", "label": "", "shape": "f-circ" }
76
+ },
77
+ {
78
+ "name": "fork/join",
79
+ "tag": "mermaid-node",
80
+ "type": "polymer",
81
+ "diagramTypes": ["flowchart"],
82
+ "defaultWidth": "140px",
83
+ "defaultHeight": "28px",
84
+ "defaultAttributes": { "node-id": "Fork", "label": "", "shape": "fork" }
85
+ },
86
+ {
87
+ "name": "manual input",
88
+ "tag": "mermaid-node",
89
+ "type": "polymer",
90
+ "diagramTypes": ["flowchart"],
91
+ "defaultWidth": "140px",
92
+ "defaultHeight": "60px",
93
+ "defaultAttributes": { "node-id": "ManualInput", "label": "Manual Input", "shape": "sl-rect" }
94
+ },
95
+ {
96
+ "name": "data store",
97
+ "tag": "mermaid-node",
98
+ "type": "polymer",
99
+ "diagramTypes": ["flowchart"],
100
+ "defaultWidth": "140px",
101
+ "defaultHeight": "60px",
102
+ "defaultAttributes": { "node-id": "DataStore", "label": "Data Store", "shape": "datastore" }
103
+ },
104
+ {
105
+ "name": "text block",
106
+ "tag": "mermaid-node",
107
+ "type": "polymer",
108
+ "diagramTypes": ["flowchart"],
109
+ "defaultWidth": "140px",
110
+ "defaultHeight": "54px",
111
+ "defaultAttributes": { "node-id": "Text", "label": "Text", "shape": "text" }
112
+ },
113
+ {
114
+ "name": "mindmap node",
115
+ "tag": "mermaid-mindmap-node",
116
+ "type": "polymer",
117
+ "diagramTypes": ["mindmap"],
118
+ "defaultWidth": "150px",
119
+ "defaultHeight": "44px",
120
+ "defaultAttributes": {
121
+ "mindmap-id": "Node",
122
+ "label": "Node",
123
+ "shape": "default"
124
+ }
125
+ },
126
+ {
127
+ "name": "sequence participant",
128
+ "tag": "mermaid-sequence-participant",
129
+ "type": "polymer",
130
+ "diagramTypes": ["sequenceDiagram"],
131
+ "defaultWidth": "140px",
132
+ "defaultHeight": "44px",
133
+ "defaultAttributes": {
134
+ "participant-id": "Alice",
135
+ "label": "Alice",
136
+ "participant-type": "participant"
137
+ }
138
+ },
139
+ {
140
+ "name": "sequence actor",
141
+ "tag": "mermaid-sequence-participant",
142
+ "type": "polymer",
143
+ "diagramTypes": ["sequenceDiagram"],
144
+ "defaultWidth": "140px",
145
+ "defaultHeight": "44px",
146
+ "defaultAttributes": {
147
+ "participant-id": "Actor",
148
+ "label": "Actor",
149
+ "participant-type": "actor"
150
+ }
151
+ },
152
+ {
153
+ "name": "sequence message",
154
+ "tag": "mermaid-sequence-message",
155
+ "type": "polymer",
156
+ "diagramTypes": ["sequenceDiagram"],
157
+ "defaultWidth": "220px",
158
+ "defaultHeight": "36px",
159
+ "defaultAttributes": {
160
+ "from": "Alice",
161
+ "to": "Bob",
162
+ "label": "Message",
163
+ "message-type": "solid",
164
+ "connector": "->>"
165
+ }
166
+ },
167
+ {
168
+ "name": "requirement",
169
+ "tag": "mermaid-requirement-node",
170
+ "type": "polymer",
171
+ "diagramTypes": ["requirementDiagram"],
172
+ "defaultWidth": "220px",
173
+ "defaultHeight": "160px",
174
+ "defaultAttributes": {
175
+ "node-kind": "requirement",
176
+ "label": "Req",
177
+ "requirement-type": "requirement",
178
+ "requirement-id": "1",
179
+ "text": "Requirement text",
180
+ "risk": "low",
181
+ "verify-method": "test"
182
+ }
183
+ },
184
+ {
185
+ "name": "element",
186
+ "tag": "mermaid-requirement-node",
187
+ "type": "polymer",
188
+ "diagramTypes": ["requirementDiagram"],
189
+ "defaultWidth": "170px",
190
+ "defaultHeight": "84px",
191
+ "defaultAttributes": {
192
+ "node-kind": "element",
193
+ "label": "Element",
194
+ "element-type": "simulation"
195
+ }
196
+ }
197
+ ]
198
+ }