1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 11:12:42 +02:00

add moveToOffsets transform, fixes #70

This commit is contained in:
Ian Storm Taylor
2016-07-12 12:26:32 -07:00
parent 7aa475d74d
commit fae913b2c2
2 changed files with 17 additions and 0 deletions

View File

@@ -456,6 +456,22 @@ class Selection extends new Record(DEFAULTS) {
}) })
} }
/**
* Move the selection to `anchor` and `focus` offsets.
*
* @param {Number} anchor
* @param {Number} focus (optional)
* @return {Selection} selection
*/
moveToOffsets(anchor, focus = anchor) {
return this.merge({
anchorOffset: anchor,
focusOffset: focus,
isBackward: null
})
}
/** /**
* Extend the focus point forward `n` characters. * Extend the focus point forward `n` characters.
* *

View File

@@ -61,6 +61,7 @@ const SELECTION_TRANSFORMS = [
'moveToEnd', 'moveToEnd',
'moveToEndOf', 'moveToEndOf',
'moveToFocus', 'moveToFocus',
'moveToOffsets',
'moveToRangeOf', 'moveToRangeOf',
'moveToStart', 'moveToStart',
'moveToStartOf' 'moveToStartOf'