Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to init with pre content? #59

Open
zfha opened this issue Dec 20, 2018 · 2 comments
Open

How to init with pre content? #59

zfha opened this issue Dec 20, 2018 · 2 comments

Comments

@zfha
Copy link

zfha commented Dec 20, 2018

As the question

@adamblvck
Copy link

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.

@adamblvck
Copy link

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"))
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants