Skip to content

Instantly share code, notes, and snippets.

@benbriggs
Last active March 14, 2017 16:50
Show Gist options
  • Save benbriggs/2fccaa5fda34616aa975f4286f07637f to your computer and use it in GitHub Desktop.
Save benbriggs/2fccaa5fda34616aa975f4286f07637f to your computer and use it in GitHub Desktop.
const fromHTML = convertFromHTML({...});
// within a wrapping component
handlePastedText(text, html) {
const {
editorState,
onChange
} = this.props;
const pastedContentState = fromHTML(html || text);
const updatedContentState = Modifier.replaceWithFragment(
editorState.getCurrentContent(),
editorState.getSelection(),
contentStateWithStyle.getBlockMap()
);
const updatedEditorState = EditorState.push(
editorState,
updatedContentState,
'insert-fragment'
);
onChange(updatedEditorState);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment