[lexical][lexical-clipboard][lexical-html][lexical-selection] Feature: Add an internal ephemeral node concept#7904
Merged
etrepum merged 4 commits intofacebook:mainfrom Oct 7, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…concept to deal with creating nodes in readonly editors
4c2027b to
824fef3
Compare
…k as expected now
zurfyx
approved these changes
Oct 7, 2025
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
Some of the ugly parts in JSON + HTML export are related to dealing with partially selected TextNode. This tries to clean up some of those rough edges with a new internal concept.
Ephemeral Nodes
An ephemeral node is marked with the
node[EPHEMERAL] === true(it is a symbol so is non-enumerable and won't show up with yjs). These instances always returnthisforgetLatestandgetWritableand are not allowed to be in an EditorState (which means they can not be a parent or child of some other node). You can create these with$cloneWithPropertiesEphemeral. This is mostly used to create a TextNode in a read-only context where we slice its__textbased on the selection.With this feature we can be more sure that state doesn't leak from these cloned nodes back into the EditorState, and that EditorState doesn't leak out into the accessors and mutators of the ephemeral node (e.g.
setTextContentnow works on these ephemeral nodes in a read-only editor with no errors or side-effects to the EditorState)Test plan
New unit tests, all existing e2e + unit tests should pass