Skip to content

Commit

Permalink
fix: don't throw an error when initialContent is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
m-risto committed Aug 21, 2024
1 parent 6af5023 commit b302ec9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions libs/ngx-blocknote/src/lib/editor/bna-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class BnaEditorComponent<

ngOnChanges(changes: SimpleChanges) {
if (changes['options']) {
this.editor = this.createEditor(changes['initialContent'].currentValue);
this.editor = this.createEditor(changes['initialContent']?.currentValue);
this.blockNoteAngularService.setOptions(this.options ?? {});
} else if (changes['initialContent']) {
this.updateEditorsInitialContent(changes['initialContent'].currentValue);
Expand All @@ -176,15 +176,17 @@ export class BnaEditorComponent<
) {
const schema = this.options?.schema;
const editor = BlockNoteEditor.create({
schema: schema ? schema : (BlockNoteSchema.create({
blockSpecs: { ...defaultBlockSpecs },
inlineContentSpecs: { ...defaultInlineContentSpecs },
styleSpecs: {
...defaultStyleSpecs,
},
// in this case the user did not give a blocknote schema so we want to use the default one
//TODO: remove casting
})as unknown as BlockNoteSchema<BSchema, ISchema, SSchema>),
schema: schema
? schema
: (BlockNoteSchema.create({
blockSpecs: { ...defaultBlockSpecs },
inlineContentSpecs: { ...defaultInlineContentSpecs },
styleSpecs: {
...defaultStyleSpecs,
},
// in this case the user did not give a blocknote schema so we want to use the default one
//TODO: remove casting
}) as unknown as BlockNoteSchema<BSchema, ISchema, SSchema>),
initialContent: initialContent,
uploadFile: this.options?.uploadFile,
});
Expand Down

0 comments on commit b302ec9

Please sign in to comment.