lexical: Bug: getTextContent Removes a New Line on Rich Text Editor
Lexical version: 0.8.0
Steps To Reproduce
Basically the issue is that in rootNode.getTextContent() there’s a point where two of the same exact editor states result in two different text contents
Seems to be easy to reproduce by
1. Having at least two lines with text
Row 1
Row 2
The text content is Row1\n\nRow2
2. Add a new line between them
Row 1
Row 2
The text content is Row1\n\n\n\nRow2
3. On the 2nd line type anything
Row 1
dRow 2
The text content is Row1\n\ndRow2
Where did the two \n’s go?
Link to code example:
The current behavior
It’s possible to get two different text contents for the same editor state and it seems to remove some new lines
The expected behavior
An editor state should always return the same text content
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (2 by maintainers)
This still repros in 0.11.1
I think we can take over
Enterto fix this problem…@etrepum i wish this issue wasn’t closed, because it is still a problem over here. The @jackple code did fix the issue, and I think it shows 2 things:
\nmarkers when it should be a single one is a bug in my opinion. If we need to take over the enter command and override the event function for it to work as intended, something is wrong.Still there in 0.12.4
Not sure if it helps but you can probably fork the example I made CodeSandbox and just replace
RichTextPluginwithPlainTextPlugin