I'm using react-draft-wysiwyg editor, which is built on top of Draft.js. I'm trying to figure out, how to programmatically insert HTML, like:
<h1>Hey</h1>
So far, the closest thing i got is using the insertText() method of the Modifier module. Example:
insert = ()=>{
const editorState = this.state.editorState;
const selection = editorState.getSelection();
const contentState = editorState.getCurrentContent();
const ncs = Modifier.insertText(contentState, selection, "<h1>Hey</h1>",);
const es = EditorState.push(editorState, ncs, 'insert-fragment');
this.setState({editorState: es})
}
This results in a literal string being inserted, not an HTML H1 element.
How can it be done?