I'm using Facebook's draft-js
to create a WYSIWYG. I'm trying to convert HTML to editorState using the native convertFromHtml
. But it's not recognizing the img
tag.
import draftJs from 'draft-js'
const blocksFromHTML = convertFromHTML("<img src='some/img.png' />", draftJs.getSafeBodyFromHTML, draftJs.DefaultDraftBlockRenderMap);
const contentState = draftJs.ContentState.createFromBlockArray(blocksFromHTML);
editorState = draftJs.EditorState.createWithContent(contentState);
Doing so completely removes the image. Any ideas?
the Mikhail Khazov solution is partially correct, I had to add the img tag into the figure tag, that should solve the problem