Skip to content

Commit 1841346

Browse files
committed
Fixing issues in mindmaps and class diagram notes after tests
1 parent e8799ad commit 1841346

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

cypress/platform/knsv2.html

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
</style>
5858
</head>
5959
<body>
60-
<pre id="diagram" class="mermaid">
60+
<pre id="diagram" class="mermaid2">
6161
flowchart LR
6262
A[A text that needs to be wrapped wraps to another line]
6363
B[A text that needs to be<br/>wrapped wraps to another line]
6464
C["`A text that needs to be wrapped to another line`"]</pre>
65-
<pre id="diagram" class="mermaid">
65+
<pre id="diagram" class="mermaid2">
6666
flowchart LR
6767
C["`A text
6868
that needs
@@ -71,11 +71,21 @@
7171
way`"]
7272
</pre
7373
>
74-
<pre id="diagram" class="mermaid2">
75-
flowchart-elk LR
76-
b("The dog in the hog... a very<br/>long text about it<br/>Word!")
77-
</pre>
74+
<pre id="diagram" class="mermaid">
75+
mindmap
76+
root
77+
Child3(A node with an icon and with a long text that wraps to keep the node size in check)
78+
</pre
7879
>
80+
<pre id="diagram" class="mermaid">
81+
%%{init: {"theme": "forest"} }%%
82+
mindmap
83+
id1[**Start2**<br/>end]
84+
id2[**Start2**<br />end]
85+
%% Another comment
86+
id3[**Start2**<br>end] %% Comment
87+
id4[**Start2**<br >end<br >the very end]
88+
</pre>
7989
<pre id="diagram" class="mermaid2">
8090
mindmap
8191
id1[`**Start2**
@@ -89,7 +99,7 @@
8999
and another
90100
`]
91101
</pre>
92-
<pre id="diagram" class="mermaid">
102+
<pre id="diagram" class="mermaid2">
93103
mindmap
94104
id1("`**Root**`"]
95105
id2["`A formatted text... with **bold** and *italics*`"]

packages/mermaid/src/dagre-wrapper/nodes.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,19 @@ const rect = (parent, node) => {
316316
// add the rect
317317
const rect = shapeSvg.insert('rect', ':first-child');
318318

319-
const totalWidth = bbox.width + node.padding * 2;
320-
const totalHeight = bbox.height + node.padding * 2;
319+
// const totalWidth = bbox.width + node.padding * 2;
320+
// const totalHeight = bbox.height + node.padding * 2;
321+
const totalWidth = bbox.width + node.padding;
322+
const totalHeight = bbox.height + node.padding;
321323
rect
322324
.attr('class', 'basic label-container')
323325
.attr('style', node.style)
324326
.attr('rx', node.rx)
325327
.attr('ry', node.ry)
326-
.attr('x', -bbox.width / 2 - node.padding)
327-
.attr('y', -bbox.height / 2 - node.padding)
328+
// .attr('x', -bbox.width / 2 - node.padding)
329+
// .attr('y', -bbox.height / 2 - node.padding)
330+
.attr('x', -bbox.width / 2 - halfPadding)
331+
.attr('y', -bbox.height / 2 - halfPadding)
328332
.attr('width', totalWidth)
329333
.attr('height', totalHeight);
330334

@@ -351,7 +355,7 @@ const rect = (parent, node) => {
351355
const labelRect = (parent, node) => {
352356
const { shapeSvg } = labelHelper(parent, node, 'label', true);
353357

354-
log.info('Classes = ', node.classes);
358+
log.trace('Classes = ', node.classes);
355359
// add the rect
356360
const rect = shapeSvg.insert('rect', ':first-child');
357361

packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const draw = async (text, id, version, diagObj) => {
175175
// Parse the graph definition
176176
diagObj.parser.parse(text);
177177

178-
log.debug('Renering mindmap diagram\n' + text, diagObj);
178+
log.debug('Rendering mindmap diagram\n' + text, diagObj.parser);
179179

180180
const securityLevel = getConfig().securityLevel;
181181
// Handle root and Document for when rendering in sandbox mode

packages/mermaid/src/diagrams/mindmap/parser/mindmap.jison

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
%%
2020

21-
\s*\%\%.* {yy.getLogger().trace('Found comment',yytext);}
21+
\s*\%\%.* {yy.getLogger().trace('Found comment',yytext); return 'SPACELINE';}
2222
// \%\%[^\n]*\n /* skip comments */
2323
"mindmap" return 'MINDMAP';
2424
":::" { this.begin('CLASS'); }

packages/mermaid/src/diagrams/mindmap/svgDraw.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ export const drawNode = function (elem, node, fullSection, conf) {
217217

218218
// Create the wrapped text element
219219
const textElem = nodeElem.append('g');
220-
const newEl = createText(textElem, node.descr, {
220+
const description = node.descr.replace(/(<br\/*>)/g, '\n');
221+
const newEl = createText(textElem, description, {
221222
useHtmlLabels: htmlLabels,
222223
width: node.width,
223224
classes: 'mindmap-node-label',

0 commit comments

Comments
 (0)