Skip to content

[lexical-utils][lexical-playground] Feature: Add $insertNodeIntoLeaf and insert deeply DateTimeNode#8206

Merged
etrepum merged 4 commits intofacebook:mainfrom
levensta:insert-datetime-to-leaf
Mar 13, 2026
Merged

[lexical-utils][lexical-playground] Feature: Add $insertNodeIntoLeaf and insert deeply DateTimeNode#8206
etrepum merged 4 commits intofacebook:mainfrom
levensta:insert-datetime-to-leaf

Conversation

@levensta
Copy link
Contributor

Description

Added $insertNodeIntoLeaf function to insert a node into the outermost leaf node. An example of how to use this function can be seen when inserting DateTimeNode into lexical-playground

Test plan

Before

Inserting DateTime into a link split it into two nodes, and DateTime does not become part of the link. Also, inserting DateTime does not take into account the text format. To select DateTime in a link and apply a format to it, you have to select it again

Screen.Recording.2026-03-11.at.02.05.42.mov

After

DateTime is inserted into the link and becomes part of it. If you enter formatted text, the subsequent insertion of DateTime will preserve the preceding format

Screen.Recording.2026-03-11.at.02.03.23.mov

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Mar 12, 2026 1:07am
lexical-playground Ready Ready Preview, Comment Mar 12, 2026 1:07am

Request Review

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 10, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 11, 2026
@@ -47,7 +51,11 @@ export default function DateTimePlugin(): JSX.Element | null {
const {dateTime} = payload;
const dateTimeNode = $createDateTimeNode(dateTime);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be simpler and probably more accurate to pick up the selection's format rather than only a bordering TextNode on insert. It's possible to insert a DateTimeNode into an empty ParagraphNode after changing the desired format but before entering any other text.

Co-authored-by: Bob Ippolito <bob@redivi.com>
@etrepum etrepum added this pull request to the merge queue Mar 13, 2026
Merged via the queue into facebook:main with commit e6a7fd3 Mar 13, 2026
37 checks passed
@etrepum etrepum mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants