Repository navigation
fix(6763): copy and paste with newline at the beginning - #7184
ozanilkumar23 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Hi @ozanilkumar23! 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 [email protected]. Thanks! |
etrepum
left a comment
There was a problem hiding this comment.
This does not pass the style checks (npm run ci-check; the prettier formatting and the lint against using the ?. operator), does not have any new tests to confirm that it is solving the issue, and probably fails other tests.
I did already fix this particular issue more systematically in #7155, which is waiting for review
| (!firstBlock.isEmpty() || firstBlock.canMergeWhenEmpty()); | ||
|
|
||
| const shouldInsert = !$isElementNode(firstBlock) || !firstBlock.isEmpty(); | ||
| let isFirstBlockEmpty = (firstBlock as ElementNode)?.isEmpty(); |
There was a problem hiding this comment.
The INTERNAL_$isBlock guard will also return true for a top-level decorator nodes, so casting here is not safe
| let isFirstBlockEmpty = (firstBlock as ElementNode)?.isEmpty(); | ||
| // if first block is empty check its has newline chars | ||
| if(isFirstBlockEmpty) { | ||
| const firstBlockParentContent = firstBlock?.getParent()?.getTextContent()?.split('\n') || []; |
There was a problem hiding this comment.
This is a very inefficient approach to solving this problem, as this could generally produce the textContent of the entire document just to look for a LineBreakNode. I also generally don't think it works because newlines are produced by any block ElementNode here so this would also be triggered by an empty paragraph block before the firstBlock in this selection.
edit: of course this is looking specifically for an empty paragraph, mistake in my comment above
[Lexical] : Fix duplicate content on copy and paste with newline at the beginning
Bug Fix
Description
Describe the changes in this pull request
This PR checks if the first block is empty and it has a newline char then it will call this.insertParagraph().
Closes #6763
Test plan
Before
There is no change in behavior due to the fix.
After
There is no change in behavior due to the fix.