Repository navigation
Added readme for keyboard shortcut #69462
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
Open
vk17-starlord
wants to merge
1
commit into
WordPress:trunk
Choose a base branch
from
vk17-starlord:keyboard-shortcut-component
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added readme for keyboard shortcut
- Loading branch information
commit cf4a5f55ba9ad693269fcda556b3019a0dd7fa9e
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
packages/block-editor/src/components/keyboard-shortcuts/Readme.md
This file contains hidden or 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,73 @@ | ||
| # Keyboard Shortcuts | ||
|
|
||
| The `KeyboardShortcuts` component registers and manages keyboard shortcuts for the block editor. It provides a comprehensive set of shortcuts for common block operations, navigation, and text selection. | ||
|
|
||
| ## Development guidelines | ||
|
|
||
| ### Usage | ||
|
|
||
| ```jsx | ||
| import { KeyboardShortcuts } from '@wordpress/block-editor'; | ||
|
|
||
| const MyBlockEditor = () => ( | ||
| <BlockEditorProvider> | ||
| <KeyboardShortcuts /> | ||
| {/* Other editor components */} | ||
| </BlockEditorProvider> | ||
| ); | ||
| ``` | ||
|
|
||
| _Note:_ The `KeyboardShortcuts` component should be rendered within a `BlockEditorProvider`. | ||
|
|
||
| ### Available Shortcuts | ||
|
|
||
| #### Block Operations | ||
| - **Copy** (`Cmd/Ctrl + C`): Copy selected block(s) | ||
| - **Cut** (`Cmd/Ctrl + X`): Cut selected block(s) | ||
| - **Paste** (`Cmd/Ctrl + V`): Paste block(s) | ||
| - **Duplicate** (`Cmd/Ctrl + Shift + D`): Duplicate selected block(s) | ||
| - **Remove** (`Cmd/Ctrl + Shift + Backspace`): Remove selected block(s) | ||
| - **Group** (`Cmd/Ctrl + G`): Create a group from selected blocks | ||
|
|
||
| #### Block Navigation | ||
| - **Insert Before** (`Cmd/Ctrl + Alt + T`): Insert block before selection | ||
| - **Insert After** (`Cmd/Ctrl + Alt + Y`): Insert block after selection | ||
| - **Move Up** (`Ctrl + T`): Move block(s) up | ||
| - **Move Down** (`Ctrl + Y`): Move block(s) down | ||
|
|
||
| #### Selection | ||
| - **Select All** (`Cmd/Ctrl + A`): Select all text/blocks | ||
| - **Clear Selection** (`Escape`): Clear current selection | ||
| - **Multi-text Selection** (`Shift + Arrow`): Select text across blocks | ||
|
|
||
| #### Global | ||
| - **Focus Toolbar** (`Alt + F10`): Navigate to nearest toolbar | ||
| - **List View Collapse** (`Alt + L`): Collapse all other items in list view | ||
|
|
||
| ### Implementation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is implementation details and I don't think it's useful in a README. |
||
|
|
||
| The component uses the WordPress keyboard shortcuts API to register shortcuts: | ||
|
|
||
| ```jsx | ||
| registerShortcut({ | ||
| name: 'core/block-editor/copy', | ||
| category: 'block', | ||
| description: __('Copy the selected block(s).'), | ||
| keyCombination: { | ||
| modifier: 'primary', | ||
| character: 'c', | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ### Categories | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same not needed. |
||
|
|
||
| Shortcuts are organized into categories: | ||
| - `block`: Block manipulation operations | ||
| - `selection`: Text and block selection | ||
| - `global`: Editor-wide actions | ||
| - `list-view`: List view specific actions | ||
|
|
||
| ## Related Components | ||
|
|
||
| Block Editor components are components that can be used to compose the UI of your block editor. They should be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid listing all the shortcuts because it might become outdated quickly.