mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-14 03:03:58 +02:00
Hanging Selection paste in insertFragmentAtRange (#1742)
This commit is contained in:
committed by
Ian Storm Taylor
parent
2dd77c00f1
commit
9b39a89f20
@@ -671,7 +671,11 @@ Changes.insertFragmentAtRange = (change, range, fragment, options = {}) => {
|
||||
// If the range is expanded, delete it first.
|
||||
if (range.isExpanded) {
|
||||
change.deleteAtRange(range, { normalize: false })
|
||||
if (change.value.document.getDescendant(range.startKey)) {
|
||||
range = range.collapseToStart()
|
||||
} else {
|
||||
range = range.collapseTo(range.endKey, 0)
|
||||
}
|
||||
}
|
||||
|
||||
// If the fragment is empty, there's nothing to do after deleting.
|
||||
|
@@ -0,0 +1,44 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
const fragment = (
|
||||
<document>
|
||||
<paragraph>fragment zero</paragraph>
|
||||
<paragraph>fragment one</paragraph>
|
||||
<paragraph>fragment two</paragraph>
|
||||
</document>
|
||||
)
|
||||
export default function(change) {
|
||||
change.insertFragment(fragment)
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>zero</paragraph>
|
||||
<paragraph>
|
||||
<anchor />one
|
||||
</paragraph>
|
||||
<quote>
|
||||
<focus />two
|
||||
</quote>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
// The cursor position of insertFragment has some problems;
|
||||
// If you submit PR to fixed cursor position restore in insertFragment;
|
||||
// Please change this test as well
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>zero</paragraph>
|
||||
<quote>fragment zero</quote>
|
||||
<paragraph>fragment one</paragraph>
|
||||
<paragraph>
|
||||
<cursor />fragment twotwo
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
Reference in New Issue
Block a user