diff --git a/lib/models/transforms.js b/lib/models/transforms.js index 8984602d3..9548d5c45 100644 --- a/lib/models/transforms.js +++ b/lib/models/transforms.js @@ -255,7 +255,8 @@ const Transforms = { // If the block is empty, replace it. else if (startBlock.isEmpty) { - parent = parent.merge({ nodes }) + parent = parent.insertChildrenAfter(startBlock, nodes) + parent = parent.removeDescendant(startBlock) } // If the range is at the start of the block, insert before. diff --git a/test/transforms/fixtures/insert-block-at-range/is-empty/input.yaml b/test/transforms/fixtures/insert-block-at-range/is-empty/input.yaml index f6de4d08a..fbe1a3f76 100644 --- a/test/transforms/fixtures/insert-block-at-range/is-empty/input.yaml +++ b/test/transforms/fixtures/insert-block-at-range/is-empty/input.yaml @@ -5,3 +5,8 @@ nodes: nodes: - kind: text text: "" + - kind: block + type: paragraph + nodes: + - kind: text + text: not empty diff --git a/test/transforms/fixtures/insert-block-at-range/is-empty/output.yaml b/test/transforms/fixtures/insert-block-at-range/is-empty/output.yaml index 68da1740e..82e79625b 100644 --- a/test/transforms/fixtures/insert-block-at-range/is-empty/output.yaml +++ b/test/transforms/fixtures/insert-block-at-range/is-empty/output.yaml @@ -5,3 +5,8 @@ nodes: nodes: - kind: text text: "" + - kind: block + type: paragraph + nodes: + - kind: text + text: not empty diff --git a/test/transforms/fixtures/insert-block/is-empty/input.yaml b/test/transforms/fixtures/insert-block/is-empty/input.yaml index f6de4d08a..fbe1a3f76 100644 --- a/test/transforms/fixtures/insert-block/is-empty/input.yaml +++ b/test/transforms/fixtures/insert-block/is-empty/input.yaml @@ -5,3 +5,8 @@ nodes: nodes: - kind: text text: "" + - kind: block + type: paragraph + nodes: + - kind: text + text: not empty diff --git a/test/transforms/fixtures/insert-block/is-empty/output.yaml b/test/transforms/fixtures/insert-block/is-empty/output.yaml index 68da1740e..82e79625b 100644 --- a/test/transforms/fixtures/insert-block/is-empty/output.yaml +++ b/test/transforms/fixtures/insert-block/is-empty/output.yaml @@ -5,3 +5,8 @@ nodes: nodes: - kind: text text: "" + - kind: block + type: paragraph + nodes: + - kind: text + text: not empty