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

Commit fc9395f

Browse files
Abhishek Pandyafacebook-github-bot
Abhishek Pandya
authored andcommitted
Add support to create editor state using text string
Summary: - Adds api to create editor state using text string Differential Revision: D22628246 fbshipit-source-id: e1f1c4bcc68c780de6edf68e407c196bf4c836e1
1 parent fb0eb34 commit fc9395f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/model/immutable/EditorState.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,15 @@ class EditorState {
117117
_immutable: EditorStateRecord;
118118

119119
static createEmpty(decorator?: ?DraftDecoratorType): EditorState {
120+
return this.createWithText('', decorator);
121+
}
122+
123+
static createWithText(
124+
text: string,
125+
decorator?: ?DraftDecoratorType,
126+
): EditorState {
120127
return EditorState.createWithContent(
121-
ContentState.createFromText(''),
128+
ContentState.createFromText(text),
122129
decorator,
123130
);
124131
}

0 commit comments

Comments
 (0)