#448 Fix for root nodes without children

This commit is contained in:
Knut Sveidqvist
2022-10-14 15:11:29 +02:00
parent bed95c77a9
commit 59cf085af5
2 changed files with 6 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mermaid-js/mermaid-mindmap", "name": "@mermaid-js/mermaid-mindmap",
"version": "9.2.0-rc2", "version": "9.2.0-rc3",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"main": "dist/mermaid-mindmap.core.mjs", "main": "dist/mermaid-mindmap.core.mjs",
"module": "dist/mermaid-mindmap.core.mjs", "module": "dist/mermaid-mindmap.core.mjs",

View File

@@ -34,7 +34,7 @@ function drawNodes(svg, mindmap, section, conf) {
* @param cy * @param cy
*/ */
function drawEdges(edgesEl, cy) { function drawEdges(edgesEl, cy) {
cy.edges().map((edge, id) => { cy?.edges().map((edge, id) => {
const data = edge.data(); const data = edge.data();
if (edge[0]._private.bodyBounds) { if (edge[0]._private.bodyBounds) {
const bounds = edge[0]._private.rscratch; const bounds = edge[0]._private.rscratch;
@@ -100,9 +100,10 @@ function addNodes(mindmap, cy, conf, level) {
*/ */
function layoutMindmap(node, conf) { function layoutMindmap(node, conf) {
return new Promise((resolve) => { return new Promise((resolve) => {
if (node.children.length === 0) { // if (node.children.length === 0) {
return node; // resolve(node);
} // return;
// }
// Add temporary render element // Add temporary render element
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none'); const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');