sstur / react-rte

Pure React rich text WYSIWYG editor based on draft-js.
https://react-rte.org
ISC License
2.86k stars 429 forks source link

Fetching the RichTextEditor value. #245

Open imparvez opened 6 years ago

imparvez commented 6 years ago

While creating a dashboard in ReactJS, I used react-rte in few rich text editor based component. I am successfully sending the value in HTML format to my API with the help of value.toString('html'). Now once the value is saved from the dashboard and got updated in API too, if I again go to the same page, the text editor should be pre-filled with what is during an UPDATE operation. I want to know how I can achieve this, how can I pre-filled this rich text editor section while accessing saved data.

onTextEditorChange = (value) => { this.setState({ value }); if (this.props.onTextEditorChange) { this.props.onTextEditorChange( value.toString('html') ); } };

<RichTextEditor value={this.state.value} onChange={this.onTextEditorChange} />

robertvitoriano commented 3 years ago

Have you solved it ? I have the very same situation here

i-am-waseem commented 2 years ago

For anyone who is still searching for the solution. Try the following:

setEditorValue( RichTextEditor.createValueFromString( response.data.organization.org_description, "html" )