Skip to content

[lexical-playground] DateTime Plugin#7707

Merged
etrepum merged 18 commits intofacebook:mainfrom
ivailop7:date_plugin
Aug 6, 2025
Merged

[lexical-playground] DateTime Plugin#7707
etrepum merged 18 commits intofacebook:mainfrom
ivailop7:date_plugin

Conversation

@ivailop7
Copy link
Copy Markdown
Collaborator

@ivailop7 ivailop7 commented Jul 20, 2025

Add DateTime Plugin with typeahead completions for 'Date', 'Today', 'Tomorrow', 'Yesterday'.

The popover rendering positioning respects the widget positioning and where it is relative to the edges.
If a time is added to widget, it defaults to the user's browser local time zone. In the future someone else can extend it further to support timezone selection using 'tzdb'.

Screen.Recording.2025-08-04.at.20.59.41.mov
  • Doesn't support text formatting

@vercel
Copy link
Copy Markdown

vercel bot commented Jul 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 2:46pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 2:46pm

@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 Jul 20, 2025
@ivailop7
Copy link
Copy Markdown
Collaborator Author

@etrepum Would you know why marking the decorator node as inline does not actually work? Something is off with the selection bit.

@etrepum
Copy link
Copy Markdown
Collaborator

etrepum commented Jul 21, 2025

I don't think it works inline because of the css, divs are display: block by default. The node itself is inline from lexical's perspective, it's more of a rendering concern.

To make it work with formatting you could make it not a decorator, it could be a TextNode subclass, although we don't currently have a selection/navigation mode by default that would treat a 'token' node as one unit as far as keyboard and pointer selection is concerned (I don't know how meta is using token mode, but maybe we could just fix that, or add a method or plugin to change that behavior for some or all token TextNode).

@ivailop7
Copy link
Copy Markdown
Collaborator Author

I don't think it works inline because of the css, divs are display: block by default. The node itself is inline from lexical's perspective, it's more of a rendering concern.

To make it work with formatting you could make it not a decorator, it could be a TextNode subclass, although we don't currently have a selection/navigation mode by default that would treat a 'token' node as one unit as far as keyboard and pointer selection is concerned (I don't know how meta is using token mode, but maybe we could just fix that, or add a method or plugin to change that behavior for some or all token TextNode).

I started with Element node initially, but the decorator just allowed for nice isolation of the component code with all the event listeners. I do agree, the node is closer to a mention or a hashtag with just a 'onclick' behaviour. I'll look into the CSS. Maybe we can get @zurfyx or @fantactuka to help with the 'token' part?

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

I didn't spend any time looking at the UI but I can see that the DateTimeNode implementation has some bugs with serialization and possibly collab that should be straightforward to fix by switching from an explicit property to NodeState.

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Almost there, still doesn't quite deserialize correctly (never parses from string, which it will be after JSON) and there's a type error

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Looks good, assuming the tests will pass after that explicit serialization. This is a good demo of using a more exotic type with NodeState and collab which was very hard to do correctly before

@etrepum etrepum added this pull request to the merge queue Aug 6, 2025
Merged via the queue into facebook:main with commit d9a4ecb Aug 6, 2025
39 checks passed
@etrepum etrepum mentioned this pull request Aug 7, 2025
@vadimkantorov
Copy link
Copy Markdown

vadimkantorov commented Aug 11, 2025

Just for information, here is the Clipboard HTML from Google Docs' @Today element:

<meta charset="utf-8">
<b style="font-weight:normal;" id="docs-internal-guid-8ead19bd-7fff-859b-a6a8-bd93d5d97918">
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;">
<span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;" data-rich-links="{&quot;dat_df&quot;:{&quot;fres_frt&quot;:1,&quot;dfie_ts&quot;:{&quot;tv&quot;:{&quot;tv_s&quot;:1754913600,&quot;tv_n&quot;:0}},&quot;dfie_l&quot;:&quot;en&quot;,&quot;dfie_p&quot;:{&quot;fres_frt&quot;:0,&quot;tres_tv&quot;:&quot;MMM d, y&quot;},&quot;dfie_dt&quot;:&quot;Aug 11, 2025&quot;,&quot;dfie_pt&quot;:3,&quot;dfie_tpt&quot;:0,&quot;dfie_tzi&quot;:&quot;&quot;},&quot;type&quot;:&quot;date&quot;}">Aug 11, 2025</span>
</p>
</b>
<br class="Apple-interchange-newline">

Will now Lexical be able to paste this HTML as DateTime Node?

Ha-ha, I'm still sad, no-one actually uses <time> for representing datetime semantics :)

@ivailop7
Copy link
Copy Markdown
Collaborator Author

Just for information, here is the Clipboard HTML from Google Docs' @Today element:

<meta charset="utf-8">

<b style="font-weight:normal;" id="docs-internal-guid-8ead19bd-7fff-859b-a6a8-bd93d5d97918">

<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;">

<span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;" data-rich-links="{&quot;dat_df&quot;:{&quot;fres_frt&quot;:1,&quot;dfie_ts&quot;:{&quot;tv&quot;:{&quot;tv_s&quot;:1754913600,&quot;tv_n&quot;:0}},&quot;dfie_l&quot;:&quot;en&quot;,&quot;dfie_p&quot;:{&quot;fres_frt&quot;:0,&quot;tres_tv&quot;:&quot;MMM d, y&quot;},&quot;dfie_dt&quot;:&quot;Aug 11, 2025&quot;,&quot;dfie_pt&quot;:3,&quot;dfie_tpt&quot;:0,&quot;dfie_tzi&quot;:&quot;&quot;},&quot;type&quot;:&quot;date&quot;}">Aug 11, 2025</span>

</p>

</b>

<br class="Apple-interchange-newline">

Will now Lexical be able to paste this HTML as DateTime Node?

Ha-ha, I'm still sad, no-one actually uses <time> for representing datetime semantics :)

I'm currently on holidays. If you raise the PR, I'd be more than happy to review and merge 😃.

@ivailop7 ivailop7 deleted the date_plugin branch August 31, 2025 21:02
GermanJablo added a commit to payloadcms/payload that referenced this pull request Sep 3, 2025
Fixes #13386

Below I write a clarification to copy and paste into the release note,
based on our latest upgrade of Lexical [in
v3.29.0](https://github.com/payloadcms/payload/releases/tag/v3.29.0).

## Important
This release upgrades the lexical dependency from 0.28.0 to 0.34.0.

If you installed lexical manually, update it to 0.34.0. Installing
lexical manually is not recommended, as it may break between updates,
and our re-exported versions should be used. See the [yellow banner
box](https://payloadcms.com/docs/rich-text/custom-features) for details.

If you still encounter richtext-lexical errors, do the following, in
this order:

- Delete node_modules
- Delete your lockfile (e.g. pnpm-lock.json)
- Reinstall your dependencies (e.g. pnpm install)

### Lexical Breaking Changes

The following Lexical releases describe breaking changes. We recommend
reading them if you're using Lexical APIs directly
(`@payloadcms/richtext-lexical/lexical/*`).

- [v.0.33.0](https://github.com/facebook/lexical/releases/tag/v0.33.0)
- [v.0.30.0](https://github.com/facebook/lexical/releases/tag/v0.30.0)
- [v.0.29.0](https://github.com/facebook/lexical/releases/tag/v0.29.0)

___

TODO:
- [x] facebook/lexical#7719
- [x] facebook/lexical#7362
- [x] facebook/lexical#7707
- [x] facebook/lexical#7388
- [x] facebook/lexical#7357
- [x] facebook/lexical#7352
- [x] facebook/lexical#7472
- [x] facebook/lexical#7556
- [x] facebook/lexical#7417
- [x] facebook/lexical#1036
- [x] facebook/lexical#7509
- [x] facebook/lexical#7693
- [x] facebook/lexical#7408
- [x] facebook/lexical#7450
- [x] facebook/lexical#7415
- [x] facebook/lexical#7368
- [x] facebook/lexical#7372
- [x] facebook/lexical#7572
- [x] facebook/lexical#7558
- [x] facebook/lexical#7613
- [x] facebook/lexical#7405
- [x] facebook/lexical#7420
- [x] facebook/lexical#7662

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1211202581885926
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.

3 participants