Skip to content

[lexical-playground] DatetimeNode DOM updates - #7786

Merged
etrepum merged 3 commits into
meta:mainfrom
ivailop7:date_import_gdocs
Sep 8, 2025
Merged

etrepum merged 3 commits into
meta:mainfrom
ivailop7:date_import_gdocs

Conversation

@ivailop7

Copy link
Copy Markdown
Collaborator

Fixes for importDOM & createDOM methods. Supports copy-pasted content from Google Docs that includes a date widget.

@vercel

vercel Bot commented Aug 31, 2025 •

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Sep 7, 2025 10:21pm
lexical-playground Ready Ready Preview Comment Sep 7, 2025 10:21pm

@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 Aug 31, 2025
@ivailop7 ivailop7 changed the title DatetimeNode DOM updates [lexical-playground] DatetimeNode DOM updates Aug 31, 2025
@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Aug 31, 2025

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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';
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 || '')),
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

@ivailop7

ivailop7 commented Sep 7, 2025

Copy link
Copy Markdown
Collaborator Author

@etrepum addressed

@etrepum
etrepum added this pull request to the merge queue Sep 8, 2025
Merged via the queue into meta:main with commit 0feb9e9 Sep 8, 2025
This was referenced Sep 25, 2025

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 1fc2c65d Deployed Sep 7, 2025 by vercel[bot]
Preview – lexical — 1fc2c65d Deployed Sep 7, 2025 by vercel[bot]
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