From 39addbcfb4e979134ab37fb1c747dd5e46a53c6f Mon Sep 17 00:00:00 2001 From: Ben Briggs Date: Mon, 21 May 2018 15:09:24 -0400 Subject: [PATCH] consistently pass editorState in handleKeyCommand and expect it in KeyCommandController --- src/components/Editor.js | 15 ++++++++++----- src/components/KeyCommandController.js | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/Editor.js b/src/components/Editor.js index 4dc6d26..b9aa13c 100644 --- a/src/components/Editor.js +++ b/src/components/Editor.js @@ -108,23 +108,28 @@ const EditorWrapper = createReactClass({ }, handleReturn(e) { - return (this.props.handleReturn && this.props.handleReturn(e)) || this.props.handleKeyCommand('return', e); + return (this.props.handleReturn && this.props.handleReturn(e)) || + this.props.handleKeyCommand('return', this.props.editorState, e); }, onEscape(e) { - return (this.props.onEscape && this.props.onEscape(e)) || this.props.handleKeyCommand('escape', e); + return (this.props.onEscape && this.props.onEscape(e)) || + this.props.handleKeyCommand('escape', this.props.editorState, e); }, onTab(e) { - return (this.props.onTab && this.props.onTab(e)) || this.props.handleKeyCommand('tab', e); + return (this.props.onTab && this.props.onTab(e)) || + this.props.handleKeyCommand('tab', this.props.editorState, e); }, onUpArrow(e) { - return (this.props.onUpArrow && this.props.onUpArrow(e)) || this.props.handleKeyCommand('up-arrow', e); + return (this.props.onUpArrow && this.props.onUpArrow(e)) || + this.props.handleKeyCommand('up-arrow', this.props.editorState, e); }, onDownArrow(e) { - return (this.props.onDownArrow && this.props.onDownArrow(e)) || this.props.handleKeyCommand('down-arrow', e); + return (this.props.onDownArrow && this.props.onDownArrow(e)) || + this.props.handleKeyCommand('down-arrow', this.props.editorState, e); }, focus() { diff --git a/src/components/KeyCommandController.js b/src/components/KeyCommandController.js index f5e378d..dbd83d8 100644 --- a/src/components/KeyCommandController.js +++ b/src/components/KeyCommandController.js @@ -81,7 +81,7 @@ const KeyCommandController = (Component) => createReactClass({ this.keyCommandListeners = this.keyCommandListeners.filterNot((l) => l === listener); }, - handleKeyCommand(command, keyboardEvent = null) { + handleKeyCommand(command, __editorState, keyboardEvent = null) { const {editorState, onChange, handleKeyCommand} = this.props; if (handleKeyCommand) {