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