diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index 4ee44b589e..d5c59a0fd0 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -346,5 +346,15 @@ flowchart TD {htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'} ); }); + it('61: fontawesome icons in edge labels', () => { + imgSnapshotTest( + ` + flowchart TD + C -->|fa:fa-car Car| F[fa:fa-car Car] + `, + {htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'} + ); + }); + }); diff --git a/cypress/integration/rendering/flowchart.spec.js b/cypress/integration/rendering/flowchart.spec.js index eb8c8cf816..763dde713f 100644 --- a/cypress/integration/rendering/flowchart.spec.js +++ b/cypress/integration/rendering/flowchart.spec.js @@ -787,5 +787,14 @@ describe('Flowchart', () => { {htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'} ); }); + it('61: fontawesome icons in edge labels', () => { + imgSnapshotTest( + ` +graph TD + C -->|fa:fa-car Car| F[fa:fa-car Car] + `, + {htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'} + ); + }); }); diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html index 6ef3c1dd5f..558de5f9d5 100644 --- a/cypress/platform/knsv.html +++ b/cypress/platform/knsv.html @@ -22,7 +22,7 @@

info below

-
+
graph TD A[Christmas] ==> D A[Christmas] -->|Get money| B(Go shopping) @@ -38,7 +38,7 @@

info below

class T TestSub linkStyle 0,1 color:orange, stroke: orange;
-
+
flowchart TD A[Christmas] ==> D A[Christmas] -->|Get money| B(Go shopping) @@ -55,14 +55,13 @@

info below

class T TestSub linkStyle 0,1 color:orange, stroke: orange;
-
- flowchart TB -subgraph A -a -->b -end -subgraph B -b -end +
+graph TD + C -->|fa:fa-car Car| F[fa:fa-car Car] +
+
+flowchart TD + C -->|fa:fa-car Car| F[fa:fa-car Car]
%%{init: {"fontFamily": "arial2"}}%% diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index b4a0077737..f07a8d68b5 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -230,7 +230,10 @@ export const addEdges = function(edges, g) { if (getConfig().flowchart.htmlLabels) { edgeData.labelType = 'html'; - edgeData.label = `${edge.text}`; + edgeData.label = `${edge.text.replace( + /fa[lrsb]?:fa-[\w-]+/g, + s => `` + )}`; } else { edgeData.labelType = 'text'; edgeData.label = edge.text.replace(common.lineBreakRegex, '\n');