Skip to content

Commit

Permalink
Register the block editor keyboard shortcuts automatically when using…
Browse files Browse the repository at this point in the history
… BlockEditorProvider (#53910)
  • Loading branch information
youknowriad authored Aug 25, 2023
1 parent 5a77e22 commit 44a8678
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
8 changes: 7 additions & 1 deletion packages/block-editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useBlockSync from './use-block-sync';
import { store as blockEditorStore } from '../../store';
import { BlockRefsProvider } from './block-refs-provider';
import { unlock } from '../../lock-unlock';
import KeyboardShortcuts from '../keyboard-shortcuts';

/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */

Expand Down Expand Up @@ -42,7 +43,12 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(
// Syncs the entity provider with changes in the block-editor store.
useBlockSync( props );

return <BlockRefsProvider>{ children }</BlockRefsProvider>;
return (
<>
<KeyboardShortcuts.Register />
<BlockRefsProvider>{ children }</BlockRefsProvider>
</>
);
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
BlockInspector,
CopyHandler,
WritingFlow,
BlockEditorKeyboardShortcuts,
__unstableBlockSettingsMenuFirstItem,
__unstableEditorStyles as EditorStyles,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -94,7 +93,6 @@ export default function SidebarBlockEditor( {

return (
<>
<BlockEditorKeyboardShortcuts.Register />
<KeyboardShortcuts.Register />

<SidebarEditorProvider sidebar={ sidebar } settings={ settings }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
BlockList,
BlockTools,
__unstableUseClipboardHandler as useClipboardHandler,
BlockEditorKeyboardShortcuts,
store as blockEditorStore,
} from '@wordpress/block-editor';
import {
Expand Down Expand Up @@ -116,7 +115,6 @@ export default function SiteEditorCanvas() {
}
} }
>
<BlockEditorKeyboardShortcuts.Register />
<BackButton />
<ResizableEditor
enableResizing={ enableResizing }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '@wordpress/core-data';
import { useMemo } from '@wordpress/element';
import {
BlockEditorKeyboardShortcuts,
CopyHandler,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -100,7 +99,6 @@ export default function WidgetAreasBlockEditorProvider( {

return (
<ShortcutProvider>
<BlockEditorKeyboardShortcuts.Register />
<KeyboardShortcuts.Register />
<SlotFillProvider>
<ExperimentalBlockEditorProvider
Expand Down
2 changes: 0 additions & 2 deletions storybook/stories/playground/index.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { useEffect, useState } from '@wordpress/element';
import {
BlockEditorKeyboardShortcuts,
BlockEditorProvider,
BlockList,
BlockTools,
Expand Down Expand Up @@ -50,7 +49,6 @@ function App() {
<div className="playground__content">
<BlockTools>
<div className="editor-styles-wrapper">
<BlockEditorKeyboardShortcuts.Register />
<WritingFlow>
<BlockList />
</WritingFlow>
Expand Down
2 changes: 0 additions & 2 deletions test/integration/helpers/integration-test-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import userEvent from '@testing-library/user-event';
*/
import { useState, useEffect } from '@wordpress/element';
import {
BlockEditorKeyboardShortcuts,
BlockEditorProvider,
BlockList,
BlockTools,
Expand Down Expand Up @@ -78,7 +77,6 @@ export function Editor( { testBlocks, settings = {} } ) {
>
<BlockInspector />
<BlockTools>
<BlockEditorKeyboardShortcuts.Register />
<WritingFlow>
<BlockList />
</WritingFlow>
Expand Down

0 comments on commit 44a8678

Please sign in to comment.