draft-js-markdown-shortcuts-plugin
Version:
A DraftJS plugin for supporting Markdown syntax shortcuts
66 lines (47 loc) • 2 kB
Markdown

[](#backers) [](#sponsors) [][npm]
[](https://coveralls.io/github/ngs/draft-js-markdown-shortcuts-plugin?branch=master)
A [DraftJS] plugin for supporting Markdown syntax shortcuts
This plugin works with [DraftJS Plugins] wrapper component.

[][demo]
```sh
npm i --save draft-js-markdown-shortcuts-plugin
```
then import from your editor component
```js
import createMarkdownShortcutsPlugin from 'draft-js-markdown-shortcuts-plugin';
```
```js
import React, { Component } from 'react';
import Editor from 'draft-js-plugins-editor';
import createMarkdownShortcutsPlugin from 'draft-js-markdown-shortcuts-plugin';
import { EditorState } from 'draft-js';
const plugins = [createMarkdownShortcutsPlugin()];
export default class DemoEditor extends Component {
constructor(props) {
super(props);
state = {
editorState: EditorState.createEmpty(),
};
}
onChange = editorState => {
this.setState({
editorState,
});
};
render() {
return <Editor editorState={this.state.editorState} onChange={this.onChange} plugins={plugins} />;
}
}
```
MIT. See [LICENSE]
[]: https://ngs.github.io/draft-js-markdown-shortcuts-plugin
[]: https://facebook.github.io/draft-js/
[]: https://github.com/draft-js-plugins/draft-js-plugins
[]: ./LICENSE
[]: https://www.npmjs.com/package/draft-js-markdown-shortcuts-plugin