mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 18:09:49 +02:00
fix insert fragment with void children (#2624)
This commit is contained in:
@@ -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 {
|
||||
|
@@ -0,0 +1,38 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
export default function(editor) {
|
||||
editor.insertFragment(
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>one</text>
|
||||
<text>two</text>
|
||||
</paragraph>
|
||||
</document>
|
||||
)
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<emoji />
|
||||
<cursor />
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<emoji />
|
||||
<text>
|
||||
onetwo<cursor />
|
||||
</text>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
Reference in New Issue
Block a user