An ultralight library for building Markdown editors in React - Try it out!
npm install --save react-mdex
import React, { Component } from "react";
import MarkdownIt from "markdown-it";
import { Editor, EditorState, Preview } from "react-mdex";
class BasicEditor extends Component {
constructor(props) {
super(props);
this.state = {
editorState: new EditorState()
};
this.onChange = editorState => {
this.setState({
editorState
});
};
const md = MarkdownIt();
this.renderFn = md.render.bind(md);
}
render() {
return (
<div>
<Editor editorState={this.state.editorState} onEditorStateChange={this.onChange} />
<Preview
editorState={this.state.editorState}
markdownRenderFn={this.renderFn}
/>
</div>
);
}
}
MIT © danrpts