Browse Source

fix(admin-ui): Do not display "undefined" in rich text editor

Fixes #1374
Michael Bromley 4 years ago
parent
commit
e80b8c59ab

+ 2 - 2
packages/admin-ui/src/lib/core/src/shared/components/rich-text-editor/prosemirror/prosemirror.service.ts

@@ -81,9 +81,9 @@ export class ProsemirrorService {
         }
     }
 
-    private getStateFromText(text: string): EditorState {
+    private getStateFromText(text: string | null | undefined): EditorState {
         const div = document.createElement('div');
-        div.innerHTML = text;
+        div.innerHTML = text ?? '';
         return EditorState.create({
             doc: DOMParser.fromSchema(this.mySchema).parse(div),
             plugins: this.configurePlugins({ schema: this.mySchema, floatingMenu: false }),