Using the below code i am getting plaintext but i want formatted text on button click
<input onClick={() => {alert(this.state.editorState.getCurrentContent().getPlainText());}} type="submit" value="Submit" />
Using the below code i am getting plaintext but i want formatted text on button click
<input onClick={() => {alert(this.state.editorState.getCurrentContent().getPlainText());}} type="submit" value="Submit" />
This might be helpful for you: https://medium.com/@rajaraodv/how-draft-js-represents-rich-text-data-eeabb5f25cf2
You can use convertToRaw function. It returns a structured text result that you can then process as you like. The idea is — Draft.js doesn't have any assumptions about the output format so you can really fine tune your output.