React-draft-wysiwyg: When I save images in Editor then try to edit again or even view my saved data in editor, i only see camera icon not image.

Created on 9 Jul 2019  路  1Comment  路  Source: jpuri/react-draft-wysiwyg

Image after uploading file

Screenshot 2019-07-09 at 6 22 09 pm

Image when editing in Editor

Screenshot 2019-07-09 at 6 23 28 pm

More Elaborately, i'm able to save my data in my backend with img Height, Width Attributes, but when i extract my editorState with " draftToHtml(convertToRaw(editorState.getCurrentContent()))) " i get Attributes as undefined

Screenshot 2019-07-10 at 5 05 46 pm

Most helpful comment

I swapped:
convertFromHTML to htmlToDraft when retrieving the HTML and no longer get the issue.

import draftToHtml from "draftjs-to-html";


const blocksFromHTML = htmlToDraft(contentFromDB);
const state = ContentState.createFromBlockArray(blocksFromHTML.contentBlocks, blocksFromHTML.entityMap);

const [contentState, setContentState] = useState(EditorState.createWithContent(state));

>All comments

I swapped:
convertFromHTML to htmlToDraft when retrieving the HTML and no longer get the issue.

import draftToHtml from "draftjs-to-html";


const blocksFromHTML = htmlToDraft(contentFromDB);
const state = ContentState.createFromBlockArray(blocksFromHTML.contentBlocks, blocksFromHTML.entityMap);

const [contentState, setContentState] = useState(EditorState.createWithContent(state));
Was this page helpful?
0 / 5 - 0 ratings

Related issues

regisBafutwabo picture regisBafutwabo  路  3Comments

Huespal picture Huespal  路  3Comments

MaDejing picture MaDejing  路  3Comments

jpuri picture jpuri  路  4Comments

sontek picture sontek  路  4Comments