Skip to content

Commit

Permalink
fix(text): using ceilToDecimal to set text width to avoid breaking li…
Browse files Browse the repository at this point in the history
…ne(when type line `j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j`) #WIK-16254
  • Loading branch information
pubuzhixing8 committed Sep 11, 2024
1 parent 14f0296 commit 875feb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/quiet-zebras-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@plait/common': patch
'@plait/core': patch
---

using ceilToDecimal to set text width to avoid breaking line(like `j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j'j`)
1 change: 1 addition & 0 deletions packages/common/src/text/text-manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
PlaitBoard,
Point,
RectangleClient,
ceilToDecimal,
createForeignObject,
createG,
debounce,
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/utils/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ export function toFixed(v: number) {
return +v.toFixed(2);
}

export function ceilToDecimal(value: number, decimalPlaces: number) {
const factor = Math.pow(10, decimalPlaces);
return Math.ceil(value * factor) / factor;
}

/**
* Whether two numbers numbers a and b are approximately equal.
*
Expand Down

0 comments on commit 875feb4

Please sign in to comment.