Merge pull request #5598 from mermaid-js/fix/replace-string-with-dom

fix: prevent escaping label styles
This commit is contained in:
Sidharth Vinod 2024-06-28 05:54:03 +00:00 committed by GitHub
commit 6095aaae61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 16 deletions

View File

@ -25,15 +25,10 @@ function addHtmlLabel(node) {
const label = node.label;
const labelClass = node.isNode ? 'nodeLabel' : 'edgeLabel';
div.html(
'<span class="' +
labelClass +
'" ' +
(node.labelStyle ? 'style="' + node.labelStyle + '"' : '') +
'>' +
label +
'</span>'
);
const span = div.append('span');
span.html(label);
applyStyle(span, node.labelStyle);
span.attr('class', labelClass);
applyStyle(div, node.labelStyle);
div.style('display', 'inline-block');

View File

@ -21,13 +21,10 @@ function addHtmlSpan(element, node, width, classes, addBackground = false) {
const label = node.label;
const labelClass = node.isNode ? 'nodeLabel' : 'edgeLabel';
div.html(
`<span class="${labelClass} ${classes}" ` +
(node.labelStyle ? 'style="' + node.labelStyle + '"' : '') +
'>' +
label +
'</span>'
);
const span = div.append('span');
span.html(label);
applyStyle(span, node.labelStyle);
span.attr('class', `${labelClass} ${classes}`);
applyStyle(div, node.labelStyle);
div.style('display', 'table-cell');