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

$splitNode & $insertNodeToNearestRoot for root selection #3442

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

fantactuka
Copy link
Contributor

@fantactuka fantactuka commented Nov 28, 2022

  • Update $splitNode to thrown if called on root

It's possible to keep $splitNode working with root. E.g., if we have root with 2 children, and trying to call $splitNode(root, 1), it'll return [firstRootChild, secondRootChild] without modifying (splitting) the tree. But then it means those children might be elements or decorators, so it would require API call site to check return type. Plus, there's no guarantee that there will be left or/and right tree at all since root can be empty. Supporting all of these will make $splitNode return type too vague ([null | ElementNode | DecoratorNode, null | ElementNode | DecoratorNode]) and it seems easier to handle root separately instead

  • Add root selection case for $insertNodeToNearestRoot
  • Some test utils fixes (import/export) to reduce warnings noise for unit tests
  • Add original error message to invariant stub, as otherwise errors in tests are not readable

@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 Nov 28, 2022
@vercel
Copy link

vercel bot commented Nov 28, 2022

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

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview Nov 28, 2022 at 8:08PM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Nov 28, 2022 at 8:08PM (UTC)

@fantactuka fantactuka merged commit 2694e5e into main Nov 28, 2022
@fantactuka fantactuka deleted the split-node-for-root branch November 28, 2022 20:36
@trueadm trueadm mentioned this pull request Nov 29, 2022
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