Skip to content

danrpts/react-mdex

Repository files navigation

react-mdex

An ultralight library for building Markdown editors in React - Try it out!

NPM JavaScript Style Guide

commonmark_editor_screenshot.png

Install

npm install --save react-mdex

Usage

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>
    );
  }
}

License

MIT © danrpts

About

An ultralight library for building Markdown editors in React.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published