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

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 (47) hide show
  1. package/{src/index.ts → dist/index.d.ts} +0 -3
  2. package/dist/index.js +17 -0
  3. package/dist/monaco/MermaidLanguage.d.ts +1 -0
  4. package/{src/monaco/MermaidLanguage.ts → dist/monaco/MermaidLanguage.js} +1 -4
  5. package/dist/services/MermaidConnectionRouting.d.ts +2 -0
  6. package/{src/services/MermaidConnectionRouting.ts → dist/services/MermaidConnectionRouting.js} +22 -45
  7. package/dist/services/MermaidDocumentPropertiesService.d.ts +24 -0
  8. package/{src/services/MermaidDocumentPropertiesService.ts → dist/services/MermaidDocumentPropertiesService.js} +25 -54
  9. package/dist/services/MermaidElementsService.d.ts +19 -0
  10. package/{src/services/MermaidElementsService.ts → dist/services/MermaidElementsService.js} +18 -35
  11. package/dist/services/MermaidLayoutCopyPasteService.d.ts +5 -0
  12. package/{src/services/MermaidLayoutCopyPasteService.ts → dist/services/MermaidLayoutCopyPasteService.js} +4 -6
  13. package/dist/services/MermaidLayoutPlacementService.d.ts +8 -0
  14. package/{src/services/MermaidLayoutPlacementService.ts → dist/services/MermaidLayoutPlacementService.js} +6 -11
  15. package/dist/services/MermaidParserService.d.ts +7 -0
  16. package/{src/services/MermaidParserService.ts → dist/services/MermaidParserService.js} +410 -705
  17. package/dist/services/MermaidPropertyGroupsService.d.ts +8 -0
  18. package/{src/services/MermaidPropertyGroupsService.ts → dist/services/MermaidPropertyGroupsService.js} +2 -7
  19. package/dist/services/mermaidGeometry.d.ts +31 -0
  20. package/{src/services/mermaidGeometry.ts → dist/services/mermaidGeometry.js} +13 -43
  21. package/dist/setupMermaidServiceContainer.d.ts +2 -0
  22. package/{src/setupMermaidServiceContainer.ts → dist/setupMermaidServiceContainer.js} +8 -28
  23. package/dist/toolbar/ConnectMermaidNodesTool.d.ts +20 -0
  24. package/{src/toolbar/ConnectMermaidNodesTool.ts → dist/toolbar/ConnectMermaidNodesTool.js} +26 -58
  25. package/dist/widgets/mermaid-edge.d.ts +45 -0
  26. package/{src/widgets/mermaid-edge.ts → dist/widgets/mermaid-edge.js} +39 -60
  27. package/dist/widgets/mermaid-flowchart-directive.d.ts +16 -0
  28. package/{src/widgets/mermaid-flowchart-directive.ts → dist/widgets/mermaid-flowchart-directive.js} +11 -23
  29. package/dist/widgets/mermaid-mindmap-node.d.ts +37 -0
  30. package/{src/widgets/mermaid-mindmap-node.ts → dist/widgets/mermaid-mindmap-node.js} +36 -55
  31. package/dist/widgets/mermaid-node.d.ts +75 -0
  32. package/{src/widgets/mermaid-node.ts → dist/widgets/mermaid-node.js} +78 -105
  33. package/dist/widgets/mermaid-requirement-node.d.ts +37 -0
  34. package/{src/widgets/mermaid-requirement-node.ts → dist/widgets/mermaid-requirement-node.js} +30 -49
  35. package/dist/widgets/mermaid-requirement-relationship.d.ts +28 -0
  36. package/{src/widgets/mermaid-requirement-relationship.ts → dist/widgets/mermaid-requirement-relationship.js} +21 -38
  37. package/dist/widgets/mermaid-sequence-message.d.ts +34 -0
  38. package/{src/widgets/mermaid-sequence-message.ts → dist/widgets/mermaid-sequence-message.js} +30 -44
  39. package/dist/widgets/mermaid-sequence-participant.d.ts +24 -0
  40. package/{src/widgets/mermaid-sequence-participant.ts → dist/widgets/mermaid-sequence-participant.js} +17 -28
  41. package/dist/widgets/mermaid-subgraph.d.ts +20 -0
  42. package/{src/widgets/mermaid-subgraph.ts → dist/widgets/mermaid-subgraph.js} +13 -25
  43. package/dist/widgets/views/mermaid-demo-view.d.ts +11 -0
  44. package/{src/widgets/views/mermaid-demo-view.ts → dist/widgets/views/mermaid-demo-view.js} +8 -18
  45. package/package.json +6 -1
  46. package/tsconfig.json +0 -20
  47. /package/{src → dist}/widgets/elements.json +0 -0
@@ -1,20 +1,19 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { boundsFromWaypoints, decodeWaypoints, midpointFromWaypoints, pathDataFromWaypoints } from "../services/mermaidGeometry.js";
3
3
  import { escapeLabel, sanitizeId } from "./mermaid-node.js";
4
-
5
- enum MermaidEdgeType {
6
- arrow = "arrow",
7
- open = "open",
8
- dotted = "dotted",
9
- thick = "thick",
10
- invisible = "invisible",
11
- circle = "circle",
12
- cross = "cross",
13
- multi = "multi",
14
- }
15
-
4
+ var MermaidEdgeType;
5
+ (function (MermaidEdgeType) {
6
+ MermaidEdgeType["arrow"] = "arrow";
7
+ MermaidEdgeType["open"] = "open";
8
+ MermaidEdgeType["dotted"] = "dotted";
9
+ MermaidEdgeType["thick"] = "thick";
10
+ MermaidEdgeType["invisible"] = "invisible";
11
+ MermaidEdgeType["circle"] = "circle";
12
+ MermaidEdgeType["cross"] = "cross";
13
+ MermaidEdgeType["multi"] = "multi";
14
+ })(MermaidEdgeType || (MermaidEdgeType = {}));
16
15
  export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
17
- static override readonly style = css`
16
+ static style = css `
18
17
  * {
19
18
  box-sizing: border-box;
20
19
  }
@@ -53,8 +52,7 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
53
52
  pointer-events: none;
54
53
  }
55
54
  `;
56
-
57
- static override readonly template = html`
55
+ static template = html `
58
56
  <svg id="svg" viewBox="0 0 10 10" preserveAspectRatio="none">
59
57
  <defs>
60
58
  <marker id="marker" viewBox="0 0 12 12" markerWidth="10" markerHeight="10" refX="10.5" refY="6" orient="auto" markerUnits="userSpaceOnUse">
@@ -73,24 +71,20 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
73
71
  <path id="path"></path>
74
72
  <text id="label"></text>
75
73
  </svg>`;
76
-
77
- static readonly is = "mermaid-edge";
78
-
79
- public from: string = "A";
80
- public to: string = "B";
81
- public label: string = "";
82
- public edgeType: MermaidEdgeType = MermaidEdgeType.arrow;
83
- public connector: string = "-->";
84
- public edgeId: string = "";
85
- public animation: string = "";
86
- public waypoints: string = "";
87
- private _previewWaypoints: string;
88
-
89
- private _label: SVGTextElement;
90
- private _path: SVGPathElement;
91
- private _svg: SVGSVGElement;
92
-
93
- static readonly properties = {
74
+ static is = "mermaid-edge";
75
+ from = "A";
76
+ to = "B";
77
+ label = "";
78
+ edgeType = MermaidEdgeType.arrow;
79
+ connector = "-->";
80
+ edgeId = "";
81
+ animation = "";
82
+ waypoints = "";
83
+ _previewWaypoints;
84
+ _label;
85
+ _path;
86
+ _svg;
87
+ static properties = {
94
88
  from: String,
95
89
  to: String,
96
90
  label: String,
@@ -99,38 +93,32 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
99
93
  edgeId: String,
100
94
  animation: String,
101
95
  waypoints: String,
102
- }
103
-
96
+ };
104
97
  constructor() {
105
98
  super();
106
99
  this._restoreCachedInititalValues();
107
- this._label = this._getDomElement<SVGTextElement>("label");
108
- this._path = this._getDomElement<SVGPathElement>("path");
109
- this._svg = this._getDomElement<SVGSVGElement>("svg");
100
+ this._label = this._getDomElement("label");
101
+ this._path = this._getDomElement("path");
102
+ this._svg = this._getDomElement("svg");
110
103
  }
111
-
112
104
  async ready() {
113
105
  this._parseAttributesToProperties();
114
106
  this._render();
115
107
  }
116
-
117
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
108
+ attributeChangedCallback(name, oldValue, newValue) {
118
109
  if (oldValue !== newValue) {
119
110
  this._parseAttributesToProperties();
120
111
  this._render();
121
112
  }
122
113
  }
123
-
124
- public setPreviewWaypoints(waypoints: string | null) {
114
+ setPreviewWaypoints(waypoints) {
125
115
  this._previewWaypoints = waypoints;
126
116
  this._render();
127
117
  }
128
-
129
- private _render() {
118
+ _render() {
130
119
  let waypoints = decodeWaypoints(this._previewWaypoints ?? this.getAttribute("waypoints") ?? this.waypoints);
131
120
  if (waypoints.length < 2)
132
121
  waypoints = [{ x: 0, y: 12 }, { x: 180, y: 12 }];
133
-
134
122
  const padding = 16;
135
123
  const minCrossAxisSize = 24;
136
124
  const bounds = boundsFromWaypoints(waypoints);
@@ -138,18 +126,15 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
138
126
  const height = Math.max(minCrossAxisSize, Math.round(bounds.height + padding * 2));
139
127
  const offsetX = (width - bounds.width) / 2;
140
128
  const offsetY = (height - bounds.height) / 2;
141
-
142
129
  this.style.left = `${Math.round(bounds.x - offsetX)}px`;
143
130
  this.style.top = `${Math.round(bounds.y - offsetY)}px`;
144
131
  this.style.width = `${width}px`;
145
132
  this.style.height = `${height}px`;
146
-
147
133
  const shifted = waypoints.map(point => ({ x: point.x - bounds.x + offsetX, y: point.y - bounds.y + offsetY }));
148
134
  const middle = midpointFromWaypoints(shifted);
149
-
150
135
  this._svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
151
136
  this._path.setAttribute("d", pathDataFromWaypoints(shifted));
152
- const edgeType = this.getAttribute("edge-type") as MermaidEdgeType ?? this.edgeType;
137
+ const edgeType = this.getAttribute("edge-type") ?? this.edgeType;
153
138
  const connector = this.getAttribute("connector") ?? this.connector;
154
139
  const label = this.getAttribute("label") ?? this.label ?? "";
155
140
  this._path.setAttribute("marker-start", connector.startsWith("<") || edgeType === MermaidEdgeType.multi ? "url(#marker-start)" : "");
@@ -163,25 +148,21 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
163
148
  this._label.setAttribute("y", (middle.y - 8).toString());
164
149
  this._label.setAttribute("text-anchor", "middle");
165
150
  }
166
-
167
- public createMermaid() {
151
+ createMermaid() {
168
152
  const from = sanitizeId(this.getAttribute("from") ?? this.from);
169
153
  const to = sanitizeId(this.getAttribute("to") ?? this.to);
170
154
  const label = this.getAttribute("label") ?? this.label;
171
155
  const explicitConnector = this.getAttribute("connector") ?? this.connector;
172
- const connector = explicitConnector ? { plain: explicitConnector, label: explicitConnector } : getConnector(this.getAttribute("edge-type") as MermaidEdgeType ?? this.edgeType);
156
+ const connector = explicitConnector ? { plain: explicitConnector, label: explicitConnector } : getConnector(this.getAttribute("edge-type") ?? this.edgeType);
173
157
  const rawEdgeId = this.getAttribute("edge-id") ?? this.edgeId;
174
158
  const edgeId = rawEdgeId ? sanitizeId(rawEdgeId) : "";
175
159
  const prefix = edgeId ? edgeId + "@" : "";
176
-
177
160
  if (label)
178
161
  return `${from} ${prefix}${connector.label}|${escapeLabel(label)}| ${to}`;
179
-
180
162
  return `${from} ${prefix}${connector.plain} ${to}`;
181
163
  }
182
164
  }
183
-
184
- function getMarkerEnd(edgeType: MermaidEdgeType, connector: string) {
165
+ function getMarkerEnd(edgeType, connector) {
185
166
  if (edgeType === MermaidEdgeType.open || edgeType === MermaidEdgeType.invisible || connector.endsWith("---") || connector.endsWith("===") || connector.endsWith("-.-"))
186
167
  return "";
187
168
  if (edgeType === MermaidEdgeType.circle || connector.includes("o"))
@@ -190,8 +171,7 @@ function getMarkerEnd(edgeType: MermaidEdgeType, connector: string) {
190
171
  return "url(#cross-marker)";
191
172
  return "url(#marker)";
192
173
  }
193
-
194
- function getConnector(edgeType: MermaidEdgeType) {
174
+ function getConnector(edgeType) {
195
175
  switch (edgeType) {
196
176
  case MermaidEdgeType.open:
197
177
  return { plain: "---", label: "---" };
@@ -211,5 +191,4 @@ function getConnector(edgeType: MermaidEdgeType) {
211
191
  return { plain: "-->", label: "-->" };
212
192
  }
213
193
  }
214
-
215
194
  customElements.define(MermaidEdge.is, MermaidEdge);
@@ -0,0 +1,16 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ export declare class MermaidFlowchartDirective extends BaseCustomWebComponentConstructorAppend {
3
+ static readonly style: CSSStyleSheet;
4
+ static readonly template: HTMLTemplateElement;
5
+ static readonly is = "mermaid-flowchart-directive";
6
+ line: string;
7
+ private _text;
8
+ static readonly properties: {
9
+ line: StringConstructor;
10
+ };
11
+ constructor();
12
+ ready(): Promise<void>;
13
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
14
+ private _render;
15
+ createMermaid(): string;
16
+ }
@@ -1,7 +1,6 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
-
3
2
  export class MermaidFlowchartDirective extends BaseCustomWebComponentConstructorAppend {
4
- static override readonly style = css`
3
+ static style = css `
5
4
  :host {
6
5
  background: #fffbe6;
7
6
  border: 1px solid #d6b656;
@@ -15,44 +14,33 @@ export class MermaidFlowchartDirective extends BaseCustomWebComponentConstructor
15
14
  white-space: nowrap;
16
15
  }
17
16
  `;
18
-
19
- static override readonly template = html`<span id="text"></span>`;
20
-
21
- static readonly is = "mermaid-flowchart-directive";
22
-
23
- public line: string = "";
24
-
25
- private _text: HTMLSpanElement;
26
-
27
- static readonly properties = {
17
+ static template = html `<span id="text"></span>`;
18
+ static is = "mermaid-flowchart-directive";
19
+ line = "";
20
+ _text;
21
+ static properties = {
28
22
  line: String,
29
- }
30
-
23
+ };
31
24
  constructor() {
32
25
  super();
33
26
  this._restoreCachedInititalValues();
34
- this._text = this._getDomElement<HTMLSpanElement>("text");
27
+ this._text = this._getDomElement("text");
35
28
  }
36
-
37
29
  async ready() {
38
30
  this._parseAttributesToProperties();
39
31
  this._render();
40
32
  }
41
-
42
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
33
+ attributeChangedCallback(name, oldValue, newValue) {
43
34
  if (oldValue !== newValue) {
44
35
  this._parseAttributesToProperties();
45
36
  this._render();
46
37
  }
47
38
  }
48
-
49
- private _render() {
39
+ _render() {
50
40
  this._text.textContent = this.getAttribute("line") ?? this.line;
51
41
  }
52
-
53
- public createMermaid() {
42
+ createMermaid() {
54
43
  return this.getAttribute("line") ?? this.line;
55
44
  }
56
45
  }
57
-
58
46
  customElements.define(MermaidFlowchartDirective.is, MermaidFlowchartDirective);
@@ -0,0 +1,37 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ declare enum MermaidMindmapNodeShape {
3
+ default = "default",
4
+ square = "square",
5
+ round = "round",
6
+ circle = "circle",
7
+ bang = "bang",
8
+ cloud = "cloud",
9
+ hexagon = "hexagon"
10
+ }
11
+ export declare class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend {
12
+ static readonly style: CSSStyleSheet;
13
+ static readonly template: HTMLTemplateElement;
14
+ static readonly is = "mermaid-mindmap-node";
15
+ mindmapId: string;
16
+ label: string;
17
+ shape: MermaidMindmapNodeShape;
18
+ private _node;
19
+ private _connections;
20
+ private _slot;
21
+ private _childObserver;
22
+ private _resizeObserver;
23
+ static readonly properties: {
24
+ mindmapId: StringConstructor;
25
+ label: StringConstructor;
26
+ shape: typeof MermaidMindmapNodeShape;
27
+ };
28
+ constructor();
29
+ ready(): Promise<void>;
30
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
31
+ private _render;
32
+ private _observeChildren;
33
+ private _renderConnections;
34
+ private _getMindmapChildren;
35
+ createMermaid(): string;
36
+ }
37
+ export {};
@@ -1,18 +1,17 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { formatMermaidLabel, renderMarkdownLabel, sanitizeId } from "./mermaid-node.js";
3
-
4
- enum MermaidMindmapNodeShape {
5
- default = "default",
6
- square = "square",
7
- round = "round",
8
- circle = "circle",
9
- bang = "bang",
10
- cloud = "cloud",
11
- hexagon = "hexagon",
12
- }
13
-
3
+ var MermaidMindmapNodeShape;
4
+ (function (MermaidMindmapNodeShape) {
5
+ MermaidMindmapNodeShape["default"] = "default";
6
+ MermaidMindmapNodeShape["square"] = "square";
7
+ MermaidMindmapNodeShape["round"] = "round";
8
+ MermaidMindmapNodeShape["circle"] = "circle";
9
+ MermaidMindmapNodeShape["bang"] = "bang";
10
+ MermaidMindmapNodeShape["cloud"] = "cloud";
11
+ MermaidMindmapNodeShape["hexagon"] = "hexagon";
12
+ })(MermaidMindmapNodeShape || (MermaidMindmapNodeShape = {}));
14
13
  export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend {
15
- static override readonly style = css`
14
+ static style = css `
16
15
  * {
17
16
  box-sizing: border-box;
18
17
  }
@@ -81,35 +80,28 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
81
80
  padding: 8px 22px;
82
81
  }
83
82
  `;
84
-
85
- static override readonly template = html`<svg id="connections"></svg><div id="node"></div><slot id="children"></slot>`;
86
-
87
- static readonly is = "mermaid-mindmap-node";
88
-
89
- public mindmapId: string = "Root";
90
- public label: string = "Node";
91
- public shape: MermaidMindmapNodeShape = MermaidMindmapNodeShape.default;
92
-
93
- private _node: HTMLDivElement;
94
- private _connections: SVGSVGElement;
95
- private _slot: HTMLSlotElement;
96
- private _childObserver = new MutationObserver(() => this._renderConnections());
97
- private _resizeObserver = new ResizeObserver(() => this._renderConnections());
98
-
99
- static readonly properties = {
83
+ static template = html `<svg id="connections"></svg><div id="node"></div><slot id="children"></slot>`;
84
+ static is = "mermaid-mindmap-node";
85
+ mindmapId = "Root";
86
+ label = "Node";
87
+ shape = MermaidMindmapNodeShape.default;
88
+ _node;
89
+ _connections;
90
+ _slot;
91
+ _childObserver = new MutationObserver(() => this._renderConnections());
92
+ _resizeObserver = new ResizeObserver(() => this._renderConnections());
93
+ static properties = {
100
94
  mindmapId: String,
101
95
  label: String,
102
96
  shape: MermaidMindmapNodeShape,
103
- }
104
-
97
+ };
105
98
  constructor() {
106
99
  super();
107
100
  this._restoreCachedInititalValues();
108
- this._node = this._getDomElement<HTMLDivElement>("node");
109
- this._connections = this._getDomElement<SVGSVGElement>("connections");
110
- this._slot = this._getDomElement<HTMLSlotElement>("children");
101
+ this._node = this._getDomElement("node");
102
+ this._connections = this._getDomElement("connections");
103
+ this._slot = this._getDomElement("children");
111
104
  }
112
-
113
105
  async ready() {
114
106
  this._parseAttributesToProperties();
115
107
  this._render();
@@ -118,23 +110,20 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
118
110
  this._observeChildren();
119
111
  requestAnimationFrame(() => this._renderConnections());
120
112
  }
121
-
122
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
113
+ attributeChangedCallback(name, oldValue, newValue) {
123
114
  if (oldValue !== newValue) {
124
115
  this._parseAttributesToProperties();
125
116
  this._render();
126
117
  }
127
118
  }
128
-
129
- private _render() {
119
+ _render() {
130
120
  const label = this.getAttribute("label") ?? this.label ?? this.getAttribute("mindmap-id") ?? this.mindmapId;
131
- const shape = this.getAttribute("shape") as MermaidMindmapNodeShape ?? this.shape;
121
+ const shape = this.getAttribute("shape") ?? this.shape;
132
122
  renderMarkdownLabel(this._node, label);
133
123
  this._node.dataset.shape = shape;
134
124
  this._renderConnections();
135
125
  }
136
-
137
- private _observeChildren() {
126
+ _observeChildren() {
138
127
  this._childObserver.disconnect();
139
128
  this._resizeObserver.disconnect();
140
129
  this._resizeObserver.observe(this);
@@ -144,18 +133,15 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
144
133
  }
145
134
  this._renderConnections();
146
135
  }
147
-
148
- private _renderConnections() {
136
+ _renderConnections() {
149
137
  this._connections.replaceChildren();
150
138
  const children = this._getMindmapChildren();
151
139
  if (!children.length)
152
140
  return;
153
-
154
141
  const hostWidth = this.offsetWidth;
155
142
  const hostHeight = this.offsetHeight;
156
143
  const source = { x: hostWidth / 2, y: hostHeight / 2 };
157
144
  const strokeWidth = getConnectionStrokeWidth(this);
158
-
159
145
  for (const child of children) {
160
146
  const childLeft = Number.parseFloat(child.style.left || "0");
161
147
  const childTop = Number.parseFloat(child.style.top || "0");
@@ -175,16 +161,13 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
175
161
  this._connections.appendChild(path);
176
162
  }
177
163
  }
178
-
179
- private _getMindmapChildren() {
180
- return this._slot.assignedElements().filter((element): element is MermaidMindmapNode => element.localName === MermaidMindmapNode.is);
164
+ _getMindmapChildren() {
165
+ return this._slot.assignedElements().filter((element) => element.localName === MermaidMindmapNode.is);
181
166
  }
182
-
183
- public createMermaid() {
167
+ createMermaid() {
184
168
  const id = sanitizeId(this.getAttribute("mindmap-id") ?? this.mindmapId);
185
169
  const label = formatMermaidLabel((this.getAttribute("label") ?? this.label) || id);
186
- const shape = this.getAttribute("shape") as MermaidMindmapNodeShape ?? this.shape;
187
-
170
+ const shape = this.getAttribute("shape") ?? this.shape;
188
171
  switch (shape) {
189
172
  case MermaidMindmapNodeShape.square:
190
173
  return `${id}[${label}]`;
@@ -203,10 +186,8 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
203
186
  }
204
187
  }
205
188
  }
206
-
207
189
  customElements.define(MermaidMindmapNode.is, MermaidMindmapNode);
208
-
209
- function getConnectionStrokeWidth(element: Element) {
190
+ function getConnectionStrokeWidth(element) {
210
191
  let depth = 0;
211
192
  let current = element.parentElement;
212
193
  while (current) {
@@ -0,0 +1,75 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ declare enum MermaidNodeShape {
3
+ rectangle = "rectangle",
4
+ round = "round",
5
+ stadium = "stadium",
6
+ circle = "circle",
7
+ decision = "decision",
8
+ subroutine = "subroutine",
9
+ cylinder = "cylinder",
10
+ asymmetric = "asymmetric",
11
+ hexagon = "hexagon",
12
+ parallelogram = "parallelogram",
13
+ parallelogramAlt = "parallelogramAlt",
14
+ trapezoid = "trapezoid",
15
+ trapezoidAlt = "trapezoidAlt",
16
+ doubleCircle = "doubleCircle",
17
+ bang = "bang",
18
+ cloud = "cloud",
19
+ hourglass = "hourglass",
20
+ bolt = "bolt",
21
+ brace = "brace",
22
+ braceRight = "brace-r",
23
+ braces = "braces",
24
+ dataStore = "datastore",
25
+ delay = "delay",
26
+ horizontalCylinder = "h-cyl",
27
+ linedCylinder = "lin-cyl",
28
+ curvedTrapezoid = "curv-trap",
29
+ dividedRectangle = "div-rect",
30
+ document = "doc",
31
+ triangle = "tri",
32
+ fork = "fork",
33
+ windowPane = "win-pane",
34
+ filledCircle = "f-circ",
35
+ linedDocument = "lin-doc",
36
+ linedRectangle = "lin-rect",
37
+ notchedPentagon = "notch-pent",
38
+ flippedTriangle = "flip-tri",
39
+ slopedRectangle = "sl-rect",
40
+ stackedDocument = "docs",
41
+ stackedRectangle = "st-rect",
42
+ flag = "flag",
43
+ bowTieRectangle = "bow-rect",
44
+ framedCircle = "fr-circ",
45
+ crossedCircle = "cross-circ",
46
+ taggedDocument = "tag-doc",
47
+ taggedRectangle = "tag-rect",
48
+ text = "text",
49
+ card = "notch-rect"
50
+ }
51
+ export declare class MermaidNode extends BaseCustomWebComponentConstructorAppend {
52
+ static readonly style: CSSStyleSheet;
53
+ static readonly template: HTMLTemplateElement;
54
+ static readonly is = "mermaid-node";
55
+ nodeId: string;
56
+ label: string;
57
+ shape: MermaidNodeShape;
58
+ private _node;
59
+ static readonly properties: {
60
+ nodeId: StringConstructor;
61
+ label: StringConstructor;
62
+ shape: typeof MermaidNodeShape;
63
+ };
64
+ constructor();
65
+ ready(): Promise<void>;
66
+ private _render;
67
+ createMermaid(): string;
68
+ }
69
+ export declare function sanitizeId(id: string): string;
70
+ export declare function escapeLabel(label: string): string;
71
+ export declare function formatMermaidLabel(label: string): string;
72
+ export declare function stripMarkdownLabel(label: string): string;
73
+ export declare function renderMarkdownLabel(container: HTMLElement | SVGTextElement, label: string): void;
74
+ export declare function normalizeLabelLineBreaks(label: string): string;
75
+ export {};