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:
@@ -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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user