Fix exceptions for empty lines

This commit is contained in:
Zihua Li 2023-05-29 21:00:37 +08:00
parent 38d9ebc5da
commit ce9bdcc53f
2 changed files with 13 additions and 0 deletions

View File

@ -88,6 +88,16 @@ context('Sequence diagram', () => {
{}
);
});
it('should handle empty lines', () => {
imgSnapshotTest(
`
sequenceDiagram
Alice->>John: Hello John<br/>
John-->>Alice: Great!
`,
{}
);
});
it('should handle line breaks and wrap annotations', () => {
imgSnapshotTest(
`

View File

@ -764,6 +764,9 @@ 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;
const textElem = drawSimpleText(g, textObj)