diff --git a/docs/APIReference-Editor.md b/docs/APIReference-Editor.md index 76dc54f966..190430f23a 100644 --- a/docs/APIReference-Editor.md +++ b/docs/APIReference-Editor.md @@ -245,10 +245,21 @@ onTab?: (e: SyntheticKeyboardEvent) => void onUpArrow?: (e: SyntheticKeyboardEvent) => void ``` +#### onRightArrow +``` +onRightArrow?: (e: SyntheticKeyboardEvent) => void +``` + #### onDownArrow ``` onDownArrow?: (e: SyntheticKeyboardEvent) => void ``` + +#### onLeftArrow +``` +onLeftArrow?: (e: SyntheticKeyboardEvent) => void +``` + ### Mouse events ### onFocus diff --git a/src/component/base/DraftEditorProps.js b/src/component/base/DraftEditorProps.js index 9b5d1f6852..0631fa58f6 100644 --- a/src/component/base/DraftEditorProps.js +++ b/src/component/base/DraftEditorProps.js @@ -156,7 +156,9 @@ export type DraftEditorProps = { onEscape?: (e: SyntheticKeyboardEvent<>) => void, onTab?: (e: SyntheticKeyboardEvent<>) => void, onUpArrow?: (e: SyntheticKeyboardEvent<>) => void, + onRightArrow?: (e: SyntheticKeyboardEvent<>) => void, onDownArrow?: (e: SyntheticKeyboardEvent<>) => void, + onLeftArrow?: (e: SyntheticKeyboardEvent<>) => void, onBlur?: (e: SyntheticEvent<>) => void, onFocus?: (e: SyntheticEvent<>) => void, diff --git a/src/component/handlers/edit/editOnKeyDown.js b/src/component/handlers/edit/editOnKeyDown.js index 1e95d6068f..4cb1698e64 100644 --- a/src/component/handlers/edit/editOnKeyDown.js +++ b/src/component/handlers/edit/editOnKeyDown.js @@ -109,9 +109,15 @@ function editOnKeyDown(editor: DraftEditor, e: SyntheticKeyboardEvent<>): void { case Keys.UP: editor.props.onUpArrow && editor.props.onUpArrow(e); return; + case Keys.RIGHT: + editor.props.onRightArrow && editor.props.onRightArrow(e); + return; case Keys.DOWN: editor.props.onDownArrow && editor.props.onDownArrow(e); return; + case Keys.LEFT: + editor.props.onLeftArrow && editor.props.onLeftArrow(e); + return; case Keys.SPACE: // Handling for OSX where option + space scrolls. if (isChrome && isOptionKeyCommand(e)) {