-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: Add keyboard shortcut help modal (#37650)
* Site Editor: Add keyboard shortcut help modal * Text formatting shortcuts * Don't use plugin to render more menu tools group * Remove fragment
- Loading branch information
Showing
13 changed files
with
459 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/edit-site/src/components/keyboard-shortcut-help-modal/config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export const textFormattingShortcuts = [ | ||
{ | ||
keyCombination: { modifier: 'primary', character: 'b' }, | ||
description: __( 'Make the selected text bold.' ), | ||
}, | ||
{ | ||
keyCombination: { modifier: 'primary', character: 'i' }, | ||
description: __( 'Make the selected text italic.' ), | ||
}, | ||
{ | ||
keyCombination: { modifier: 'primary', character: 'k' }, | ||
description: __( 'Convert the selected text into a link.' ), | ||
}, | ||
{ | ||
keyCombination: { modifier: 'primaryShift', character: 'k' }, | ||
description: __( 'Remove a link.' ), | ||
}, | ||
{ | ||
keyCombination: { modifier: 'primary', character: 'u' }, | ||
description: __( 'Underline the selected text.' ), | ||
}, | ||
]; |
41 changes: 41 additions & 0 deletions
41
packages/edit-site/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Shortcut from './shortcut'; | ||
|
||
export default function DynamicShortcut( { name } ) { | ||
const { keyCombination, description, aliases } = useSelect( | ||
( select ) => { | ||
const { | ||
getShortcutKeyCombination, | ||
getShortcutDescription, | ||
getShortcutAliases, | ||
} = select( keyboardShortcutsStore ); | ||
|
||
return { | ||
keyCombination: getShortcutKeyCombination( name ), | ||
aliases: getShortcutAliases( name ), | ||
description: getShortcutDescription( name ), | ||
}; | ||
}, | ||
[ name ] | ||
); | ||
|
||
if ( ! keyCombination ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Shortcut | ||
keyCombination={ keyCombination } | ||
description={ description } | ||
aliases={ aliases } | ||
/> | ||
); | ||
} |
Oops, something went wrong.