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] Return inserted node from $insertTableRow__EXPERIMENTAL and $insertTableColumn__EXPERIMENTAL #6741

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

amanharwara
Copy link
Contributor

@amanharwara amanharwara commented Oct 16, 2024

Description

Currently, the $insertTableRow__EXPERIMENTAL function doesn't return anything, so if you want to insert a table row using it and do something with the inserted row, you'll have to do all the calculations again to find the inserted row.
With this PR, the function will return the inserted row node if it was successful and undefined if not. This removes the need for rewriting all the logic regarding spans just to find the inserted row.
Also returns the first inserted cell from $insertTableColumn__EXPERIMENTAL

Copy link

vercel bot commented Oct 16, 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 Oct 16, 2024 2:37pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2024 2:37pm

@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 Oct 16, 2024
@amanharwara amanharwara changed the title [lexical-table] Return inserted table row node from [lexical-table] Return inserted table row node from $insertTableRow__EXPERIMENTAL Oct 16, 2024
Copy link

github-actions bot commented Oct 16, 2024

size-limit report 📦

Path Size
lexical - cjs 29.94 KB (0%)
lexical - esm 29.78 KB (0%)
@lexical/rich-text - cjs 38.51 KB (0%)
@lexical/rich-text - esm 31.58 KB (0%)
@lexical/plain-text - cjs 37.16 KB (0%)
@lexical/plain-text - esm 29 KB (0%)
@lexical/react - cjs 40.29 KB (0%)
@lexical/react - esm 33 KB (0%)

@amanharwara amanharwara changed the title [lexical-table] Return inserted table row node from $insertTableRow__EXPERIMENTAL [lexical-table] Return inserted node from $insertTableRow__EXPERIMENTAL and $insertTableColumn__EXPERIMENTAL Oct 16, 2024
@ivailop7
Copy link
Collaborator

Would this actually work the way you intend to use it though? When you insert the row, the updated state needs to be commited, before using it, so you would need to do another editor.update(), at which point you could now get the just appended node key, etc after the committed state. Maybe @etrepum could confirm if I'm right or wrong here.

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.

I think it would be perfectly reasonable to do something with the result, e.g. populate some default content into the cells. The update commit concern is only relevant if you're trying to do something with the DOM after it's rendered.

@etrepum etrepum added this pull request to the merge queue Oct 16, 2024
Merged via the queue into facebook:main with commit 790b516 Oct 16, 2024
40 of 43 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.

4 participants