Skip to content

Instantly share code, notes, and snippets.

@levvsha
Created June 27, 2018 10:16
Show Gist options
  • Save levvsha/48d1b95ef75b49f593f3a342cd0de934 to your computer and use it in GitHub Desktop.
Save levvsha/48d1b95ef75b49f593f3a342cd0de934 to your computer and use it in GitHub Desktop.
updateData(data) {
const editorState = this.props.blockProps.getEditorState();
const content = editorState.getCurrentContent();
const selection = new SelectionState({
anchorKey: this.props.block.key,
anchorOffset: 0,
focusKey: this.props.block.key,
focusOffset: this.props.block.getLength()
});
const newContentState = Modifier.mergeBlockData(content, selection, data);
const newEditorState = EditorState.push(editorState, newContentState);
setTimeout(() => this.props.blockProps.setEditorState(newEditorState));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment