Render empty lines correctly

This commit is contained in:
Zihua Li
2023-06-04 16:24:41 +08:00
parent ce9bdcc53f
commit 2a6603b33a
3 changed files with 8 additions and 8 deletions

View File

@@ -32,6 +32,8 @@ import assignWithDepth from './assignWithDepth.js';
import { MermaidConfig } from './config.type.js';
import memoize from 'lodash-es/memoize.js';
export const ZERO_WIDTH_SPACE = '\u200b';
// Effectively an enum of the supported curve types, accessible by name
const d3CurveTypes = {
curveBasis: curveBasis,
@@ -764,11 +766,8 @@ export const calculateTextDimensions: (
let cheight = 0;
const dim = { width: 0, height: 0, lineHeight: 0 };
for (const line of lines) {
if (!line) {
continue;
}
const textObj = getTextObj();
textObj.text = line;
textObj.text = line || ZERO_WIDTH_SPACE;
const textElem = drawSimpleText(g, textObj)
.style('font-size', _fontSizePx)
.style('font-weight', fontWeight)