I can’t get the html output from draft-js?

There is a handy library I used, draft-js-export-html. Import the library and you should be able to see HTML once you invoke the function, stateToHTML: console.log(stateToHTML(this.state.editorState.getCurrentContent())); I’m pretty new to React so hopefully this works for you. I looked under the hood of contentState and there is a fair bit going on there that makes … Read more

Draft js. Persist EditorContent to database

The getPlainText() method, as its name suggests, only returns the plain text without any rich formatting. You should use the convertToRaw() and convertFromRaw() functions to serialize and deserialize the contents of the editor. You can import them this way if necessary: (assuming you are using ES6) import {convertFromRaw, convertToRaw} from ‘draft-js’; If you need to … Read more

draftjs how to initiate an editor with content

The first argument to EditorState.createWithContent is a ContentState, not a string. You need to import ContentState var EditorState = Draft.EditorState; var ContentState = Draft.ContentState; Use ContentState.createFromText And pass the result to EditorState.createWithContent. return { editorState: EditorState.createWithContent(ContentState.createFromText(‘Hello’)) };

techhipbettruvabetnorabahisbahis forumueduedusedusedusedusedusedusedueduedu