React Markdown editor with preview, built with react-markdown-renderer.
http://insidersbyte.github.io/react-markdown-editor
npm install @insidersbyte/react-markdown-editor --save
import React from 'react';
import ReactDOM from 'react-dom';
import MarkdownEditor from '@insidersbyte/react-markdown-editor';
import '@insidersbyte/react-markdown-editor/dist/css/react-markdown-editor.css';
class App extends React.Component {
constructor() {
super();
this.state = {
markdown: '# This is a H1 \n## This is a H2 \n###### This is a H6',
};
this.updateMarkdown = this.updateMarkdown.bind(this);
}
updateMarkdown(event) {
this.setState({ markdown: event.target.value });
}
render() {
return (
<MarkdownEditor
value={this.state.markdown}
onChange={this.updateMarkdown}
/>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
- value (string) - the raw markdown that will be converted to html (required)
- onChange (function) - called when a change is made (required)
- options (object) - the options for remarkable (see here) (default: { })
You can either write your own css for this component or use the one provided. If you want to write your own look at react-markdown-editor.styl for an idea on how to style this component.
Contributions are very welcome!
Please note that by submitting a pull request for this project, you agree to license your contribution under the MIT License to this project.
Published under the MIT License.