Core Commands: Introduce new useCommands hook#71603
Conversation
|
Size Change: +51 B (0%) Total Size: 1.94 MB
ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
youknowriad
left a comment
There was a problem hiding this comment.
This works for me.
I believe ultimately we need to move to a command palette powered by abilities to unify shortcuts/commands and AI but for the existing API, I think this is a nice addition.
|
Thanks for the review!
I agree, I don't have any idea yet on how to integrate the Commald Palette and the Abilities API, but I'd like to try to work on that in the feature. |
|
Flaky tests detected in c2fd175. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17640267452
|
* Core Commands: Introduce new useCommands hook * Add example Co-authored-by: t-hamano <[email protected]> Co-authored-by: youknowriad <[email protected]>
What?
This PR proposes to introduce a new
useCommandshook.Why?
The
useCommandhook (widthouts) can only be used to register a single static command. Therefore, registering multiple static commands is a bit tedious - consumers have to use the "useCommandLoader" hook even though all the commands are static.How?
Introduces the new
useCommandshook that allows consumers to register multiple static commands at once. Additionally, I refactored the code that registers menu commands with this new hook.I'd love to hear your feedback on whether you find this new hook useful.
Testing Instructions
Commands based on the Menu API are now registered via this new hook, so make sure "Go to: ..." commands still works as before.