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:
@@ -808,7 +808,11 @@ Commands.insertFragmentAtRange = (editor, range, fragment) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const findInsertionNode = (fragment, document, startKey) => {
|
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()
|
const firstNode = object => object && object.nodes.first()
|
||||||
let node = fragment
|
let node = fragment
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
)
|
Reference in New Issue
Block a user