File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export class DraftBase {
3333export class DraftHtmlBase extends DraftBase {
3434 @Input ( )
3535 set html ( html : string ) {
36- const state : EditorState = html ? this . stateFromHTML ( html ) : EditorState . createEmpty ( ) ;
36+ const state : EditorState = this . stateFromHTML ( html ) ;
3737 this . editorProps = Object . assign ( { } , this . editorProps , { editorState : state } ) ;
3838 }
3939
@@ -45,8 +45,15 @@ export class DraftHtmlBase extends DraftBase {
4545 } ) ;
4646 }
4747
48- stateFromHTML ( html : string ) {
48+ stateFromHTML ( html : string ) : EditorState {
49+ const emptyState = EditorState . createEmpty ( ) ;
50+
51+ if ( ! html ) { return emptyState ; }
52+
4953 const blocksFromHTML = convertFromHTML ( html ) ;
54+
55+ if ( ! blocksFromHTML ) { return emptyState ; }
56+
5057 const state = ContentState . createFromBlockArray (
5158 blocksFromHTML . contentBlocks ,
5259 blocksFromHTML . entityMap ,
You can’t perform that action at this time.
0 commit comments