diff --git a/packages/mermaid-layout-elk/src/index.ts b/packages/mermaid-layout-elk/src/index.ts index 80652924c..eb860436e 100644 --- a/packages/mermaid-layout-elk/src/index.ts +++ b/packages/mermaid-layout-elk/src/index.ts @@ -59,7 +59,7 @@ export const addVertex = async (nodeEl, graph, nodeArr, node) => { nodeDb[node.id] = child; // // Add the element to the DOM - if (node.type !== 'group') { + if (!node.isGroup) { const childNodeEl = await insertNode(nodeEl, node, node.dir); boundingBox = childNodeEl.node().getBBox(); child.domId = childNodeEl; @@ -106,7 +106,7 @@ const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, depth) => { width: node.width, height: node.height, }; - if (node.type === 'group') { + if (node.isGroup) { log.debug('Id abc88 subgraph = ', node.id, node.x, node.y, node.labelData); const subgraphEl = subgraphsEl.insert('g').attr('class', 'subgraph'); // TODO use faster way of cloning @@ -135,7 +135,7 @@ const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, depth) => { } }); nodeArray.forEach(function (node) { - if (node && node.type === 'group') { + if (node && node.isGroup) { drawNodes(relX + node.x, relY + node.y, node.children, svg, subgraphsEl, depth + 1); } }); @@ -192,7 +192,7 @@ const getNextPort = (node, edgeDirection, graphDirection) => { const addSubGraphs = function (nodeArr) { const parentLookupDb = { parentById: {}, childrenById: {} }; - const subgraphs = nodeArr.filter((node) => node.type === 'group'); + const subgraphs = nodeArr.filter((node) => node.isGroup); log.info('Subgraphs - ', subgraphs); subgraphs.forEach(function (subgraph) { const children = nodeArr.filter((node) => node.parentId === subgraph.id); diff --git a/packages/mermaid/src/diagrams/state/dataFetcher.js b/packages/mermaid/src/diagrams/state/dataFetcher.js index f0d1f03e7..d553a4834 100644 --- a/packages/mermaid/src/diagrams/state/dataFetcher.js +++ b/packages/mermaid/src/diagrams/state/dataFetcher.js @@ -279,6 +279,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt if (!newNode.type && parsedItem.doc) { log.info('Setting cluster for ', itemId, getDir(parsedItem)); newNode.type = 'group'; + newNode.isGroup = true; newNode.dir = getDir(parsedItem); newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP; newNode.cssClasses = @@ -300,6 +301,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt dir: newNode.dir, domId: stateDomId(itemId, graphItemCount), type: newNode.type, + isGroup: newNode.type === 'group', padding: 15, rx: 10, ry: 10, @@ -325,6 +327,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt id: itemId + NOTE_ID + '-' + graphItemCount, domId: stateDomId(itemId, graphItemCount, NOTE), type: newNode.type, + isGroup: newNode.type === 'group', padding: 15, //getConfig().flowchart.padding useRough, }; @@ -337,6 +340,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt id: itemId + PARENT_ID, domId: stateDomId(itemId, graphItemCount, PARENT), type: 'group', + isGroup: true, padding: 0, //getConfig().flowchart.padding useRough, }; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js index db0c1e0f6..3a20a2e0e 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js @@ -165,7 +165,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit graph.nodes().forEach(function (v) { const n = graph.node(v); log.info(v, n.type, n.diff); - if (n.type === 'group') { + if (n.isGroup) { diff = n.diff; } });