Skip to content

Commit

Permalink
fix(portable-text-editor): add default value when there are no previo…
Browse files Browse the repository at this point in the history
…us value.
  • Loading branch information
skogsmaskin committed Aug 11, 2022
1 parent 80e2482 commit 10167b2
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -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],
Expand All @@ -186,6 +188,7 @@ export function createWithPatches(
)
)
}

switch (operation.type) {
case 'insert_text':
patches = [...patches, ...insertTextPatch(editor, operation, previousChildren)]
Expand Down

0 comments on commit 10167b2

Please sign in to comment.