fix:prioritize flowchart.htmlLabels over global htmlLabels

on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
darshanr0107
2025-09-18 17:47:41 +05:30
parent 270f05d409
commit c16d20c855
3 changed files with 11 additions and 8 deletions

View File

@@ -1231,15 +1231,18 @@ class link myClass
); );
}); });
it('should not create foreignObject elements when htmlLabels disabled via global config', () => { it('should not render with htmlLabels when disabled via flowchart config, even when enabled in global config', () => {
renderGraph( imgSnapshotTest(
`flowchart TD `flowchart LR
A["Node with <br> HTML"] -- "edge <br> label" --> B["Another node"] A["HTML label <br> with breaks"] --> B["Another label"]
C --> D C --> D
`, `,
{ htmlLabels: false } { htmlLabels: true, flowchart: { htmlLabels: false } },
undefined,
($svg) => {
expect($svg.find('foreignObject').length).to.equal(0);
}
); );
cy.get('svg foreignObject').should('not.exist');
}); });
it('should create foreignObject elements when htmlLabels enabled', () => { it('should create foreignObject elements when htmlLabels enabled', () => {

View File

@@ -21,7 +21,7 @@ export const diagram = {
if (cnf.layout) { if (cnf.layout) {
setConfig({ layout: cnf.layout }); setConfig({ layout: cnf.layout });
} }
cnf.flowchart.htmlLabels = cnf?.htmlLabels ?? cnf.flowchart?.htmlLabels; cnf.flowchart.htmlLabels = cnf.flowchart?.htmlLabels ?? cnf?.htmlLabels;
cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
setConfig({ setConfig({
flowchart: { flowchart: {

View File

@@ -13,7 +13,7 @@ export const labelHelper = async <T extends SVGGraphicsElement>(
_classes?: string _classes?: string
) => { ) => {
let cssClasses; let cssClasses;
const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.htmlLabels); const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels);
if (!_classes) { if (!_classes) {
cssClasses = 'node default'; cssClasses = 'node default';
} else { } else {