diff --git a/packages/slate/src/commands/at-range.js b/packages/slate/src/commands/at-range.js index 6e0290f03..4a0308002 100644 --- a/packages/slate/src/commands/at-range.js +++ b/packages/slate/src/commands/at-range.js @@ -789,7 +789,11 @@ Commands.insertFragmentAtRange = (editor, range, fragment) => { // If the starting block is empty, we replace it entirely with the first block // of the fragment, since this leads to a more expected behavior for the user. - if (!editor.isVoid(startBlock) && startBlock.text === '') { + if ( + !editor.isVoid(startBlock) && + startBlock.text === '' && + !startBlock.findDescendant(n => editor.isVoid(n)) + ) { editor.removeNodeByKey(startBlock.key) editor.insertNodeByKey(parent.key, index, firstBlock) } else { diff --git a/packages/slate/test/commands/at-current-range/insert-fragment/start-block-with-void-no-text.js b/packages/slate/test/commands/at-current-range/insert-fragment/start-block-with-void-no-text.js new file mode 100644 index 000000000..b1efcd24c --- /dev/null +++ b/packages/slate/test/commands/at-current-range/insert-fragment/start-block-with-void-no-text.js @@ -0,0 +1,38 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export default function(editor) { + editor.insertFragment( + + + one + two + + + ) +} + +export const input = ( + + + + + + + + +) + +export const output = ( + + + + + + onetwo + + + + +)