[lexical] Bug Fix: Preserve paragraph alignment when pasting#8102
[lexical] Bug Fix: Preserve paragraph alignment when pasting#8102aldoprogrammer wants to merge 7 commits intofacebook:mainfrom
Conversation
… clipboard handling.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…paragraph node validation in JSON export
…ethod for better readability and maintainability
etrepum
left a comment
There was a problem hiding this comment.
This needs a closer look from someone to come up with a better suggestion, but I don't think this is the right approach to solve this problem
etrepum
left a comment
There was a problem hiding this comment.
The logic for this one still doesn't seem right, any transformation to the JSON should be happening during export rather than after
…node types and adding a new method to extract child nodes based on selection. This improves flexibility in handling different node formats.
etrepum
left a comment
There was a problem hiding this comment.
This looks like the right approach! There are merge conflicts with the tests that need to be resolved before it can be approved
…paragraph-alignment-8101 # Conflicts: # packages/lexical/src/nodes/__tests__/unit/LexicalParagraphNode.test.ts
On further checks discovered some unexpected behavior when copying partial paragraphs
etrepum
left a comment
There was a problem hiding this comment.
This has unexpected behavior when copying partial paragraphs
Screen.Recording.2026-02-06.at.11.29.09.mov
| ): boolean { | ||
| const formatType = this.getFormatType(); | ||
| return formatType !== '' && formatType !== 'left' && formatType !== 'start'; | ||
| } |
There was a problem hiding this comment.
I just did some final checks here and the problem with this approach is that it doesn't verify that the entire paragraph is selected when preserving the alignment. It's unexpected behavior to copy part of a paragraph and then on paste discover that it creates a new paragraph instead of just copying that text.
Description
Fixes paste alignment loss when copying from non-left aligned paragraphs. Covers both full paragraph and text-only selection; pasted content retains original alignment.Tests added for HTML/JSON paste and copy/paste scenarios.
Closes #8101
Test plan
Before
Can't persist the alignment copied text
After
Demo