0.1.0 • Published 3 years ago

draft-js-markdown-code-plugin v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

draft-js-markdown-code-plugin

A DraftJS plugin for supporting Markdown syntax shortcuts.

This plugin works with DraftJS Plugins wrapper component.

This is a fork of ngs/draft-js-markdown-shortcuts-plugin, which hasn't merged PRs in a while.

This fork includes:

  • Dependency updates
  • Typescript support
  • Resolved deprecation warnings

TODO:

  • Port tests
  • Add custom components to render links and images

Install

yarn add draft-js-markdown-code-plugin

Usage

import Editor from '@draft-js-plugins/editor';
import createMarkdownCodePlugin from 'draft-js-markdown-code-plugin';

const [editorState, setEditorState] = useState(
  () => EditorState.createWithContent(ContentState.createFromText(''))
);
const plugins = [createMarkdownCodePlugin()];

export default function Example() {
  return (
    <Editor
      editorState={editorState}
      onChange={setEditorState}
      placeholder="Write something here..."
      plugins={plugins}
    />
  )
}

License

MIT © davidmh