1
votes

Let's say i have draft.js editor and after editing is finished i preserved result to dataBase. I have two approaches: to save result as html string or as json object. When i use a html string from dataBase it's easy to render it using dangerouslySetInnerHTML. But how to use json object that is produced by convertToRaw draft.js method if i want to display this content not in the but in some other component? I know that i can use , but i'm not sure that this is optimize approach to show lot of on page An example of json object from draft.js

{
   blocks: [
      {
         data: {},
         depth: 0,
         entityRanges: [],
         inlineStyleRanges: [],
         key: "f25a2",
         text: "Styled string, ",
         type: "unstyled"
      }
   ],
   entityMap: {
      {
         0: {
            data: {
               url: "www.google.com",
               mutability: "MUTABLE",
               type: "LINK"
            }
         }
      }
   }
}
1

1 Answers

-3
votes

update

use draftjs and set to readonly mode

original answer

convertFromRaw and EditorState.createWithContent(state),