[lexical-text] Bug Fix: preserve style and detail when a text entity reverts to plain text - #8919
Open
LeSingh1 wants to merge 1 commit into
Open
[lexical-text] Bug Fix: preserve style and detail when a text entity reverts to plain text#8919LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 4, 2026 06:56
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Aug 5, 2026
Comment on lines
51
to
55
| const textNode = $createTextNode(node.getTextContent()); | ||
| textNode.setFormat(node.getFormat()); | ||
| textNode.setStyle(node.getStyle()); | ||
| textNode.setDetail(node.getDetail()); | ||
| node.replace(textNode); |
Collaborator
There was a problem hiding this comment.
You can save some code size by chaining all of this
Suggested change
| const textNode = $createTextNode(node.getTextContent()); | |
| textNode.setFormat(node.getFormat()); | |
| textNode.setStyle(node.getStyle()); | |
| textNode.setDetail(node.getDetail()); | |
| node.replace(textNode); | |
| const textNode = $createTextNode(node.getTextContent()) | |
| .setFormat(node.getFormat()) | |
| .setStyle(node.getStyle()) | |
| .setDetail(node.getDetail()); | |
| node.replace(textNode); |
…reverts to plain text
LeSingh1
force-pushed
the
fix/text-entity-preserve-style
branch
from
August 5, 2026 05:51
779a75c to
e5a2d50
Compare
Contributor
Author
|
Applied in e5a2d50 — chained, same behaviour. |
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.
Description
registerLexicalTextEntityreplaces an entity node with a plainTextNode($replaceWithSimpleText) whenever the text stops matching. It copiesformatbut notstyleordetail, so inline styling applied to an entity node is silently dropped the moment the entity breaks — a coloured hashtag loses its colour when you delete the#, keeping bold but turning black.@lexical/linkalready does this correctly when it builds the text node for an auto-link:This copies
styleanddetailas well, so the two paths agree.Test plan
Before
New unit test at
packages/lexical-text/src/__tests__/unit/registerLexicalTextEntity.test.tsfails:After
format,styleanddetailall survive the revert, verified alongsidepackages/lexical-hashtag. Full unit suite green (228 files, 4939 passed).