Skip to content
Permalink
Browse files

added rich text key commands

  • Loading branch information
Julian Krispel-Samsel
Julian Krispel-Samsel committed Jun 16, 2017
1 parent 7c7e299 commit 16d29d7a83d5373153a99cf89139d3db44d4076a
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/App.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Editor, EditorState } from 'draft-js';
import { Editor, EditorState, RichUtils } from 'draft-js';

class App extends Component {
constructor() {
@@ -13,10 +13,22 @@ class App extends Component {
this.setState({ editorState });
};

handleKeyCommand = (command) => {
const newState = RichUtils.handleKeyCommand(this.state.editorState, command);

if (newState) {
this.onChange(newState);
return 'handled';
}

return 'not-handled';
}

render() {
return (
<Editor
editorState={this.state.editorState}
handleKeyCommand={this.handleKeyCommand}
onChange={this.onChange}
/>
);

0 comments on commit 16d29d7

Please sign in to comment.
You can’t perform that action at this time.