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

Fix TableCell child nodes on paste #5951

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

Shubhankerism
Copy link
Collaborator

@Shubhankerism Shubhankerism commented Apr 24, 2024

This PR fixes pasting tables that have the copied html in such format:

...
<td>
<span> ... </span>
</td>
...

Pasting this results in the following node structure:

image

which causes the editor to freeze and eventually crash on enter key press, as the text node is not wrapped in a paragraph node.
This issue is similar to the one described here and was fixed for the case when pasting empty cells.

This PR addresses the case when on paste the children of the TableCell node are not within a block element node.

Another case to reproduce this issue is when we copy something with such html:

...
<td>
<a> ... </a>
</td>
...

This results in a link node inside a tablecell node which again crashes on enter key press.

Also, this PR fixes the issue with alignment of text inside the cell as well, as this formatting can now be applied on the wrapping block element node.
So, copying from google sheets will now have the correct alignment.

Before

table-align-before

After

table-align-after

@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 Apr 24, 2024
Copy link

vercel bot commented Apr 24, 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 Apr 24, 2024 5:14pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 5:14pm

@zurfyx
Copy link
Member

zurfyx commented Apr 25, 2024

Thank you, we can merge this, but I'd be inclined to roll it back as soon as #5857 is ready as it fixes the same issue in a more generic manner cc @potatowagon

@ivailop7
Copy link
Collaborator

Thanks Gerard! Happy to revert once the larger one lands. Do we have an ETA on the generic solution? If it's a week, we can wait it out.

@Shubhankerism Shubhankerism merged commit 937432c into facebook:main Apr 25, 2024
45 checks passed
@potatowagon
Copy link
Contributor

potatowagon commented Apr 30, 2024

#5857 is ready, tests added and comments addressed @ivailop7 @zurfyx

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.

5 participants