facebook / facebook/lexical

Bug: TextNode in Token mode gets split when format is changed on portion of its text

Open
#4,167 9 comments 0 reactions 0 assignees View on GitHub
selection
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
55

Description

Lexical version: 0.9.0

## Steps To Reproduce

1. Open a modified `MentionsPlugin` example that simply uses `RichTextEditor` instead of `PlainTextEditor`
2. Create a mention node by entering `@Ham` and selecting `@Hammerhead`.
3. Select a portion of the newly created node (e.g. `mer`), press Cmd/Ctrl+B to bold the selected text
4. Observe that the node that's supposed to be a token gets incorrectly split into multiple nodes

Link to code example:

https://codesandbox.io/s/purple-river-pmc11v

## The current behavior
Applying format to a range selection does not respect boundaries of text nodes in token mode.
image

## The expected behavior
`RangeSelection`'s `formatText` method (and likely other methods) should not invoke `splitText` on "token" text nodes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.