Markdown draft.js
Markdown editor framework that works with an immutable state and utility functions to modify it.
Live demo here!
Install
Use it as an npm package:
npm install md-draft-js --save
Usage
import React from 'react';import ReactDOM from 'react-dom';import Editor EditorState from 'md-draft-js'; Component { ; thisstate = editorState: EditorState ; this this; } { return <Editor = = /> ; } ReactDOM;
Handling keys
// ...import Editor EditorState RichUtils from 'md-draft-js'; Component /// ... { const newState = RichUtils; if newState this; } { return <Editor = = = /> ; }
Applying a style
// ...import Editor EditorState RichUtils from 'md-draft-js'; Component /// ... { const newState = RichUtils; this; } { return <button =>Bold</button> <Editor = = /> ; }
Fully working example
See this file to check a fully working example.
License
MIT