mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 05:31:56 +02:00
Merge branch 'schema-normalize-selection-ops' of https://github.com/GitbookIO/slate into schema-normalize-selection-ops
This commit is contained in:
@@ -576,7 +576,7 @@ class Selection extends new Record(DEFAULTS) {
|
|||||||
* @return {Selection} selection
|
* @return {Selection} selection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extendStartOffset(n = 1) {
|
moveStartOffset(n = 1) {
|
||||||
return this.isBackward
|
return this.isBackward
|
||||||
? this.merge({ focusOffset: this.focusOffset + n })
|
? this.merge({ focusOffset: this.focusOffset + n })
|
||||||
: this.merge({ anchorOffset: this.anchorOffset + n })
|
: this.merge({ anchorOffset: this.anchorOffset + n })
|
||||||
@@ -589,7 +589,7 @@ class Selection extends new Record(DEFAULTS) {
|
|||||||
* @return {Selection} selection
|
* @return {Selection} selection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extendEndOffset(n = 1) {
|
moveEndOffset(n = 1) {
|
||||||
return this.isBackward
|
return this.isBackward
|
||||||
? this.merge({ anchorOffset: this.anchorOffset + n })
|
? this.merge({ anchorOffset: this.anchorOffset + n })
|
||||||
: this.merge({ focusOffset: this.focusOffset + n })
|
: this.merge({ focusOffset: this.focusOffset + n })
|
||||||
|
@@ -116,10 +116,10 @@ function insertText(state, operation) {
|
|||||||
|
|
||||||
// Update the selection
|
// Update the selection
|
||||||
if (startKey == node.key && startOffset > offset) {
|
if (startKey == node.key && startOffset > offset) {
|
||||||
selection = selection.extendStartOffset(text.length)
|
selection = selection.moveStartOffset(text.length)
|
||||||
}
|
}
|
||||||
if (endKey == node.key && endOffset > offset) {
|
if (endKey == node.key && endOffset > offset) {
|
||||||
selection = selection.extendEndOffset(text.length)
|
selection = selection.moveEndOffset(text.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
state = state.merge({ document, selection })
|
state = state.merge({ document, selection })
|
||||||
|
Reference in New Issue
Block a user