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 label = node.label;
const labelClass = node.isNode ? 'nodeLabel' : 'edgeLabel'; const labelClass = node.isNode ? 'nodeLabel' : 'edgeLabel';
div.html( const span = div.append('span');
'<span class="' + span.html(label);
labelClass + applyStyle(span, node.labelStyle);
'" ' + span.attr('class', labelClass);
(node.labelStyle ? 'style="' + node.labelStyle + '"' : '') +
'>' +
label +
'</span>'
);
applyStyle(div, node.labelStyle); applyStyle(div, node.labelStyle);
div.style('display', 'inline-block'); div.style('display', 'inline-block');

View File

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