-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: breakText method support line wrapping text #3910
Conversation
@orientMoon Please provide us with more info about this pull request. |
当前breakText在计算时,如果text中已经包含换行符eol,breakText计算后的换行结果显示效果很混乱,因此,调整一下breakText方法,在计算前判断一下是否包含eol,包含eol的text先按照eol分割,分割后的部分text依次执行breakText,最后根据可显示的行数决定保留多少行text |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #3910 +/- ##
==========================================
- Coverage 10.35% 10.35% -0.01%
==========================================
Files 180 180
Lines 10513 10519 +6
Branches 2561 2564 +3
==========================================
Hits 1089 1089
- Misses 9335 9341 +6
Partials 89 89
Flags with carried forward coverage won't be shown. Click here to find out more.
|
const splitText: string[] = [] | ||
|
||
text.split(eol).map((line) => { | ||
const part = breakText(line, { ...size, height: Number.MAX_SAFE_INTEGER }, styles, { ...options, eol: delimiter }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 eol 可以不传吧,因为 split 后 line 里面肯定不会继续有 eol 了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split后的line在进行breakText时,返回值会用eol进行join,为了将join后的字符串分割,所以这里用uuid作为新的eol
Description
Motivation and Context
Types of changes
Self Check before Merge