1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 13:41:19 +02:00

fix(at-range): correct findInsertionNode method throw a type error when there arg is a Text node (#2498)

This commit is contained in:
phy
2019-01-30 08:09:18 +08:00
committed by Ian Storm Taylor
parent 91d46b3529
commit 1ce7c7cc89
2 changed files with 42 additions and 1 deletions

View File

@@ -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

View File

@@ -0,0 +1,37 @@
/** @jsx h */
import h from '../../../helpers/h'
export default function(editor) {
editor.insertFragment(
<document>
<code>
<paragraph>2</paragraph>
</code>
</document>
)
}
export const input = (
<value>
<document>
<code>
<paragraph>
1<cursor />
</paragraph>
</code>
</document>
</value>
)
export const output = (
<value>
<document>
<code>
<paragraph>
12<cursor />
</paragraph>
</code>
</document>
</value>
)