WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.23k forks source link

Calendar customization #13649

Closed ElyDotDev closed 5 years ago

ElyDotDev commented 5 years ago

Is your feature request related to a problem? Please describe. Last day I tried to add Jalali calendar to Gutenberg, using a plugin and no change to Gutenberg codebase, without any success. I want to share my thoughts about it.

Gutenberg uses moment.js for the business logic of date and time and react-dates for visual datepicker.

Changing moment.js calendar system to Jalali is not an easy task of just calling moment.locale with wp_locale data, which Gutenberg do in client-assets.php#L248-L274. A plugin should be added. But as we have no access to Gutenberg internal script equqeeing, the plugin will load too late that the initial call to moment api is before plugin enhance the moment.js to support the calendar system. So, I faced no success by adding a moment.js plugin. Even I tried to make the plugin depends on moment and be loaded just after moment, without any success.

Also, react-dates has open issues (#975, #755, #578 and #488) related to Jalali Calendar. So even if We add the plugin successfully, the final UI will have an issue that cannot be fixed using just a WordPress plugin.

So, adding a calendar system is not possible right now, I think.

Describe the solution you'd like Well, it depends on how Gutenberg wants to give the plugin developers ability to replace/enhance internal packages and modules. Currently, I found no official api to do it. It should be discussed and added to Gutenberg. The datepicker is just an example. For maximum customizability, Gutenberg should add an ability to change its modules and default block.

I'm free to make PR to add Jalali calendar to Gutenberg core, but I think It's not the optimum solution. What about Hijri calendar? Chinese? etc... The customization should be done using plugins.

Describe alternatives you've considered

youknowriad commented 5 years ago

You should be able to add your own PostSchedule component to the Document Settings or the PrePublish area.

This tutorial should help (just notice that this tutorial uses the sidebar slot, while you should probably use the PostPublishStatus info slot https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/plugin-sidebar-0/

Let me know how it goes for you.