Skip to content

Commit

Permalink
Add undo/redo shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Jun 17, 2020
1 parent 57cf8f2 commit 592e0f5
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ function NavigationEditorShortcuts( { saveBlocks } ) {
}
);

const { redo, undo } = useDispatch( 'core' );
useShortcut(
'core/edit-navigation/undo',
( event ) => {
undo();
event.preventDefault();
},
{ bindGlobal: true }
);

useShortcut(
'core/edit-navigation/redo',
( event ) => {
redo();
event.preventDefault();
},
{ bindGlobal: true }
);

return null;
}

Expand All @@ -33,6 +52,24 @@ function RegisterNavigationEditorShortcuts() {
character: 's',
},
} );
registerShortcut( {
name: 'core/edit-navigation/undo',
category: 'global',
description: __( 'Undo your last changes.' ),
keyCombination: {
modifier: 'primary',
character: 'z',
},
} );
registerShortcut( {
name: 'core/edit-navigation/redo',
category: 'global',
description: __( 'Redo your last undo.' ),
keyCombination: {
modifier: 'primaryShift',
character: 'z',
},
} );
}, [ registerShortcut ] );

return null;
Expand Down

0 comments on commit 592e0f5

Please sign in to comment.