mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 04:49:44 +02:00
#1295 Adding support for multiline descriptions for states
This commit is contained in:
@@ -49,10 +49,14 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 50%; height: 20%;">
|
<div class="mermaid" style="width: 50%; height: 20%;">
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
|
State1: This a a single line description
|
||||||
[*] --> S1
|
State2: This a a multi line description
|
||||||
state "Some long name" as S1: The description<br/>continues
|
State2: here comes the multi part
|
||||||
|
a
|
||||||
|
[*] --> State1
|
||||||
|
State1 --> State2
|
||||||
|
State2 --> [*]
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2 mermaid-apa" style="width: 100%; height: 20%;">
|
<div class="mermaid2 mermaid-apa" style="width: 100%; height: 20%;">
|
||||||
stateDiagram
|
stateDiagram
|
||||||
|
@@ -132,6 +132,7 @@ export const addState = function(id, type, doc, descr, note) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (descr) {
|
if (descr) {
|
||||||
|
logger.info('Adding state ', id, descr);
|
||||||
if (typeof descr === 'string') addDescription(id, descr.trim());
|
if (typeof descr === 'string') addDescription(id, descr.trim());
|
||||||
|
|
||||||
if (typeof descr === 'object') {
|
if (typeof descr === 'object') {
|
||||||
|
@@ -52,13 +52,26 @@ const setupNode = (g, parent, node, altFlag) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description
|
// Build of the array of description strings accordinging
|
||||||
if (node.description) {
|
if (node.description) {
|
||||||
if (Array.isArray(node.description)) {
|
if (Array.isArray(nodeDb[node.id].description)) {
|
||||||
|
// There already is an array of strings,add to it
|
||||||
nodeDb[node.id].shape = 'rectWithTitle';
|
nodeDb[node.id].shape = 'rectWithTitle';
|
||||||
nodeDb[node.id].description = node.description;
|
nodeDb[node.id].description.push(node.description);
|
||||||
} else {
|
} else {
|
||||||
nodeDb[node.id].description = node.description;
|
if (nodeDb[node.id].description.length > 0) {
|
||||||
|
// if there is a description already transformit to an array
|
||||||
|
nodeDb[node.id].shape = 'rectWithTitle';
|
||||||
|
if (nodeDb[node.id].description === node.id) {
|
||||||
|
// If the previous description was the is, remove it
|
||||||
|
nodeDb[node.id].description = [node.description];
|
||||||
|
} else {
|
||||||
|
nodeDb[node.id].description = [nodeDb[node.id].description, node.description];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nodeDb[node.id].shape = 'rect';
|
||||||
|
nodeDb[node.id].description = node.description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user