From fc9395fe7ebf077db903c9c8fed71f136528ea5b Mon Sep 17 00:00:00 2001 From: Abhishek Pandya Date: Tue, 21 Jul 2020 09:12:19 -0700 Subject: [PATCH] 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 --- src/model/immutable/EditorState.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/model/immutable/EditorState.js b/src/model/immutable/EditorState.js index 65d5ad26ab..627cf9fea4 100644 --- a/src/model/immutable/EditorState.js +++ b/src/model/immutable/EditorState.js @@ -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, ); }