WordPress / gutenberg

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

Command Palette: Block actions in command center #51559

Open draganescu opened 1 year ago

draganescu commented 1 year ago

Command center is a great solution for keyboard based interaction with the block editor in all its shapes and forms.

One of the most common actions in the block editor is interacting with blocks via the controls in the toolbar and the inspector.

Consider adding commands to the command center from blocks, mirror actions of things that exist in the block toolbar and the block inspector.

For example the image block could register direct shortcuts such as "Replace from media library" or "Crop image". The navigation block could register "change to Footer Nav 2" or "delete navigation".

Some commands such as select parent or move up/down/left/right could work out of the box.

Since blocks can have many possible actions available, which could lead to crowding of the command center search results, I suggest creating a sort of global shortcut command using ":" to trigger the block commands of the currently selected block.

(We could also use other similar shortcuts like "@" for a list view in the way finder.)

The main hurdle is how to register commands from blocks. My initial thought was to use the block toolbar to auto add all registered buttons plus the default ones. But the way we extend that makes this idea inappropriate - each block would have to provide name and callback for the command too big of a rewrite.

Another way is to selectively register block by block the commands that make most sense from block definition or simply from its edit component.

I suppose a big part of this is already possible?

All the commands will work on the currently selected block(s) - so commands such as group, insert before and insert after would also make sense but these are handled separately.

These commands would work great with distraction free mode. Since the introduction of this mode we had a problem with making often used UI actions available quickly and easily without turning off the mode. Command center - given its extensible enough could solve this quite easily.

richtabor commented 1 year ago

Since blocks can have many possible actions available, which could lead to crowding of the command center search results, I suggest creating a sort of global shortcut command using ":" to trigger the block commands of the currently selected block.

I'm not so worried about crowding the commands. I suspect there will be hundreds of commands one day — and that's not a bad thing. We do have context — which surfaces the right commands in the right context; perhaps this could work as an extension of that, to suggest block commands if a block is selected when pulling up Wayfinder.

priethor commented 1 year ago

I'm not so worried about crowding the commands.

I agree with this. As long as the search functionality and discoverability are good, it shouldn't be a problem. It's like an action inserter 🙂