Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically render category keyboard shortcuts #19965

Merged
merged 3 commits into from
Feb 5, 2020

Conversation

youknowriad
Copy link
Contributor

closes #15205

In This PR, instead of listing the shortcuts to be shown in each category of the help modal, I'm update the code to automatically show the registered shortcuts of that category.

The good news is that this allows third-party plugins to register their shortcuts and they'll show up magically on that help modal. The only requirement is to choose one of these categories (block, selection, global).

Down the road, we can probably open to random categories but this is a good start I think.

The downside of this PR is that we don't control the order of the shortcuts. We could add an alphabetical order or a priority property per shortcut. But we can iterate on that.

Testing instructions

  • Register a custom shortcut like so (paste into the console):
wp.data.dispatch('core/keyboard-shortcuts').registerShortcut( {
			name: 'mynamespace/myshortcut',
			category: 'global',
			description: 'Awesome shortcut that sends spaceships to another Galaxy',
			keyCombination: {
				character: 's',
			},
		} );
  • Open the keyboard shortcuts modal, you should see the shortcut added to the right category.

@youknowriad youknowriad self-assigned this Jan 30, 2020
@youknowriad youknowriad added [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement. labels Jan 30, 2020
@gziolo
Copy link
Member

gziolo commented Jan 30, 2020

Great one. It was a lot of work to get to this stage but it is so neat how much control site owners and plugin authors get 👍

@youknowriad youknowriad force-pushed the update/automatically-render-category-shortcuts branch from d6166c4 to de1b24c Compare February 3, 2020 10:18
@youknowriad youknowriad force-pushed the update/automatically-render-category-shortcuts branch from de1b24c to 16e4a94 Compare February 5, 2020 09:34
@youknowriad youknowriad force-pushed the update/automatically-render-category-shortcuts branch from 3d11447 to 002ddb1 Compare February 5, 2020 10:13
@youknowriad youknowriad merged commit dbcaf38 into master Feb 5, 2020
@youknowriad youknowriad deleted the update/automatically-render-category-shortcuts branch February 5, 2020 10:54
@github-actions github-actions bot added this to the Gutenberg 7.5 milestone Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance KeyboardShortcuts component to automatically document 3rd party shortcuts in modal
2 participants