1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 13:41:19 +02:00

Merge branch 'schema-normalize-selection-ops' of https://github.com/GitbookIO/slate into schema-normalize-selection-ops

This commit is contained in:
Samy Pessé
2016-10-26 13:59:05 +02:00
3 changed files with 6 additions and 4 deletions

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
/* eslint-disable no-console */
import { Raw, Inline } from './src' import { Raw, Inline } from './src'
function printNode(node, depth = 0) { function printNode(node, depth = 0) {