Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Add support to create editor state using text string
Browse files Browse the repository at this point in the history
Summary: - Adds api to create editor state using text string

Differential Revision: D22628246

fbshipit-source-id: e1f1c4bcc68c780de6edf68e407c196bf4c836e1
  • Loading branch information
Abhishek Pandya authored and facebook-github-bot committed Jul 21, 2020
1 parent fb0eb34 commit fc9395f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/model/immutable/EditorState.js
Expand Up @@ -117,8 +117,15 @@ class EditorState {
_immutable: EditorStateRecord;

static createEmpty(decorator?: ?DraftDecoratorType): EditorState {
return this.createWithText('', decorator);
}

static createWithText(
text: string,
decorator?: ?DraftDecoratorType,
): EditorState {
return EditorState.createWithContent(
ContentState.createFromText(''),
ContentState.createFromText(text),
decorator,
);
}
Expand Down

0 comments on commit fc9395f

Please sign in to comment.