Skip to content

Commit

Permalink
Restore global primary+a shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 17, 2018
1 parent c729c99 commit e4f2d5f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions editor/components/editor-global-keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { first, last } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -12,12 +17,19 @@ class EditorGlobalKeyboardShortcuts extends Component {
constructor() {
super( ...arguments );

this.selectAll = this.selectAll.bind( this );
this.undoOrRedo = this.undoOrRedo.bind( this );
this.save = this.save.bind( this );
this.deleteSelectedBlocks = this.deleteSelectedBlocks.bind( this );
this.clearMultiSelection = this.clearMultiSelection.bind( this );
}

selectAll( event ) {
const { uids, onMultiSelect } = this.props;
event.preventDefault();
onMultiSelect( first( uids ), last( uids ) );
}

undoOrRedo( event ) {
const { onRedo, onUndo } = this.props;

Expand Down Expand Up @@ -52,6 +64,7 @@ class EditorGlobalKeyboardShortcuts extends Component {
const { hasMultiSelection, clearSelectedBlock } = this.props;
if ( hasMultiSelection ) {
clearSelectedBlock();
window.getSelection().removeAllRanges();
}
}

Expand All @@ -60,6 +73,7 @@ class EditorGlobalKeyboardShortcuts extends Component {
<Fragment>
<KeyboardShortcuts
shortcuts={ {
[ rawShortcut.primary( 'a' ) ]: this.selectAll,
[ rawShortcut.primary( 'z' ) ]: this.undoOrRedo,
[ rawShortcut.primaryShift( 'z' ) ]: this.undoOrRedo,
backspace: this.deleteSelectedBlocks,
Expand Down Expand Up @@ -98,6 +112,7 @@ export default compose( [
withDispatch( ( dispatch ) => {
const {
clearSelectedBlock,
multiSelect,
redo,
undo,
removeBlocks,
Expand All @@ -106,6 +121,7 @@ export default compose( [

return {
clearSelectedBlock,
onMultiSelect: multiSelect,
onRedo: redo,
onUndo: undo,
onRemove: removeBlocks,
Expand Down

0 comments on commit e4f2d5f

Please sign in to comment.