Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
fix(SlateAsInputEditor): handle undo link removal - I272
Browse files Browse the repository at this point in the history
Signed-off-by: irmerk <[email protected]>
  • Loading branch information
jolanglinais committed Mar 10, 2020
1 parent 5d4b6ca commit b34e7b0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/SlateAsInputEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,20 @@ const SlateAsInputEditor = React.forwardRef((props, ref) => {
* @param {*} next
*/
const onKeyDown = async (event, editor, next) => {
const { onUndoOrRedo } = editor.props.editorProps;
const isEnter = () => handleEnter(event, editor, next);
const isBackSpace = () => handleBackspace(event, editor, next);
const isSpecialKey = async () => {

const isSpecialKey = () => {
switch (true) {
case isHotKey('mod+z', event) && editor.props.editorProps.onUndoOrRedo:
await editor.undo();
return editor.props.editorProps.onUndoOrRedo(editor);
case isHotKey('mod+shift+z', event) && editor.props.editorProps.onUndoOrRedo:
await editor.redo();
return editor.props.editorProps.onUndoOrRedo(editor);
case isHotKey('mod+z', event):
editor.undo();
if (onUndoOrRedo) return onUndoOrRedo(editor);
return next();
case isHotKey('mod+shift+z', event):
editor.redo();
if (onUndoOrRedo) return onUndoOrRedo(editor);
return next();
case isHotKey('mod+b', event) && isEditable(editor, CONST.FONT_BOLD):
return editor.toggleMark(CONST.FONT_BOLD);
case isHotKey('mod+i', event) && isEditable(editor, CONST.FONT_ITALIC):
Expand Down

0 comments on commit b34e7b0

Please sign in to comment.