jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.41k stars 1.16k forks source link

how do i get the entered text from this editor #812

Open NiyazMulla opened 5 years ago

NiyazMulla commented 5 years ago

if i entered something in this editor how can i get the that text to upload in a local file

seth-seikosoft commented 5 years ago

You should be able to use a file stream to download the contents of the editor. I would first convert the editor state to an HTML string and then use the file stream to get that string to download into a file.

You have to use these 2 conversion packages: Libraries draftjs-to-html can be used to convert RawDraftContentState to html. html-to-draftjs provides the option to convert HTML generated by react-draft-wysiwyg back to draftJS ContentState which can be used to initialize the Editor.

https://jpuri.github.io/react-draft-wysiwyg/#/docs (scroll to the very bottom to see an example)