React-draft-wysiwyg: Issue related to display the content of the editor.

Created on 30 Jan 2017  路  16Comments  路  Source: jpuri/react-draft-wysiwyg

Hi,

Is there any attribute to hold the value(text) of the editor,if yes please suggest.Kindly help.

Thanks

Most helpful comment

to get your content for storing it in the DB
convertToRaw(this.state.editorState.getCurrentContent())
And to load your saved editorState you just assign it to the editorState:
editorState: EditorState.createWithContent(convertFromRaw(rawEditorStateFromDataBase))

All 16 comments

Hey @Srisuk , I do not get your question.

Hi,
I want to display the content in the text editor after saving the content in database and display the same content while reopening the editor.
Now we have only "Placeholder" as an attribute to display the content when we open the text editor for the first time.
So,In the same way do we have any attribute to display the fetched content from database??
Kindly help.

Thanks

@Srisuk: yes that of course works, check Controlled / Un-Controlled editor component section in docs (https://jpuri.github.io/react-draft-wysiwyg/#/docs).

Hi Jyoti,
My concern is related to display the content. I will elaborate my doubt.
I am creating a page in which when i click on a button Editor will open and i am writing some content inside an editor and then storing in database.
I am able to store the content in database but when i am opening again the editor to "edit it" i need some attribute to display the content from database.
I am using placeholder to display the content but placeholder is used only when the editor is empty so that is not a good way of doing.
So is there any other attribute like placeholder to display the content of an editor.Kindly help.
Thanks

editorState, contentState, defaultEditorState are the attributes. You can refer to example here: https://github.com/jpuri/react-draft-wysiwyg/blob/master/js/playground/index.js#L105.

editorState, contentState, defaultEditorState to store the content of the editor and send back to database n all purpose but these attributes are not used for displaying content.Like we have "value" attribute in