Last active
April 1, 2020 10:14
-
-
Save hadijahkyampeire/04f7be2b271d32352d91d95639166257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { EditorState } from 'draft-js'; | |
import { Editor } from 'react-draft-wysiwyg'; | |
class MyEditor extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
editorState: EditorState.createEmpty() | |
}; | |
} | |
onEditorStateChange = editorState => { | |
this.setState({ | |
editorState | |
}); | |
}; | |
render() { | |
const { editorState } = this.state; | |
return ( | |
<div> | |
<Editor | |
editorState={editorState} | |
wrapperClassName="rich-editor demo-wrapper" | |
editorClassName="demo-editor" | |
onEditorStateChange={this.onEditorStateChange} | |
placeholder="The message goes here..." | |
/> | |
{/*new code: adding a bootstrap button and preview div, remember to remove these comments*/ } | |
<h4>Underlying HTML</h4> | |
<div className="html-view"> | |
... | |
</div> | |
<button className="btn btn-success" data-toggle="modal" data-target="#previewModal"> | |
Preview message | |
</button> | |
{/* end of new code*/ } | |
</div> | |
); | |
} | |
} | |
export { MyEditor }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment