Last active
March 14, 2017 16:50
-
-
Save benbriggs/2fccaa5fda34616aa975f4286f07637f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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