diff --git a/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPatches.ts b/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPatches.ts index 87e8e181306..c3301701284 100644 --- a/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPatches.ts +++ b/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPatches.ts @@ -171,12 +171,14 @@ export function createWithPatches( } if (editorWasEmpty && operation.type !== 'set_selection') { + patches.push(setIfMissing([], [])) patches.push( - setIfMissing([], []), insert( [ fromSlateValue( - previousChildren, + previousChildren.length === 0 + ? [editor.createPlaceholderBlock()] + : previousChildren, portableTextFeatures.types.block.name, KEY_TO_VALUE_ELEMENT.get(editor) )[0], @@ -186,6 +188,7 @@ export function createWithPatches( ) ) } + switch (operation.type) { case 'insert_text': patches = [...patches, ...insertTextPatch(editor, operation, previousChildren)]