diff --git a/packages/x6-common/src/dom/text.ts b/packages/x6-common/src/dom/text.ts index a97eb6ad21b..7f0514bb3aa 100644 --- a/packages/x6-common/src/dom/text.ts +++ b/packages/x6-common/src/dom/text.ts @@ -453,15 +453,12 @@ export function breakText( const delimiter = StringExt.uuid() const splitText: string[] = [] - text.split(eol).map((fragment) => { - splitText.push( - ...breakText( - fragment, - { ...size, height: Number.MAX_SAFE_INTEGER }, - styles, - { ...options, eol: delimiter }, - ).split(delimiter), - ) + text.split(eol).map((line) => { + const part = breakText(line, { ...size, height: Number.MAX_SAFE_INTEGER }, styles, { ...options, eol: delimiter }) + + if (part) { + splitText.push(...part.split(delimiter)) + } }) return splitText.slice(0, maxLines).join(eol)