import React from 'react' ; import BraftEditor from 'braft-editor' ; import 'braft-editor/dist/index.css' ; export default class Editor extends React . Component { state = { editorState : BraftEditor . createEditorState ( null ) , } ; async componentDidMount ( ) { const rawString = `{"blocks":[{"key":"9hu83","text":"Hello World!","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":6,"length":5,"style":"BOLD"},{"offset":6,"length":5,"style":"COLOR-F32784"}],"entityRanges":[],"data":{}}],"entityMap":{}}` ; const editorState = BraftEditor . createEditorState ( rawString ) ; this . setState ( { editorState , } ) ; } submitContent = async ( ) => { const htmlContent = this . state . editorState . toHTML ( ) ; } ; handleEditorChange = editorState => { this . setState ( { editorState , } ) ; } ; render ( ) { const { editorState } = this . state ; return ( < div > < BraftEditor value = { editorState } onChange = { this . handleEditorChange } onSave = /> < /div>); } }