fix for other styling fixes

This commit is contained in:
Ashish Jain
2024-07-18 13:24:43 +02:00
parent 15c85efd88
commit f30d370e3b
4 changed files with 25 additions and 12 deletions

View File

@@ -224,7 +224,9 @@ export const createText = async (
const vertexNode = await addHtmlSpan(el, node, width, classes, addSvgBackground);
return vertexNode;
} else {
const structuredText = markdownToLines(text.replace('<br>', '<br/>'), config);
//sometimes the user might add br tags with 1 or more spaces in between, so we need to replace them with <br/>
const sanitizeBR = text.replace(/<br\s*\/?>/g, '<br/>');
const structuredText = markdownToLines(sanitizeBR.replace('<br>', '<br/>'), config);
const svgLabel = createFormattedText(
width,
el,
@@ -235,9 +237,13 @@ export const createText = async (
if (/stroke:/.exec(style)) {
style = style.replace('stroke:', 'lineColor:');
}
select(svgLabel)
.select('text')
.attr('style', style.replace(/color:/g, 'fill:'));
const nodeLabelTextStyle = style
.replace(/stroke:[^;]+;?/g, '')
.replace(/stroke-width:[^;]+;?/g, '')
.replace(/fill:[^;]+;?/g, '')
.replace(/color:/g, 'fill:');
select(svgLabel).attr('style', nodeLabelTextStyle);
// svgLabel.setAttribute('style', style);
} else {
//On style, assume `stroke`, `stroke-width` are used for edge path, so remove them

View File

@@ -81,6 +81,8 @@ export function markdownToHTML(markdown: string, { markdownAutoWrap }: MermaidCo
return `<em>${node.tokens?.map(output).join('')}</em>`;
} else if (node.type === 'paragraph') {
return `<p>${node.tokens?.map(output).join('')}</p>`;
} else if (node.type === 'space') {
return '';
} else if (node.type === 'html') {
return `${node.text}`;
}