fix: prevent escaping label styles

This commit is contained in:
Yash Singh 2024-06-24 16:07:43 -07:00
parent ce3b0af03a
commit ab726f008c
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');