mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-31 06:06:44 +02:00
Fix issue with text content using < and >
This commit is contained in:
@@ -280,29 +280,27 @@ async function addText(
|
|||||||
labelText = labelText.replaceAll('<', '<').replaceAll('>', '>');
|
labelText = labelText.replaceAll('<', '<').replaceAll('>', '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = label
|
const text = label.node().appendChild(
|
||||||
.node()
|
await createText(
|
||||||
.appendChild(
|
label,
|
||||||
await createText(
|
labelText,
|
||||||
label,
|
{
|
||||||
labelText,
|
width: calculateTextWidth(labelText, config) + 100,
|
||||||
{
|
style,
|
||||||
width: calculateTextWidth(labelText, config) + 100,
|
useHtmlLabels: config.htmlLabels,
|
||||||
style,
|
},
|
||||||
useHtmlLabels: config.htmlLabels,
|
config
|
||||||
},
|
)
|
||||||
config
|
);
|
||||||
)
|
|
||||||
);
|
|
||||||
// Undo work around now that text passed through correctly
|
// Undo work around now that text passed through correctly
|
||||||
if (labelText.includes('<')) {
|
if (labelText.includes('<') || labelText.includes('>')) {
|
||||||
let child = text.children[0];
|
let child = text.children[0];
|
||||||
// Get last child
|
child.textContent = child.textContent.replaceAll('<', '<').replaceAll('>', '>');
|
||||||
while (child.childNodes[0]) {
|
while (child.childNodes[0]) {
|
||||||
child = child.childNodes[0];
|
child = child.childNodes[0];
|
||||||
|
// Replace its text content
|
||||||
|
child.textContent = child.textContent.replaceAll('<', '<').replaceAll('>', '>');
|
||||||
}
|
}
|
||||||
// Replace its text content
|
|
||||||
child.textContent = child.textContent.replaceAll('<', '<').replaceAll('>', '>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let bbox = text.getBBox();
|
let bbox = text.getBBox();
|
||||||
|
Reference in New Issue
Block a user