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

[lexical-playground][ExcalidrawNode] Bug Fix: Preserve Excalidraw image dimensions after resizing #6634

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

neysanfoo
Copy link
Contributor

Description

When resizing an Excalidraw image within the Lexical editor, the new dimensions are not preserved after certain editor actions. For example, try moving the cursor just to the left of the image and pressing Enter. This will cause the image to revert to its original size and a mismatch between the resize box and the image.

Changes Introduced

Updating the ExcalidrawNode Class:

  1. Updated updateDOM method to ensure than when node is updated the dom reflects the new width and height
  2. Update $createExcalidrawNode function to take in data, width, height

Modifying the ExcalidrawComponent:

  1. Retrieved width and height from the node using the new getter methods.
  2. Pass width and height to ExcalidrawImage

Updating the ExcalidrawImage Component:

  1. Accepted width and height as props.
  2. Apply the dimensions to the container's style

Test plan

Steps to Reproduce:

  1. Insert an Excalidraw image into the editor.
  2. Resize the image to make it larger.
  3. Move the cursor to the left of the image.
  4. Press Enter.

Before

Observed Behavior: The image shrinks back to its original size, losing the resizing adjustments made by the user.

lexical-bug-before.mp4

After

Observed Behavior: The image retains its resized dimensions, preserving the user's adjustments even after the editor updates.

lexical-bug-after.mp4

Copy link

vercel bot commented Sep 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 15, 2024 3:48am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 15, 2024 3:48am

@facebook-github-bot
Copy link
Contributor

Hi @neysanfoo!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link

github-actions bot commented Sep 14, 2024

size-limit report 📦

Path Size
lexical - cjs 29.78 KB (0%)
lexical - esm 29.62 KB (0%)
@lexical/rich-text - cjs 38.21 KB (0%)
@lexical/rich-text - esm 31.51 KB (0%)
@lexical/plain-text - cjs 36.87 KB (0%)
@lexical/plain-text - esm 28.82 KB (0%)
@lexical/react - cjs 40.01 KB (0%)
@lexical/react - esm 32.91 KB (0%)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 14, 2024
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Looks good! Confirmed that resizing works as expected now at least in the situations I tried

@etrepum etrepum added this pull request to the merge queue Sep 16, 2024
Merged via the queue into facebook:main with commit 3131ff8 Sep 16, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants