Repository navigation
[lexical] Bug Fix: more accurate line break pasting - #6395
Merged
Merged
Conversation
potatowagon
requested review from
Fetz,
Sahejkm,
acywatson,
fantactuka,
ivailop7 and
zurfyx
as code owners
July 12, 2024 07:02
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
potatowagon
marked this pull request as draft
July 12, 2024 07:15
potatowagon
marked this pull request as ready for review
July 12, 2024 07:33
ivailop7
approved these changes
Jul 12, 2024
2wheeh
pushed a commit
to 2wheeh/lexical
that referenced
this pull request
Jul 17, 2024
potatowagon
added a commit
to potatowagon/lexical
that referenced
this pull request
Jun 30, 2026
…naged line breaks Follow-up to meta#8750 implementing @etrepum's approach from meta#7600. meta#6395 dropped every trailing <br> in a block on import to match HTML's non-rendering behavior, but that loses authored trailing breaks on round-trip serialization. meta#8750 narrowed the drop to Safari's Apple-interchange-newline clipboard artifact, but that gate doesn't fire for ordinary structural/authored trailing breaks (or non-Safari pastes), so the phantom-blank-line regression persists for those. Instead, drop a trailing <br> only when it is a *managed* line break: - data-lexical-managed-linebreak="true": the terminator Lexical's reconciler already injects via LexicalDOMSlot.setManagedLineBreak, so re-importing Lexical's own exported HTML stays idempotent. - class="Apple-interchange-newline": Safari's clipboard transport artifact. An ordinary authored trailing <br> carries neither marker and is now preserved, so round-trip serialization to HTML is lossless while rendering of external pasted HTML stays faithful. Browser-agnostic for the Lexical-managed case. Applies the same gate to both LineBreakNode.importDOM and the @lexical/html coreImportRules LineBreakRule. Adds test coverage for the preserved / managed / Apple-interchange cases.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve br pasting
<p>. fixes extra br in<li>pasteTest plan
Before
After
before
after