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 insertNodes insert position at start of inline ElementNode #5110

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

zurfyx
Copy link
Member

@zurfyx zurfyx commented Oct 10, 2023

insertNodes does too much...

insertNodes is a function that's able to insert N amount of nodes and fixed the hierarchy accordingly.

In #1996 we determined that insertNodes [x, y, z] where y is an ElementNode should never be merged into z. That makes sense, from a user PoV these are 3 separate nodes (an array) and you'd want them one next to the other.

However, when you insertNodes from a paste PoV, if your target is non-empty ElementNode you'd want to insertBefore the Element. For example, insertNodes[$createLineBreakNode()] with the aforementioned target should prepend it on the list of nodes.

Where do we draw the line? We don't, we reduce insertNodes responsibilities. We can assume that the first node's target can be treated as merge with the current hierarchy, whereas targets for subsequent node's should always be appended.

Screen.Recording.2023-10-10.at.3.54.44.PM.mov

Closes #4172

@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 10, 2023
@vercel
Copy link

vercel bot commented Oct 10, 2023

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

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview Oct 10, 2023 7:56pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2023 7:56pm

@github-actions
Copy link

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 28.28 KB (+0.03% 🔺) 566 ms (+0.03% 🔺) 81 ms (+2.26% 🔺) 646 ms
packages/lexical-rich-text/dist/LexicalRichText.js 39.58 KB (+0.03% 🔺) 792 ms (+0.03% 🔺) 90 ms (-11.74% 🔽) 881 ms
packages/lexical-plain-text/dist/LexicalPlainText.js 39.55 KB (+0.02% 🔺) 792 ms (+0.02% 🔺) 66 ms (+3.98% 🔺) 857 ms

@fantactuka fantactuka merged commit bde5c5d into main Oct 11, 2023
44 of 45 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.

Bug: Can't insert linebreak before link if line starts with link
3 participants