This commit is contained in:
Knut Sveidqvist 2021-05-09 15:34:02 +02:00
parent 43f6ae7ba0
commit d3d0df59cb
2 changed files with 20 additions and 8 deletions

View File

@ -398,6 +398,26 @@ stateDiagram-v2
} }
); );
}); });
it('v2 should handle different rendering directions in composite states', () => {
imgSnapshotTest(
`
stateDiagram
direction LR
state A {
direction BT
a --> b
}
state C {
direction RL
c --> d
}
A --> C
`,
{
logLevel: 0, fontFamily: 'courier',
}
);
});
it('v2 handle transition from one state in a composite state to a composite state', () => { it('v2 handle transition from one state in a composite state to a composite state', () => {
imgSnapshotTest( imgSnapshotTest(
` `

View File

@ -85,7 +85,6 @@ const setupNode = (g, parent, node, altFlag) => {
// group // group
if (!nodeDb[node.id].type && node.doc) { if (!nodeDb[node.id].type && node.doc) {
log.info('Setting cluster for ', node.id, getDir(node)); log.info('Setting cluster for ', node.id, getDir(node));
console.info('Setting cluster for ', node.id, getDir(node));
nodeDb[node.id].type = 'group'; nodeDb[node.id].type = 'group';
nodeDb[node.id].dir = getDir(node); nodeDb[node.id].dir = getDir(node);
nodeDb[node.id].shape = node.type === 'divider' ? 'divider' : 'roundedWithTitle'; nodeDb[node.id].shape = node.type === 'divider' ? 'divider' : 'roundedWithTitle';
@ -220,9 +219,6 @@ const getDir = (nodes, defaultDir) => {
} }
} }
} }
if(nodes.id==='A') {
console.log('nodes.id',nodes.id, dir)
}
return dir; return dir;
}; };
/** /**
@ -232,7 +228,6 @@ const getDir = (nodes, defaultDir) => {
*/ */
export const draw = function(text, id) { export const draw = function(text, id) {
log.info('Drawing state diagram (v2)', id); log.info('Drawing state diagram (v2)', id);
console.info('Drawing state diagram (v2)', id);
stateDb.clear(); stateDb.clear();
nodeDb = {}; nodeDb = {};
const parser = state.parser; const parser = state.parser;
@ -254,7 +249,6 @@ export const draw = function(text, id) {
log.info(stateDb.getRootDocV2()); log.info(stateDb.getRootDocV2());
stateDb.extract(stateDb.getRootDocV2()); stateDb.extract(stateDb.getRootDocV2());
log.info(stateDb.getRootDocV2()); log.info(stateDb.getRootDocV2());
console.info(stateDb.getRootDocV2());
// Create the input mermaid.graph // Create the input mermaid.graph
const g = new graphlib.Graph({ const g = new graphlib.Graph({
@ -272,9 +266,7 @@ export const draw = function(text, id) {
return {}; return {};
}); });
console.info('Setup node')
setupNode(g, undefined, stateDb.getRootDocV2(), true); setupNode(g, undefined, stateDb.getRootDocV2(), true);
console.info('Setup node done')
// Set up an SVG group so that we can translate the final graph. // Set up an SVG group so that we can translate the final graph.
const svg = select(`[id="${id}"]`); const svg = select(`[id="${id}"]`);