draft-js-markdown-shortcuts-plugin
draft-js-markdown-shortcuts-plugin copied to clipboard
How to init with pre content?
trafficstars
As the question
Import the following
import { EditorState, ContentState } from 'draft-js';
After that, you can set the content in a constructor (or differently) by:
this.state = {
editorState: EditorState.createWithContent(ContentState.createFromText("hello"))
};
However, adding markdown text in the createFromText function doesn't trigger parsing from the plugin, which I would love the developer to document or chime in on.
Found a solution to problem specified above:
Install
npm install --save draft-js-import-markdown
Then you can set the content state as such:
this.state = {
editorState: EditorState.createWithContent(stateFromMarkdown("#markdowntitle"))
};