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-table][lexical-utils][lexical-react]: Bug Fix: Enforce table integrity with transforms and move non-React plugin code to @lexical/table #6914

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Dec 5, 2024

Description

  • Enforce Table invariants with node transforms that are registered by the table plugin
  • Move the majority of the Table plugin's code to @lexical/table so that it can be more easily used in non-React applications
  • Add a new $unwrapAndFilterDescendants to @lexical/utils for use in these transforms (it's possibly useful elsewhere that we have a fixed schema, like ListNode/ListItemNode)

New Import & Transform Invariants:

TableNode

  • may only have TableRowNode children

TableRowNode

  • must have a TableNode parent
  • may only have TableCellNode children

TableCellNode

  • must have a TableRowNode parent,
  • must be non-empty (an empty ParagraphNode will be added)

Closes #6910

Test plan

Before

Playground crash when pasting a table that has tbody, thead, tfoot, or and/or caption

After

No crash, new unit tests for new functionality, specifically testing that the import behaves as expected

Copy link

vercel bot commented Dec 5, 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 Dec 6, 2024 4:53am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 4:53am

@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 Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

size-limit report 📦

Path Size
lexical - cjs 31.07 KB (0%)
lexical - esm 30.92 KB (0%)
@lexical/rich-text - cjs 39.89 KB (0%)
@lexical/rich-text - esm 32.75 KB (0%)
@lexical/plain-text - cjs 38.46 KB (0%)
@lexical/plain-text - esm 30.08 KB (0%)
@lexical/react - cjs 41.79 KB (0%)
@lexical/react - esm 34.15 KB (0%)

Copy link
Collaborator

@ivailop7 ivailop7 left a comment

Choose a reason for hiding this comment

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

Fantastic refactor!

@ivailop7 ivailop7 added this pull request to the merge queue Dec 6, 2024
Merged via the queue into facebook:main with commit 97481c9 Dec 6, 2024
40 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. extended-tests Run extended e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Pasting a table that includes a 'caption' tag inside crashes the editor
3 participants