mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-06 07:39:48 +02:00
Fix for node with wrong type
This commit is contained in:
@@ -19,11 +19,13 @@ export const labelHelper = (parent, node, _classes, isNode) => {
|
||||
// Create the label and insert it after the rect
|
||||
const label = shapeSvg.insert('g').attr('class', 'label').attr('style', node.labelStyle);
|
||||
|
||||
const labelText = typeof node.labelText === 'string' ? node.labelText:node.labelText[0];
|
||||
|
||||
const text = label
|
||||
.node()
|
||||
.appendChild(
|
||||
createLabel(
|
||||
sanitizeText(decodeEntities(node.labelText), getConfig()),
|
||||
sanitizeText(decodeEntities(labelText), getConfig()),
|
||||
node.labelStyle,
|
||||
false,
|
||||
isNode
|
||||
|
@@ -70,11 +70,7 @@ const setupNode = (g, parent, node, altFlag) => {
|
||||
nodeDb[node.id].shape = 'rectWithTitle';
|
||||
if (nodeDb[node.id].description === node.id) {
|
||||
// If the previous description was the is, remove it
|
||||
if (Array.isArray(node.description)) {
|
||||
nodeDb[node.id].description = node.description;
|
||||
} else {
|
||||
nodeDb[node.id].description = [node.description];
|
||||
}
|
||||
nodeDb[node.id].description = [node.description];
|
||||
} else {
|
||||
nodeDb[node.id].description = [nodeDb[node.id].description, node.description];
|
||||
}
|
||||
@@ -83,6 +79,15 @@ const setupNode = (g, parent, node, altFlag) => {
|
||||
nodeDb[node.id].description = node.description;
|
||||
}
|
||||
}
|
||||
nodeDb[node.id].description = common.sanitizeTextOrArray(
|
||||
nodeDb[node.id].description,
|
||||
getConfig()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (nodeDb[node.id].description.length === 1 && nodeDb[node.id].shape === 'rectWithTitle') {
|
||||
nodeDb[node.id].shape = 'rect';
|
||||
}
|
||||
|
||||
// Save data for description and group so that for instance a statement without description overwrites
|
||||
@@ -100,17 +105,10 @@ const setupNode = (g, parent, node, altFlag) => {
|
||||
(altFlag ? 'statediagram-cluster statediagram-cluster-alt' : 'statediagram-cluster');
|
||||
}
|
||||
|
||||
let nodeShape = nodeDb[node.id].shape;
|
||||
let nodeLabelText = nodeDb[node.id].description;
|
||||
if (Array.isArray(nodeLabelText) && nodeLabelText.length == 1) {
|
||||
nodeShape = 'rect';
|
||||
nodeLabelText = nodeLabelText[0];
|
||||
}
|
||||
|
||||
const nodeData = {
|
||||
labelStyle: '',
|
||||
shape: nodeShape,
|
||||
labelText: nodeLabelText,
|
||||
shape: nodeDb[node.id].shape,
|
||||
labelText: nodeDb[node.id].description,
|
||||
// typeof nodeDb[node.id].description === 'object'
|
||||
// ? nodeDb[node.id].description[0]
|
||||
// : nodeDb[node.id].description,
|
||||
|
Reference in New Issue
Block a user