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:
@@ -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.
|
||||||
*
|
*
|
||||||
|
@@ -61,6 +61,7 @@ const SELECTION_TRANSFORMS = [
|
|||||||
'moveToEnd',
|
'moveToEnd',
|
||||||
'moveToEndOf',
|
'moveToEndOf',
|
||||||
'moveToFocus',
|
'moveToFocus',
|
||||||
|
'moveToOffsets',
|
||||||
'moveToRangeOf',
|
'moveToRangeOf',
|
||||||
'moveToStart',
|
'moveToStart',
|
||||||
'moveToStartOf'
|
'moveToStartOf'
|
||||||
|
Reference in New Issue
Block a user