1169- break out getRows

Moved getRows function from `state/stateRenderer.js` and `state/shapes.js` into `common/common.js`. Broke out section into small one line functions for replacing line breaks, then moved the `sanitize` function from `utils.js` to this new module as there is shared functionality
This commit is contained in:
Justin Greywolf
2020-02-21 13:49:05 -08:00
parent 5ccca5e329
commit 6d74c5663f
6 changed files with 51 additions and 42 deletions

View File

@@ -74,25 +74,6 @@ export const interpolateToCurve = (interpolate, defaultCurve) => {
return d3[curveName] || defaultCurve;
};
export const sanitize = (text, config) => {
let txt = text;
let htmlLabels = true;
if (
config.flowchart &&
(config.flowchart.htmlLabels === false || config.flowchart.htmlLabels === 'false')
)
htmlLabels = false;
if (config.securityLevel !== 'loose' && htmlLabels) { // eslint-disable-line
txt = txt.replace(/<br\s*\/?>/gi, '#br#');
txt = txt.replace(/</g, '&lt;').replace(/>/g, '&gt;');
txt = txt.replace(/=/g, '&equals;');
txt = txt.replace(/#br#/g, '<br/>');
}
return txt;
};
export const formatUrl = (linkStr, config) => {
let url = linkStr.trim();
@@ -225,7 +206,6 @@ export default {
interpolateToCurve,
calcLabelPosition,
calcCardinalityPosition,
sanitize,
formatUrl,
getStylesFromArray
};