Releases: SamyPesse/draft-js-code
Releases · SamyPesse/draft-js-code
v0.3.0
Breaking changes
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;
}
}