Merge pull request #5786 from mermaid-js/5782_supporting_defaultRenderer

#5782 fix: adding backwards compatability for defaultRenderer directive
This commit is contained in:
Ashish Jain 2024-08-28 13:40:56 +02:00 committed by GitHub
commit 0bd00764c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View File

@ -7,13 +7,14 @@ import type {
const id = 'flowchart-v2'; const id = 'flowchart-v2';
const detector: DiagramDetector = (txt, config) => { const detector: DiagramDetector = (txt, config) => {
if ( if (config?.flowchart?.defaultRenderer === 'dagre-d3') {
config?.flowchart?.defaultRenderer === 'dagre-d3' ||
config?.flowchart?.defaultRenderer === 'elk'
) {
return false; return false;
} }
if (config?.flowchart?.defaultRenderer === 'elk') {
config.layout = 'elk';
}
// If we have configured to use dagre-wrapper then we should return true in this function for graph code thus making it use the new flowchart diagram // If we have configured to use dagre-wrapper then we should return true in this function for graph code thus making it use the new flowchart diagram
if (/^\s*graph/.test(txt) && config?.flowchart?.defaultRenderer === 'dagre-wrapper') { if (/^\s*graph/.test(txt) && config?.flowchart?.defaultRenderer === 'dagre-wrapper') {
return true; return true;

View File

@ -111,7 +111,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
if (graph.children(v).length > 0) { if (graph.children(v).length > 0) {
// This is a cluster but not to be rendered recursively // This is a cluster but not to be rendered recursively
// Render as before // Render as before
log.info( log.trace(
'Cluster - the non recursive path XBX', 'Cluster - the non recursive path XBX',
v, v,
node.id, node.id,
@ -120,11 +120,11 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
'Graph:', 'Graph:',
graph graph
); );
log.info(findNonClusterChild(node.id, graph)); log.trace(findNonClusterChild(node.id, graph));
clusterDb.set(node.id, { id: findNonClusterChild(node.id, graph), node }); clusterDb.set(node.id, { id: findNonClusterChild(node.id, graph), node });
// insertCluster(clusters, graph.node(v)); // insertCluster(clusters, graph.node(v));
} else { } else {
log.warn('Node - the non recursive path XAX', v, nodes, graph.node(v), dir); log.trace('Node - the non recursive path XAX', v, nodes, graph.node(v), dir);
await insertNode(nodes, graph.node(v), dir); await insertNode(nodes, graph.node(v), dir);
} }
} }