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

@@ -2,6 +2,7 @@ import * as d3 from 'd3';
import idCache from './id-cache.js';
import stateDb from './stateDb';
import utils from '../../utils';
import common from '../common/common';
import { getConfig } from '../../config';
// let conf;
@@ -391,12 +392,6 @@ export const drawState = function(elem, stateDef) {
return stateInfo;
};
const getRows = s => {
let str = s.replace(/<br\s*\/?>/gi, '#br#');
str = str.replace(/\\n/g, '#br#');
return str.split('#br#');
};
let edgeCount = 0;
export const drawEdge = function(elem, path, relation) {
const getRelationType = function(type) {
@@ -455,7 +450,7 @@ export const drawEdge = function(elem, path, relation) {
const { x, y } = utils.calcLabelPosition(path.points);
const rows = getRows(relation.title);
const rows = common.getRows(relation.title);
// console.warn(rows);