htmlreactjseditordraftjsreact-draft-wysiwyg

How to push html to draft with react-draft-wysiwyg and draft js?


I get a Html string from my API : "consigne": "<p>test</p>\n" and I want to display it on my editor.

My Editor is :

<Editor id="consigne" name= "consigne" editorState={consigne} value={draftToHtml(convertToRaw(consigne.getCurrentContent()))} onEditorStateChange={(consigne) => {this.setState({consigne})} localization={{ locale: 'fr' }}/>

I want to insert this consigne on my editor.

How I can push this consigne to my editor ?


Solution

  • I find it by this :

      this.setState({ 
    consigne:EditorState.createWithContent(ContentState.createFromBlockArray(convertFromHTML(plan.consigne))) 
        })