mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-01 14:46:41 +02:00
#945Renabling support for descriptions
This commit is contained in:
@@ -13,6 +13,21 @@ describe('State diagram', () => {
|
||||
);
|
||||
cy.get('svg');
|
||||
});
|
||||
it('should render a states with descriptions including multi-line descriptions', () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
stateDiagram
|
||||
State1: This a a single line description
|
||||
State2: This a a multi line description
|
||||
State2: here comes the multi part
|
||||
[*] --> State1
|
||||
State1 --> State2
|
||||
State2 --> [*]
|
||||
`,
|
||||
{ logLevel: 0 }
|
||||
);
|
||||
cy.get('svg');
|
||||
});
|
||||
it('should render a simple state diagrams', () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
|
@@ -109,7 +109,7 @@ line
|
||||
;
|
||||
|
||||
statement
|
||||
: idStatement DESCR { $$={ stmt: 'state', id: $1, type: 'default', description: $2.trim()};}
|
||||
: idStatement DESCR { console.warn('got id and descr', $1, $2.trim());$$={ stmt: 'state', id: $1, type: 'default', description: $2.trim()};}
|
||||
| idStatement '-->' idStatement
|
||||
{
|
||||
/*console.warn('got id', $1);yy.addRelation($1, $3);*/
|
||||
|
@@ -14,7 +14,7 @@ const extract = doc => {
|
||||
|
||||
doc.forEach(item => {
|
||||
if (item.stmt === 'state') {
|
||||
addState(item.id, item.type, item.doc);
|
||||
addState(item.id, item.type, item.doc, item.description);
|
||||
}
|
||||
if (item.stmt === 'relation') {
|
||||
addRelation(item.state1.id, item.state2.id, item.description);
|
||||
@@ -46,7 +46,7 @@ let endCnt = 0;
|
||||
* @param type
|
||||
* @param style
|
||||
*/
|
||||
export const addState = function(id, type, doc) {
|
||||
export const addState = function(id, type, doc, descr) {
|
||||
console.warn('Add state', id);
|
||||
if (typeof currentDocument.states[id] === 'undefined') {
|
||||
currentDocument.states[id] = {
|
||||
@@ -63,6 +63,7 @@ export const addState = function(id, type, doc) {
|
||||
currentDocument.states[id].type = type;
|
||||
}
|
||||
}
|
||||
if (descr) addDescription(id, descr.trim());
|
||||
};
|
||||
|
||||
export const clear = function() {
|
||||
@@ -107,7 +108,7 @@ export const addRelation = function(_id1, _id2, title) {
|
||||
currentDocument.relations.push({ id1, id2, title });
|
||||
};
|
||||
|
||||
export const addDescription = function(id, _descr) {
|
||||
const addDescription = function(id, _descr) {
|
||||
const theState = currentDocument.states[id];
|
||||
let descr = _descr;
|
||||
if (descr[0] === ':') {
|
||||
@@ -144,7 +145,7 @@ export default {
|
||||
getStates,
|
||||
getRelations,
|
||||
addRelation,
|
||||
addDescription,
|
||||
// addDescription,
|
||||
cleanupLabel,
|
||||
lineType,
|
||||
relationType,
|
||||
|
Reference in New Issue
Block a user