diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index 9c95c54c3..936d8423f 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -57,12 +57,12 @@
-+flowchart LR A[A text that needs to be wrapped wraps to another line] B[A text that needs to be-
wrapped wraps to another line] C["`A text that needs to be wrapped to another line`"]+flowchart LR C["`A text that needs @@ -71,11 +71,21 @@ flowchart LR way`"]--flowchart-elk LR -b("The dog in the hog... a very+
long text about it
Word!") -+mindmap +root + Child3(A node with an icon and with a long text that wraps to keep the node size in check) +++ %%{init: {"theme": "forest"} }%% +mindmap + id1[**Start2**
end] + id2[**Start2**
end] + %% Another comment + id3[**Start2**
end] %% Comment + id4[**Start2**
end
the very end] +mindmap id1[`**Start2** @@ -89,7 +99,7 @@ mindmap and another `]-+mindmap id1("`**Root**`"] id2["`A formatted text... with **bold** and *italics*`"] diff --git a/packages/mermaid/src/dagre-wrapper/nodes.js b/packages/mermaid/src/dagre-wrapper/nodes.js index 3e71f500a..d5af81c1b 100644 --- a/packages/mermaid/src/dagre-wrapper/nodes.js +++ b/packages/mermaid/src/dagre-wrapper/nodes.js @@ -316,15 +316,19 @@ const rect = (parent, node) => { // add the rect const rect = shapeSvg.insert('rect', ':first-child'); - const totalWidth = bbox.width + node.padding * 2; - const totalHeight = bbox.height + node.padding * 2; + // const totalWidth = bbox.width + node.padding * 2; + // const totalHeight = bbox.height + node.padding * 2; + const totalWidth = bbox.width + node.padding; + const totalHeight = bbox.height + node.padding; rect .attr('class', 'basic label-container') .attr('style', node.style) .attr('rx', node.rx) .attr('ry', node.ry) - .attr('x', -bbox.width / 2 - node.padding) - .attr('y', -bbox.height / 2 - node.padding) + // .attr('x', -bbox.width / 2 - node.padding) + // .attr('y', -bbox.height / 2 - node.padding) + .attr('x', -bbox.width / 2 - halfPadding) + .attr('y', -bbox.height / 2 - halfPadding) .attr('width', totalWidth) .attr('height', totalHeight); @@ -351,7 +355,7 @@ const rect = (parent, node) => { const labelRect = (parent, node) => { const { shapeSvg } = labelHelper(parent, node, 'label', true); - log.info('Classes = ', node.classes); + log.trace('Classes = ', node.classes); // add the rect const rect = shapeSvg.insert('rect', ':first-child'); diff --git a/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js b/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js index a2a4def59..86260e155 100644 --- a/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js +++ b/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js @@ -175,7 +175,7 @@ export const draw = async (text, id, version, diagObj) => { // Parse the graph definition diagObj.parser.parse(text); - log.debug('Renering mindmap diagram\n' + text, diagObj); + log.debug('Rendering mindmap diagram\n' + text, diagObj.parser); const securityLevel = getConfig().securityLevel; // Handle root and Document for when rendering in sandbox mode diff --git a/packages/mermaid/src/diagrams/mindmap/parser/mindmap.jison b/packages/mermaid/src/diagrams/mindmap/parser/mindmap.jison index 84a6191cf..9dd046a3d 100644 --- a/packages/mermaid/src/diagrams/mindmap/parser/mindmap.jison +++ b/packages/mermaid/src/diagrams/mindmap/parser/mindmap.jison @@ -18,7 +18,7 @@ %% -\s*\%\%.* {yy.getLogger().trace('Found comment',yytext);} +\s*\%\%.* {yy.getLogger().trace('Found comment',yytext); return 'SPACELINE';} // \%\%[^\n]*\n /* skip comments */ "mindmap" return 'MINDMAP'; ":::" { this.begin('CLASS'); } diff --git a/packages/mermaid/src/diagrams/mindmap/svgDraw.js b/packages/mermaid/src/diagrams/mindmap/svgDraw.js index 8b58c11a3..ab7dcc1e3 100644 --- a/packages/mermaid/src/diagrams/mindmap/svgDraw.js +++ b/packages/mermaid/src/diagrams/mindmap/svgDraw.js @@ -217,7 +217,8 @@ export const drawNode = function (elem, node, fullSection, conf) { // Create the wrapped text element const textElem = nodeElem.append('g'); - const newEl = createText(textElem, node.descr, { + const description = node.descr.replace(/(
)/g, '\n'); + const newEl = createText(textElem, description, { useHtmlLabels: htmlLabels, width: node.width, classes: 'mindmap-node-label',