Skip to content
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

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

orientMoon
Copy link
Contributor

@orientMoon orientMoon commented Sep 13, 2023

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Enhancement (changes that improvement of current feature or performance)
  • Refactoring (changes that neither fixes a bug nor adds a feature)
  • Test Case (changes that add missing tests or correct existing tests)
  • Code style optimization (changes that do not affect the meaning of the code)
  • Docs (changes that only update documentation)
  • Chore (changes that don't modify src or test files)

Self Check before Merge

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@x6-bot x6-bot bot added needs-more-info PR: unreviewed PR does not have any reviews. labels Sep 13, 2023
@x6-bot
Copy link
Contributor

x6-bot bot commented Sep 13, 2023

@orientMoon Please provide us with more info about this pull request.

@x6-bot x6-bot bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 13, 2023
@orientMoon
Copy link
Contributor Author

当前breakText在计算时,如果text中已经包含换行符eol,breakText计算后的换行结果显示效果很混乱,因此,调整一下breakText方法,在计算前判断一下是否包含eol,包含eol的text先按照eol分割,分割后的部分text依次执行breakText,最后根据可显示的行数决定保留多少行text

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #3910 (137c43f) into master (a152965) will decrease coverage by 0.01%.
Report is 80 commits behind head on master.
The diff coverage is 11.90%.

Additional details and impacted files

Impacted file tree graph

@@            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              
Flag Coverage Δ
x6 10.35% <11.90%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
packages/x6/src/graph/mousewheel.ts 7.27% <0.00%> (ø)
packages/x6/src/model/edge.ts 7.59% <0.00%> (ø)
packages/x6/src/model/model.ts 1.63% <0.00%> (ø)
packages/x6/src/registry/tool/editor.ts 5.06% <0.00%> (ø)
packages/x6/src/view/edge.ts 1.12% <0.00%> (ø)
packages/x6/src/view/view.ts 6.04% <ø> (ø)
packages/x6/src/renderer/scheduler.ts 4.74% <8.33%> (ø)
packages/x6/src/registry/tool/vertices.ts 4.83% <11.11%> (-0.17%) ⬇️
packages/x6/src/renderer/queueJob.ts 8.21% <100.00%> (ø)

... and 1 file with indirect coverage changes

const splitText: string[] = []

text.split(eol).map((line) => {
const part = breakText(line, { ...size, height: Number.MAX_SAFE_INTEGER }, styles, { ...options, eol: delimiter })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 eol 可以不传吧,因为 split 后 line 里面肯定不会继续有 eol 了。

Copy link
Contributor Author

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

@NewByVector NewByVector merged commit f3efd68 into antvis:master Sep 19, 2023
22 checks passed
@x6-bot x6-bot bot added PR: merged PR has merged. and removed PR: unreviewed PR does not have any reviews. labels Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-info PR: merged PR has merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants