Skip to content

Releases: SamyPesse/draft-js-code

v0.3.0

23 Oct 13:20
c219dc5
Compare
Choose a tag to compare

Breaking changes

  • Remove code block splitting with CMD+ENTER (#21)
  • Rename handleTab to onTab (#28)

Upgrade guide

npm i --save [email protected]

If you need code block splitting in your app, you can still upgrade and then copy and paste the below code into your own app to get the behaviour back:

import { KeyBindingUtil, Modifier, EditorState } from 'draft-js';

class Editor extends React.Component {

  handleReturn = () => {
    const editorState = this.state.editorState;
    const contentState = editorState.getCurrentContent();
    const selection = editorState.getSelection();
    if (selection.isCollapsed() && KeyBindingUtil.hasCommandModifier(e)) {
      var newContentState = Modifier.splitBlock(contentState, selection);
      this.onChange(EditorState.push(editorState, newContentState, 'split-block'));
    }
    return;
  }

}