mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 21:21:21 +02:00
Be inclusive for selection in insertText
This commit is contained in:
@@ -115,10 +115,10 @@ function insertText(state, operation) {
|
|||||||
document = document.updateDescendant(node)
|
document = document.updateDescendant(node)
|
||||||
|
|
||||||
// Update the selection
|
// Update the selection
|
||||||
if (startKey == node.key && startOffset > offset) {
|
if (startKey == node.key && startOffset >= offset) {
|
||||||
selection = selection.moveStartOffset(text.length)
|
selection = selection.moveStartOffset(text.length)
|
||||||
}
|
}
|
||||||
if (endKey == node.key && endOffset > offset) {
|
if (endKey == node.key && endOffset >= offset) {
|
||||||
selection = selection.moveEndOffset(text.length)
|
selection = selection.moveEndOffset(text.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,9 @@ export default function (state) {
|
|||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
next.selection.toJS(),
|
next.selection.toJS(),
|
||||||
nextSelection.toJS()
|
nextSelection.merge({
|
||||||
|
focusOffset: 6
|
||||||
|
}).toJS()
|
||||||
)
|
)
|
||||||
|
|
||||||
return next
|
return next
|
||||||
|
@@ -22,6 +22,7 @@ export default function (state) {
|
|||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
next.selection.toJS(),
|
next.selection.toJS(),
|
||||||
nextSelection.merge({
|
nextSelection.merge({
|
||||||
|
anchorOffset: 4,
|
||||||
focusOffset: 6
|
focusOffset: 6
|
||||||
}).toJS()
|
}).toJS()
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user