Skip to content

Commit

Permalink
Merge pull request draft-js-plugins#130 from draft-js-plugins/improve…
Browse files Browse the repository at this point in the history
…-handleKeyCommand

fix behaviour for custom handleKeyCommand
  • Loading branch information
nikgraf committed Mar 26, 2016
2 parents 3eacc6d + 979e9c2 commit 7c4b899
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions draft-js-plugins-editor/src/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ export default class PluginEditor extends Component {
getEditorState = () => this.editorState;

handleKeyCommand = (command) => {
let preventDefaultBehaviour = false;
if (this.props.handleKeyCommand) {
const handled = this.props.handleKeyCommand(command);
if (handled === true) {
return handled;
preventDefaultBehaviour = true;
}
}

// TODO optimize to break after the first one
let preventDefaultBehaviour = this.plugins
preventDefaultBehaviour = this.plugins
.map((plugin) => {
if (plugin.handleKeyCommand) {
const handled = plugin.handleKeyCommand(command);
Expand All @@ -140,7 +141,6 @@ export default class PluginEditor extends Component {
preventDefaultBehaviour = true;
}

// TODO allow to provide a custom handleKeyCommand
return preventDefaultBehaviour === true;
};

Expand Down

0 comments on commit 7c4b899

Please sign in to comment.