Skip to content

Instantly share code, notes, and snippets.

@hadijahkyampeire
Last active April 1, 2020 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadijahkyampeire/04f7be2b271d32352d91d95639166257 to your computer and use it in GitHub Desktop.
Save hadijahkyampeire/04f7be2b271d32352d91d95639166257 to your computer and use it in GitHub Desktop.
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