Skip to content
Snippets Groups Projects
editorStateManagment.ts 356 B
Newer Older
  • Learn to ignore specific revisions
  • import { EditorState, ContentState } from 'draft-js'
    import htmlToDraft from 'html-to-draftjs'
    
    
    export const convertStringToEditorState = (string: string): EditorState => {
    
      const { contentBlocks, entityMap } = htmlToDraft(string)
      const state = ContentState.createFromBlockArray(contentBlocks, entityMap)
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      return EditorState.createWithContent(state)