I am using draft-js and react-draft-wysiwyg package to show the Email editor for my application. I am able to show correct content but facing issue with Image.
Image is not displaying in editor when it is part of input HTML. Please find my below sample code.
import { Editor } from "react-draft-wysiwyg";
import {
EditorState,
ContentState,
convertFromHTML
} from "draft-js";
const htmlContentFromServer =
'<b>Bold text</b>, <i>Italic text</i><br/ ><br />' +
'<a href="https://www.facebook.com">Example link</a><br /><br/ >' +
'<img src="https://raw.githubusercontent.com/facebook/draft-js/master/examples/draft-0-10-0/convertFromHTML/image.png" height="112" width="200" />';
this.state = {
editorState: EditorState.createWithContent(
ContentState.createFromBlockArray(
convertFromHTML(
htmlContentFromServer
)
)
)
};
<Editor
editorState={this.state.editorState}
wrapperClassName="c-react-draft"
editorClassName="demo-editor"
onEditorStateChange={this.onEditorStateChange}
spellCheck={true}
wrapperId={this.props.wrapperId}
/>
I am able to display image using this solution https://codepen.io/Kiwka/pen/YNYgWa .
But above solution works only if I use Editor from 'draft-js' package but I want to use Editor from 'react-draft-wysiwyg' as with that I get Rich Toolbar options.
Need help in displaying image when it is part of HTML content in Editor from 'react-draft-wysiwyg'.