diff --git a/packages/slate/src/commands/at-range.js b/packages/slate/src/commands/at-range.js index 37a46a752..6e0290f03 100644 --- a/packages/slate/src/commands/at-range.js +++ b/packages/slate/src/commands/at-range.js @@ -808,7 +808,11 @@ Commands.insertFragmentAtRange = (editor, range, fragment) => { } const findInsertionNode = (fragment, document, startKey) => { - const hasSingleNode = object => object && object.nodes.size === 1 + const hasSingleNode = object => { + if (!object || object.object === 'text') return + return object.nodes.size === 1 + } + const firstNode = object => object && object.nodes.first() let node = fragment diff --git a/packages/slate/test/commands/at-current-range/insert-fragment/fragment-single-child-block.js b/packages/slate/test/commands/at-current-range/insert-fragment/fragment-single-child-block.js new file mode 100644 index 000000000..c5f57ae90 --- /dev/null +++ b/packages/slate/test/commands/at-current-range/insert-fragment/fragment-single-child-block.js @@ -0,0 +1,37 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export default function(editor) { + editor.insertFragment( + + + 2 + + + ) +} + +export const input = ( + + + + + 1 + + + + +) + +export const output = ( + + + + + 12 + + + + +)