1
0
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:
Samy Pessé
2016-10-26 14:07:26 +02:00
parent 9f5807e008
commit 99e9a77639
3 changed files with 6 additions and 3 deletions

View File

@@ -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)
} }

View File

@@ -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

View File

@@ -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()
) )