-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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: text wrapping #7999
feat: text wrapping #7999
Conversation
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.
Hi @ryan-di , did some quick testing of the PR and it looks good ✨
left some comments
packages/excalidraw/change.ts
Outdated
@@ -1450,7 +1450,9 @@ export class ElementsChange implements Change<SceneElementsMap> { | |||
continue; | |||
} | |||
|
|||
redrawTextBoundingBox(boundText, container, elements, false); | |||
redrawTextBoundingBox(boundText, container, elements, { | |||
informMutation: false, |
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.
I don't recall, why is this not needed any more ?
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.
haha, I fell for the same. The informMutation=false
is kept. Previously it was just a boolean
flag.
Though through refactor the API signature change is no longer necessary so we can potential revert.
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.
reverted 🙂
} | ||
if (transformHandleType.includes("s")) { | ||
scaleY = (rotatedY - y1) / (y2 - y1); | ||
if (transformHandleType !== "e" && transformHandleType !== "w") { |
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.
can this go into else of line 327 ? since you are checking if its e
|| w
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.
Without the if
check here, scale from line 266 would not be zero and it'll trigger logic unrelated to e
and w
. I didn't really want to touch the logic that was working well for corner resizes. So the if
check is here for that purpose.
expect(text.height).toBe(height); | ||
}); | ||
|
||
it("can be resized from w", async () => { |
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.
it("can be resized from w", async () => { | |
it("text can be resized from w", async () => { |
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.
keeping the format: describe("text element") it("can be resized from w")
expect(text.autoResize).toBe(false); | ||
}); | ||
|
||
it("has a minimum width when wrapped", async () => { |
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.
it("has a minimum width when wrapped", async () => { | |
it("text has a minimum width when wrapped", async () => { |
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
fix #7864
fix #4267 (partial)
This PR builds upon the side resizing PR. For text elements, when resized from "left" and "right" (or "w" and "e"), we support text wrapping and unwrapping.
follow-ups/TBD
autoResize
)