This commit is contained in:
Knut Sveidqvist
2022-01-18 23:02:16 +01:00
parent 87dc13365f
commit 44d7dfe993
5 changed files with 122 additions and 8 deletions

View File

@@ -1,7 +1,9 @@
import { select } from 'd3';
import { log } from '../logger'; // eslint-disable-line
import { getConfig } from '../config';
import { evaluate } from '../diagrams/common/common';
import { sanitizeText, evaluate } from '../diagrams/common/common';
const sanitizeTxt = (txt) => sanitizeText(txt, getConfig());
/**
* @param dom
@@ -42,7 +44,7 @@ function addHtmlLabel(node) {
}
const createLabel = (_vertexText, style, isTitle, isNode) => {
let vertexText = _vertexText || '';
let vertexText = sanitizeTxt(_vertexText || '');
if (typeof vertexText === 'object') vertexText = vertexText[0];
if (evaluate(getConfig().flowchart.htmlLabels)) {
// TODO: addHtmlLabel accepts a labelStyle. Do we possibly have that?

View File

@@ -13,6 +13,8 @@ let classCounter = 0;
let funs = [];
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
export const parseDirective = function (statement, context, type) {
mermaidAPI.parseDirective(this, statement, context, type);
};
@@ -137,6 +139,7 @@ export const addMember = function (className, member) {
if (typeof member === 'string') {
// Member can contain white spaces, we trim them out
// const memberString = sanitizeText(member.trim());
const memberString = member.trim();
if (memberString.startsWith('<<') && memberString.endsWith('>>')) {

View File

@@ -17,6 +17,8 @@ parser.yy = classDb;
let idCache = {};
const padding = 20;
const sanitizeText = (txt) => common.sanitizeText(txt, getConfig());
const conf = {
dividerMargin: 10,
padding: 5,
@@ -103,7 +105,7 @@ export const addClasses = function (classes, g) {
g.setNode(vertex.id, {
labelStyle: styles.labelStyle,
shape: _shape,
labelText: vertexText,
labelText: sanitizeText(vertexText),
classData: vertex,
rx: radious,
ry: radious,