mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 15:02:51 +02:00
Limit melding behavior in insertFragmentAtRange
(#1366)
* fix insert nested single block fragment * disable merging multi nested blocks
This commit is contained in:
committed by
Ian Storm Taylor
parent
0dc2a4feab
commit
7c76fe7120
@@ -707,6 +707,20 @@ Changes.insertFragmentAtRange = (change, range, fragment, options = {}) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the fragment starts or ends with single nested block, (e.g., table),
|
||||||
|
// do not merge this fragment with existing blocks.
|
||||||
|
if (
|
||||||
|
firstBlock != lastBlock &&
|
||||||
|
Block.isBlock(fragment.nodes.first()) &&
|
||||||
|
Block.isBlock(fragment.nodes.last()) &&
|
||||||
|
(firstBlock != fragment.nodes.first() || lastBlock != fragment.nodes.last())
|
||||||
|
) {
|
||||||
|
fragment.nodes.reverse().forEach((node) => {
|
||||||
|
change.insertBlockAtRange(range, node, options)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// If the first and last block aren't the same, we need to insert all of the
|
// If the first and last block aren't the same, we need to insert all of the
|
||||||
// nodes after the fragment's first block at the index.
|
// nodes after the fragment's first block at the index.
|
||||||
if (firstBlock != lastBlock) {
|
if (firstBlock != lastBlock) {
|
||||||
|
Reference in New Issue
Block a user