question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: In an editable EditorState after Parsed, typing will create a new TextNode instead of continuing with the last TextNode

See original GitHub issue

Lexical version: 0.3.6

Steps To Reproduce

With TextNode

  1. Refresh browser in code sandbox link
  2. Editor should AutoFocus
  3. type anything, see in TreeView that a new TextNode was created Screen Shot 2022-06-30 at 11 40 06 AM

With AutoLinkNode

  1. Uncomment SerializedAutoLinkNode json in state
  2. Refresh browser in code sandbox link
  3. Editor should AutoFocus
  4. type m to complete the link, see in TreeView that a new TextNode with m was created, and AutoLinkNode was destructed Screen Shot 2022-06-30 at 11 44 31 AM

Link to code example:

https://codesandbox.io/s/lexical-plain-text-example-forked-t3cgjf?file=/src/Editor.js

The current behavior

  • On fresh parsing, editor won’t consider the last TextNode, will blindly create a new TextNode and won’t merge it with its predecessor

The expected behavior

  • The last TextNode should be open for edit, new input should be considered part of that TextNode
  • AutoLinkNode shouldn’t collapse, it should take new input as part of its child TextNode

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fantactukacommented, Jun 30, 2022

Yeah, I guess once state is serialized you can recursively run through the tree to cleanup unused fields, and once it loaded for to be passed into editor do same, but to populate default values. I want to hear more from other folks whether they can think of any downsides of supporting missed fields and using default values before doing this change

0reactions
ProvidenceXzcommented, Jun 30, 2022

That’s exactly what I’ve been doing. Look forward to the resolution 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Doc's TextNode goes as a content to the wrong node - Discuss
Now this is how i parse the initial content and i create the doc that will be passed to the editor's view state...
Read more >
handler function never given text node · Issue #525 - GitHub
I have installed a handleClickOn prop. Here is the problem: whenever I click any of the words, the node argument given to the...
Read more >
ProseMirror Changelog
Work around a Safari bug where it draws the cursor at the start of the line when it is after an uneditable node...
Read more >
JavaScript TextNode update - dom - Stack Overflow
I would like to change the text inside the parent without using removeChild , createTextNode and appendChild . Why would I need this...
Read more >
Reference Manual - CodeMirror
To update a state, you create a transaction, which produces a new state ... character offset when it is a text node) at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found