ngs / draft-js-markdown-shortcuts-plugin

A DraftJS plugin for supporting Markdown syntax shortcuts

Home Page:https://ngs.github.io/draft-js-markdown-shortcuts-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

draft-js-markdown-shortcuts-plugin

Run tests Backers on Open Collective Sponsors on Open Collective npm Coverage Status

A DraftJS plugin for supporting Markdown syntax shortcuts

This plugin works with DraftJS Plugins wrapper component.

screen

View Demo

Usage

npm i --save draft-js-markdown-shortcuts-plugin

then import from your editor component

import createMarkdownShortcutsPlugin from 'draft-js-markdown-shortcuts-plugin';

Example

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);
    this.state = {
      editorState: EditorState.createEmpty(),
    };
  }

  onChange = editorState => {
    this.setState({
      editorState,
    });
  };

  render() {
    return <Editor editorState={this.state.editorState} onChange={this.onChange} plugins={plugins} />;
  }
}

License

MIT. See LICENSE

About

A DraftJS plugin for supporting Markdown syntax shortcuts

https://ngs.github.io/draft-js-markdown-shortcuts-plugin/

License:MIT License


Languages

Language:JavaScript 100.0%