1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 06:31:28 +02:00

handle splitting for fragments

This commit is contained in:
Ian Storm Taylor
2016-10-14 16:46:12 -07:00
parent fa5d59c063
commit 8cf0a05926

View File

@@ -318,7 +318,9 @@ export function insertFragmentAtRange(transform, range, fragment) {
}) })
} }
if (startOffset != 0) {
transform.splitNodeByKey(startChild.key, offset) transform.splitNodeByKey(startChild.key, offset)
}
state = transform.state state = transform.state
document = state.document document = state.document
@@ -345,7 +347,8 @@ export function insertFragmentAtRange(transform, range, fragment) {
const inlineIndex = startBlock.nodes.indexOf(inlineChild) const inlineIndex = startBlock.nodes.indexOf(inlineChild)
firstBlock.nodes.forEach((inline, i) => { firstBlock.nodes.forEach((inline, i) => {
const newIndex = inlineIndex + i + 1 const offset = startOffset == 0 ? 0 : 1
const newIndex = inlineIndex + i + offset
transform.insertNodeByKey(startBlock.key, newIndex, inline) transform.insertNodeByKey(startBlock.key, newIndex, inline)
}) })
} }