zenoamaro / react-quill

A Quill component for React.
https://zenoamaro.github.io/react-quill
MIT License
6.71k stars 914 forks source link

Question: Moving from Draft.js #806

Open jz222 opened 2 years ago

jz222 commented 2 years ago

Hi,

thanks for your work on this project.

I took over a project that uses Draft.js and react-draft-wysiwyg as editor. The rich text is stored as Draft.js object, which looks like so:

{
    "blocks": [
        {
            "key": "8k657",
            "text": "Some text for testing",
            "type": "unstyled",
            "depth": 0,
            "inlineStyleRanges": [],
            "entityRanges": [],
            "data": {}
        }
    ],
    "entityMap": {}
}

Is there a way to use this with react-quill or is there a way to convert it to make it compatible?

Thanks for your time.

JFMarty commented 2 years ago

I'm facing the same problem and have to migrate away from Draft.js. One option I found is via html. You can convert draftjs to html and import it into Quill with the quill.clipboard.dangerouslyPasteHTML (setQuillContentsFromHTML in react-quill) function.

But this would require some tricky handling in a interactive/ui-based migration tool (since i didn't find a serverside option), so I'm still looking for a better solution.

alexkrolick commented 2 years ago

The recommended approach to convert between editors is to use HTML as the intermediate format, unless you can figure out how to translate between the two JSON schemas.