mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 15:30:03 +02:00
#5237 Removed use of node.type from renderer
This commit is contained in:
@@ -59,7 +59,7 @@ export const addVertex = async (nodeEl, graph, nodeArr, node) => {
|
|||||||
nodeDb[node.id] = child;
|
nodeDb[node.id] = child;
|
||||||
|
|
||||||
// // Add the element to the DOM
|
// // Add the element to the DOM
|
||||||
if (node.type !== 'group') {
|
if (!node.isGroup) {
|
||||||
const childNodeEl = await insertNode(nodeEl, node, node.dir);
|
const childNodeEl = await insertNode(nodeEl, node, node.dir);
|
||||||
boundingBox = childNodeEl.node().getBBox();
|
boundingBox = childNodeEl.node().getBBox();
|
||||||
child.domId = childNodeEl;
|
child.domId = childNodeEl;
|
||||||
@@ -106,7 +106,7 @@ const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, depth) => {
|
|||||||
width: node.width,
|
width: node.width,
|
||||||
height: node.height,
|
height: node.height,
|
||||||
};
|
};
|
||||||
if (node.type === 'group') {
|
if (node.isGroup) {
|
||||||
log.debug('Id abc88 subgraph = ', node.id, node.x, node.y, node.labelData);
|
log.debug('Id abc88 subgraph = ', node.id, node.x, node.y, node.labelData);
|
||||||
const subgraphEl = subgraphsEl.insert('g').attr('class', 'subgraph');
|
const subgraphEl = subgraphsEl.insert('g').attr('class', 'subgraph');
|
||||||
// TODO use faster way of cloning
|
// TODO use faster way of cloning
|
||||||
@@ -135,7 +135,7 @@ const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, depth) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
nodeArray.forEach(function (node) {
|
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);
|
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 addSubGraphs = function (nodeArr) {
|
||||||
const parentLookupDb = { parentById: {}, childrenById: {} };
|
const parentLookupDb = { parentById: {}, childrenById: {} };
|
||||||
const subgraphs = nodeArr.filter((node) => node.type === 'group');
|
const subgraphs = nodeArr.filter((node) => node.isGroup);
|
||||||
log.info('Subgraphs - ', subgraphs);
|
log.info('Subgraphs - ', subgraphs);
|
||||||
subgraphs.forEach(function (subgraph) {
|
subgraphs.forEach(function (subgraph) {
|
||||||
const children = nodeArr.filter((node) => node.parentId === subgraph.id);
|
const children = nodeArr.filter((node) => node.parentId === subgraph.id);
|
||||||
|
@@ -279,6 +279,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
|
|||||||
if (!newNode.type && parsedItem.doc) {
|
if (!newNode.type && parsedItem.doc) {
|
||||||
log.info('Setting cluster for ', itemId, getDir(parsedItem));
|
log.info('Setting cluster for ', itemId, getDir(parsedItem));
|
||||||
newNode.type = 'group';
|
newNode.type = 'group';
|
||||||
|
newNode.isGroup = true;
|
||||||
newNode.dir = getDir(parsedItem);
|
newNode.dir = getDir(parsedItem);
|
||||||
newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
|
newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
|
||||||
newNode.cssClasses =
|
newNode.cssClasses =
|
||||||
@@ -300,6 +301,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
|
|||||||
dir: newNode.dir,
|
dir: newNode.dir,
|
||||||
domId: stateDomId(itemId, graphItemCount),
|
domId: stateDomId(itemId, graphItemCount),
|
||||||
type: newNode.type,
|
type: newNode.type,
|
||||||
|
isGroup: newNode.type === 'group',
|
||||||
padding: 15,
|
padding: 15,
|
||||||
rx: 10,
|
rx: 10,
|
||||||
ry: 10,
|
ry: 10,
|
||||||
@@ -325,6 +327,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
|
|||||||
id: itemId + NOTE_ID + '-' + graphItemCount,
|
id: itemId + NOTE_ID + '-' + graphItemCount,
|
||||||
domId: stateDomId(itemId, graphItemCount, NOTE),
|
domId: stateDomId(itemId, graphItemCount, NOTE),
|
||||||
type: newNode.type,
|
type: newNode.type,
|
||||||
|
isGroup: newNode.type === 'group',
|
||||||
padding: 15, //getConfig().flowchart.padding
|
padding: 15, //getConfig().flowchart.padding
|
||||||
useRough,
|
useRough,
|
||||||
};
|
};
|
||||||
@@ -337,6 +340,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
|
|||||||
id: itemId + PARENT_ID,
|
id: itemId + PARENT_ID,
|
||||||
domId: stateDomId(itemId, graphItemCount, PARENT),
|
domId: stateDomId(itemId, graphItemCount, PARENT),
|
||||||
type: 'group',
|
type: 'group',
|
||||||
|
isGroup: true,
|
||||||
padding: 0, //getConfig().flowchart.padding
|
padding: 0, //getConfig().flowchart.padding
|
||||||
useRough,
|
useRough,
|
||||||
};
|
};
|
||||||
|
@@ -165,7 +165,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
|||||||
graph.nodes().forEach(function (v) {
|
graph.nodes().forEach(function (v) {
|
||||||
const n = graph.node(v);
|
const n = graph.node(v);
|
||||||
log.info(v, n.type, n.diff);
|
log.info(v, n.type, n.diff);
|
||||||
if (n.type === 'group') {
|
if (n.isGroup) {
|
||||||
diff = n.diff;
|
diff = n.diff;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user