[lexical-playground] DatetimeNode DOM updates#7786
Merged
etrepum merged 3 commits intofacebook:mainfrom Sep 8, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Sep 1, 2025
Collaborator
etrepum
left a comment
There was a problem hiding this comment.
I didn't audit the code thoroughly to see where the dateTime can be undefined or how invalid input can occur but it's not very defensive against that sort of thing
Comment on lines
+50
to
+64
| const [includeTime, setIncludeTime] = useState(() => { | ||
| const hours = dateTime?.getHours(); | ||
| const minutes = dateTime?.getMinutes(); | ||
| return hours !== 0 || minutes !== 0; | ||
| }); | ||
| const [timeValue, setTimeValue] = useState(() => { | ||
| const hours = dateTime?.getHours(); | ||
| const minutes = dateTime?.getMinutes(); | ||
| if (hours !== 0 || minutes !== 0) { | ||
| return `${hours?.toString().padStart(2, '0')}:${minutes | ||
| ?.toString() | ||
| .padStart(2, '0')}`; | ||
| } | ||
| return '00:00'; | ||
| }); |
Collaborator
There was a problem hiding this comment.
I think these are maybe not correct for dateTime === undefined? includeTime will be true if it is undefined and timeValue will be undefined:undefined
Comment on lines
+63
to
+65
| const node = $createDateTimeNode( | ||
| new Date(Date.parse(parsed?.dat_df?.dfie_dt || '')), | ||
| ); |
Collaborator
There was a problem hiding this comment.
might be worth checking if Date.parse is NaN because those invalid date objects are weird (all of the accessors return NaN) and will also be !== 0
Collaborator
Author
|
@etrepum addressed |
etrepum
approved these changes
Sep 8, 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.
Fixes for importDOM & createDOM methods. Supports copy-pasted content from Google Docs that includes a date widget.