[lexical] Bug Fix: Preserve pasted blocks after consecutive line breaks - #8890
[lexical] Bug Fix: Preserve pasted blocks after consecutive line breaks#8890wanxiankai wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @wanxiankai! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
etrepum
left a comment
There was a problem hiding this comment.
The cursor ends up in the wrong location after pasting
## Description Treat consecutive soft line breaks as a block boundary when inserting blocks so pasted blocks do not merge into either side of the surrounding paragraph. This preserves block formatting and leaves the cursor at the end of the pasted content. Closes facebook#4815 ## Test plan ### Before Issue4815Repro.test.ts fails because the heading is merged into the surrounding paragraph or the final pasted paragraph is merged with the original trailing text, moving the cursor to the wrong location. ### After Issue4815Repro.test.ts passes, preserving both pasted block boundaries, the pasted-content selection, and the existing single-line-break merge behavior.
7367e5f to
1edace8
Compare
|
Thanks for catching this. I reproduced it with the playground state from #4815. The previous version only prevented the first pasted block from merging into the left side; the final pasted paragraph could still merge with the original trailing content, so the block boundary and cursor result were incomplete. Updated in
The regression test now asserts the four resulting blocks ( |
Description
Pasting multiple blocks after two consecutive soft line breaks currently merges the first pasted block into the surrounding paragraph. This drops block semantics, such as a heading's tag.
Treat consecutive soft line breaks as a block boundary so the first pasted block retains its type. The selection remains at the end of the pasted content, before the original trailing text.
Closes #4815
Test plan
Before
Issue4815Repro.test.tsfails because the heading is merged into the surrounding paragraph.After
Issue4815Repro.test.tspasses, preserving the heading block and selection. A second assertion confirms the existing single-line-break merge behavior is unchanged.