From f2e1addd23808edd08c993c7631258367c40ae1c Mon Sep 17 00:00:00 2001 From: Eve Essex Date: Tue, 12 Sep 2017 12:29:48 -0400 Subject: [PATCH 1/2] expose right and left arrow keyboard events --- src/component/base/DraftEditorProps.js | 2 ++ src/component/handlers/edit/editOnKeyDown.js | 6 ++++++ 2 files changed, 8 insertions(+) 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)) { From ff66bf46f99a72bb3dc1dc65f15b553f4cb03927 Mon Sep 17 00:00:00 2001 From: Eve Essex Date: Tue, 12 Sep 2017 12:32:17 -0400 Subject: [PATCH 2/2] update readme --- docs/APIReference-Editor.md | 11 +++++++++++ 1 file changed, 11 insertions(+) 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