Skip to content

Commit

Permalink
feat: breakText method support line wrapping text
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinghui.Liu authored and Qinghui.Liu committed Sep 13, 2023
1 parent 54e4f69 commit 137c43f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/x6-common/src/dom/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 137c43f

Please sign in to comment.