From fb299e5221b478c93113f859559e6936f2b6d960 Mon Sep 17 00:00:00 2001 From: yousefed Date: Thu, 3 Aug 2023 20:40:50 +0200 Subject: [PATCH] fix initialcontent collaboration --- packages/core/src/BlockNoteEditor.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/core/src/BlockNoteEditor.ts b/packages/core/src/BlockNoteEditor.ts index 524967c824..ef3340334b 100644 --- a/packages/core/src/BlockNoteEditor.ts +++ b/packages/core/src/BlockNoteEditor.ts @@ -205,12 +205,15 @@ export class BlockNoteEditor { this.schema = newOptions.blockSchema; - const initialContent = newOptions.initialContent || [ - { - type: "paragraph", - id: UniqueID.options.generateID(), - }, - ]; + const initialContent = + newOptions.initialContent || options.collaboration + ? undefined + : [ + { + type: "paragraph", + id: UniqueID.options.generateID(), + }, + ]; const tiptapOptions: EditorOptions = { ...blockNoteTipTapOptions, @@ -220,6 +223,10 @@ export class BlockNoteEditor { this.ready = true; }, onBeforeCreate(editor) { + if (!initialContent) { + // when using collaboration + return; + } // we have to set the initial content here, because now we can use the editor schema // which has been created at this point const schema = editor.editor.schema;