WordPress / gutenberg

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

Command Palette: add command to open fonts #54880

Open annezazu opened 1 year ago

annezazu commented 1 year ago

Pulled from the FSE Outreach Program's Final Touches call for testing:

I clicked the “Aa” icon to open up font management just because I followed your instructions, but I couldn’t have found the font management easily without them. I love icons, but this is only visible with a label. I guess this is by design. I can’t wait for a font’s library command.

In checking, there is not a command in place for opening the font management and it seems wise to add in. At the minimum, a "Open font management" command, similar to "Open styles".

Screenshot 2023-09-27 at 10 03 17 AM
richtabor commented 1 year ago

I would expect this command would available in the Site Editor, opening the Styles > Typography panel, with the Fonts modal open.

CleanShot 2023-09-28 at 12 50 46 CleanShot 2023-09-28 at 12 49 25
jordesign commented 10 months ago

@annezazu It strikes me that if the Font Library is going to land in 6.5 - that this would be a good one to squeeze in as well.

annezazu commented 10 months ago

Agreed! @mikachan & @matiasbenedetto for consideration.

matiasbenedetto commented 10 months ago

Thanks for the ping. It would be very nice to add this :+1:

mikachan commented 10 months ago

Agreed, this would be a super cool addition!

carolinan commented 10 months ago

I had a try at this, but was unable to find a way to open not only the modal, but also the typography panel.

In comparison, (simplified) the custom CSS, stylebook and preference modal commands work because these are separate screens with their own paths.

mikachan commented 10 months ago

Thanks for taking a look at this, @carolinan. Maybe we need to use a different kind of trigger to open the Font Library modal, something that's more similar to the preference modal. (I say all this without looking into the details yet.)

t-hamano commented 10 months ago

Just to be sure, is this command expected to open the Font Library modal itself, rather than opening the Global Styles typography panel? If so, I think we need to manage the modal's state with a datastore. I'm testing it with #58350.

mikachan commented 10 months ago

is this command expected to open the Font Library modal itself, rather than opening the Global Styles typography panel?

Yes, I think opening the modal makes the most sense. Thanks for testing a solution for this! Managing the modal's state with the datastore sounds like a good step forward.

carolinan commented 10 months ago

I think it should do both.

t-hamano commented 10 months ago

I think it should do both.

After some simple hacking and testing of existing command actions, it seems possible to open the Typograph panel with a command action.

I would like to proceed with #58350.

Diff ```diff diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 3abd1c811f..c59c7caee3 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -246,6 +246,9 @@ function GlobalStylesEditorCanvasContainerLink() { case 'global-styles-revisions:style-book': goTo( '/revisions' ); break; + case 'global-styles-typograpy': + goTo( '/typography' ); + break; case 'global-styles-css': goTo( '/css' ); break; diff --git a/packages/edit-site/src/hooks/commands/use-common-commands.js b/packages/edit-site/src/hooks/commands/use-common-commands.js index fdea50d8af..e61365572d 100644 --- a/packages/edit-site/src/hooks/commands/use-common-commands.js +++ b/packages/edit-site/src/hooks/commands/use-common-commands.js @@ -202,8 +202,8 @@ function useGlobalStylesOpenCssCommands() { return [ { - name: 'core/edit-site/open-styles-css', - label: __( 'Customize CSS' ), + name: 'core/edit-site/open-font-library-modal', + label: __( 'Open font library' ), icon: brush, callback: ( { close } ) => { close(); @@ -217,7 +217,7 @@ function useGlobalStylesOpenCssCommands() { setCanvasMode( 'edit' ); } openGeneralSidebar( 'edit-site/global-styles' ); - setEditorCanvasContainerView( 'global-styles-css' ); + setEditorCanvasContainerView( 'global-styles-typograpy' ); }, }, ]; ```

https://github.com/WordPress/gutenberg/assets/54422211/81b76803-2979-47ea-9ca6-07a8d6d474ae

richtabor commented 10 months ago

I think it should do both.

Agreed.

t-hamano commented 10 months ago

As seen in https://github.com/WordPress/gutenberg/pull/58350#discussion_r1470690520, refactoring (removing) the context is necessary to move this issue forward.

I have submitted https://github.com/WordPress/gutenberg/issues/58428, but if anyone is interested, please join.

t-hamano commented 9 months ago

In order to add the command using the ideal approach, #58428 would need to be resolved first. This command is not originally on the roadmap and I don't think it's essential to include it in WP6.5, so I'll punt it to 6.6.

NekoJonez commented 9 months ago

Today I was playing around looking for the modal in 6.5 beta 2 ... And I didn't easily find it. Now, does this mean that the font library is only here for FSE themes? Is it ever coming to non FSE themes?

Also, I expected it to be in the block options but don't know if that's the best idea.

colorful-tones commented 6 months ago

Hi folks, We are only one week away from the Beta 1 cut-off date for WordPress 6.6. This issue hasn’t seen any movement in a while, so we (the editor triage leads of the 6.6 release) have decided to remove it from the WordPress 6.6 Editor Tasks project board.