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-playground] Bug Fix: Fix merged cell related edge cases #6607

Merged
merged 5 commits into from
Sep 7, 2024

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Sep 6, 2024

Description

  • Ensure that TableSelection.getNodes returns each node at most once, which fixes logic errors in merge code when the "first cell" shows up multiple times due to merge
  • Account for colSpan and rowSpan in TableSelection.getShape
  • Fix some inconsistencies with the implementation of TableCellNode
  • Use a heuristic for setting table cell styles when unmerging cells
  • Add a mask for TableCellNode.setHeaderStyles so that the row or column style can be explicitly set without affecting the other setting
  • Remove restriction on merging "weird shapes" of table cells, all selections are rectangular and can be merged
  • Workaround in $computeTableMapSkipCellCheck for non-rectangular tables with rowSpan below the last <tr> in the table. Someone who cares more about these edge cases with what is essentially a bad input should put some more work into this though, since there are likely still other edge cases. The TableMapType and its associated functions (e.g. $computeTableMap) really should get tossed, it's not a good abstraction and it can't represent a non-rectangular table, but because the types are fully transparent it can't be fixed in-place in a backwards compatible way.

/cc @ivailop7

Closes #6599
Closes #4470
Closes #5853
Closes #6605
Closes #6584

Test plan

Before

  • Prior to this PR it will throw an exception

After

  • The merge executes with the correct colSpan/rowSpan (from two cells with colSpan=2 and rowSpan=1 to one cell with colSpan=2 and rowSpan=1)
  • The unmerge results in 4 cells with colSpan=1, rowSpan=1

Copy link

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

Copy link

github-actions bot commented Sep 6, 2024

size-limit report 📦

Path Size
lexical - cjs 29.66 KB (0%)
lexical - esm 29.48 KB (0%)
@lexical/rich-text - cjs 38.11 KB (+0.11% 🔺)
@lexical/rich-text - esm 31.32 KB (0%)
@lexical/plain-text - cjs 36.65 KB (0%)
@lexical/plain-text - esm 28.66 KB (0%)
@lexical/react - cjs 39.83 KB (0%)
@lexical/react - esm 32.75 KB (0%)

@etrepum etrepum changed the title [WIP] [lexical-table][lexical-playground] Bug Fix: Fix merged cell related edge cases [lexical-table][lexical-playground] Bug Fix: Fix merged cell related edge cases Sep 6, 2024
@etrepum etrepum added the tables Relates to Lexical Tables label Sep 7, 2024
@rilrom
Copy link
Contributor

rilrom commented Sep 7, 2024

Great work @etrepum, this is a massive improvement to table cell merging.

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.

This is a fantastic step forward! Thank you for putting in the effort in fixing up tables!

@etrepum etrepum added this pull request to the merge queue Sep 7, 2024
Merged via the queue into facebook:main with commit 8d01b99 Sep 7, 2024
41 checks passed
@etrepum etrepum deleted the table-cell-merge branch September 7, 2024 16:13
AlessioGr added a commit to payloadcms/payload that referenced this pull request Sep 28, 2024
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 tables Relates to Lexical Tables
Projects
None yet
4 participants