facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
17.37k stars 1.43k forks source link

Bug: Additional paragraph inserted when pressing "Enter" within AutoLinkNode #5882

Open polyrainbow opened 2 weeks ago

polyrainbow commented 2 weeks ago

When pressing "Enter" and the cursor is within an AutoLinkNode, the link is split into two paragraphs, but there is also an empty paragraph is inserted in between. This is also reproducible in the Playground.

Lexical version: 0.14.3

Steps To Reproduce

  1. Visit playground and delete demo text
  2. Type "http://example.com"
  3. Press left arrow key to move cursor one character to the left
  4. Press "Enter"

Link to code example: https://playground.lexical.dev/

https://github.com/facebook/lexical/assets/5648131/04f1b334-e41d-4f46-94d2-2e01cbbdd52a

The current behavior

There are 3 paragraphs, because an additional empty ParagraphBlock is inserted.

The expected behavior

There should be 2 paragraphs, one with text content http://example.co, and one with text content m.