mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-25 03:06:50 +02:00
#1295 Bugfix for descriptions
This commit is contained in:
@@ -290,7 +290,7 @@ describe('State diagram', () => {
|
|||||||
);
|
);
|
||||||
cy.get('svg');
|
cy.get('svg');
|
||||||
});
|
});
|
||||||
it('should render conurrency states', () => {
|
it('should render concurrency states', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
|
@@ -39,16 +39,25 @@
|
|||||||
G-->H
|
G-->H
|
||||||
G-->c
|
G-->c
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 50%; height: 20%;">
|
|
||||||
stateDiagram-v2
|
|
||||||
[*] --> monkey
|
|
||||||
state monkey {
|
|
||||||
Sitting
|
|
||||||
--
|
|
||||||
Eating
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="mermaid" style="width: 50%; height: 20%;">
|
<div class="mermaid" style="width: 50%; height: 20%;">
|
||||||
|
stateDiagram-v2
|
||||||
|
[*] --> Active
|
||||||
|
|
||||||
|
state Active {
|
||||||
|
[*] --> NumLockOff
|
||||||
|
NumLockOff --> NumLockOn : EvNumLockPressed
|
||||||
|
NumLockOn --> NumLockOff : EvNumLockPressed
|
||||||
|
--
|
||||||
|
[*] --> CapsLockOff
|
||||||
|
CapsLockOff --> CapsLockOn : EvCapsLockPressed
|
||||||
|
CapsLockOn --> CapsLockOff : EvCapsLockPressed
|
||||||
|
--
|
||||||
|
[*] --> ScrollLockOff
|
||||||
|
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
|
||||||
|
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="mermaid2" style="width: 50%; height: 20%;">
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*]-->TV
|
[*]-->TV
|
||||||
|
|
||||||
|
@@ -2,8 +2,12 @@ const createLabel = (vertexText, style, isTitle) => {
|
|||||||
const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
||||||
svgLabel.setAttribute('style', style.replace('color:', 'fill:'));
|
svgLabel.setAttribute('style', style.replace('color:', 'fill:'));
|
||||||
let rows = [];
|
let rows = [];
|
||||||
if (vertexText) {
|
if (typeof vertexText === 'string') {
|
||||||
rows = vertexText.split(/\\n|\n|<br\s*\/?>/gi);
|
rows = vertexText.split(/\\n|\n|<br\s*\/?>/gi);
|
||||||
|
} else if (Array.isArray(vertexText)) {
|
||||||
|
rows = vertexText;
|
||||||
|
} else {
|
||||||
|
rows = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let j = 0; j < rows.length; j++) {
|
for (let j = 0; j < rows.length; j++) {
|
||||||
|
@@ -16,6 +16,8 @@ import { logger as log } from '../logger';
|
|||||||
const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
|
const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
|
||||||
log.info('Graph in recursive render:', graphlib.json.write(graph), parentCluster);
|
log.info('Graph in recursive render:', graphlib.json.write(graph), parentCluster);
|
||||||
const dir = graph.graph().rankdir;
|
const dir = graph.graph().rankdir;
|
||||||
|
log.warn('Dir in recursive render - dir:', dir);
|
||||||
|
|
||||||
const elem = _elem.insert('g').attr('class', 'root'); // eslint-disable-line
|
const elem = _elem.insert('g').attr('class', 'root'); // eslint-disable-line
|
||||||
if (!graph.nodes()) {
|
if (!graph.nodes()) {
|
||||||
log.trace('No nodes found for', graph);
|
log.trace('No nodes found for', graph);
|
||||||
|
@@ -293,8 +293,11 @@ const rectWithTitle = (parent, node) => {
|
|||||||
|
|
||||||
const label = shapeSvg.insert('g').attr('class', 'label');
|
const label = shapeSvg.insert('g').attr('class', 'label');
|
||||||
|
|
||||||
const text = label.node().appendChild(createLabel(node.labelText[0], node.labelStyle, true));
|
const text2 = node.labelText.flat();
|
||||||
const textRows = node.labelText.slice(1, node.labelText.length);
|
logger.info('Label text', text2[0]);
|
||||||
|
|
||||||
|
const text = label.node().appendChild(createLabel(text2[0], node.labelStyle, true));
|
||||||
|
const textRows = text2.slice(1, text2.length);
|
||||||
let titleBox = text.getBBox();
|
let titleBox = text.getBBox();
|
||||||
const descr = label
|
const descr = label
|
||||||
.node()
|
.node()
|
||||||
|
Reference in New Issue
Block a user