mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 21:21:21 +02:00
update reference
This commit is contained in:
@@ -12,22 +12,22 @@ The "anchor" is the fixed point in a selection, and the "focus" is the non-fixed
|
|||||||
Often times, you don't need to specifically know which point is the "anchor" and which is the "focus", and you just need to know which comes first and last in the document. For these cases, there are many convenience equivalent properties and methods referring to the "start" and "end" points.
|
Often times, you don't need to specifically know which point is the "anchor" and which is the "focus", and you just need to know which comes first and last in the document. For these cases, there are many convenience equivalent properties and methods referring to the "start" and "end" points.
|
||||||
|
|
||||||
- [Properties](#properties)
|
- [Properties](#properties)
|
||||||
- [`anchorKey`](#anchorkey-string)
|
- [`anchorKey`](#anchorkey)
|
||||||
- [`anchorOffset`](#anchoroffset-number)
|
- [`anchorOffset`](#anchoroffset)
|
||||||
- [`focusKey`](#focuskey-string)
|
- [`focusKey`](#focuskey)
|
||||||
- [`focusOffset`](#focusoffset-number)
|
- [`focusOffset`](#focusoffset)
|
||||||
- [`isBackward`](#isbackward-boolean)
|
- [`isBackward`](#isbackward)
|
||||||
- [`isFocused`](#isfocused-boolean)
|
- [`isFocused`](#isfocused)
|
||||||
- [Computed Properties](#computed-properties)
|
- [Computed Properties](#computed-properties)
|
||||||
- [`endKey`](#endkey-string)
|
- [`endKey`](#endkey)
|
||||||
- [`endOffset`](#endoffset-number)
|
- [`endOffset`](#endoffset)
|
||||||
- [`isBlurred`](#isblurred-boolean)
|
- [`isBlurred`](#isblurred)
|
||||||
- [`isCollapsed`](#iscollapsed-boolean)
|
- [`isCollapsed`](#iscollapsed)
|
||||||
- [`isExpanded`](#isExpanded-boolean)
|
- [`isExpanded`](#isExpanded)
|
||||||
- [`isForward`](#isForward-boolean)
|
- [`isForward`](#isForward)
|
||||||
- [`startKey`](#startkey-string)
|
- [`startKey`](#startkey)
|
||||||
- [`startOffset`](#startoffset-number)
|
- [`startOffset`](#startoffset)
|
||||||
- [Static Methods](#static-methods)
|
- [Static Methods](#static)
|
||||||
- [`Selection.create(properties)`](#create-properties)
|
- [`Selection.create(properties)`](#create-properties)
|
||||||
- [Checking Methods](#checking-methods)
|
- [Checking Methods](#checking-methods)
|
||||||
- [`has{Edge}AtEndOf(node)`](hasedgeatendof-node)
|
- [`has{Edge}AtEndOf(node)`](hasedgeatendof-node)
|
||||||
@@ -64,27 +64,33 @@ Selection({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `anchorKey: String`
|
### `anchorKey`
|
||||||
|
`String`
|
||||||
|
|
||||||
The key of the text node at the selection's anchor point.
|
The key of the text node at the selection's anchor point.
|
||||||
|
|
||||||
#### `anchorOffset: Number`
|
### `anchorOffset`
|
||||||
|
`Number`
|
||||||
|
|
||||||
The numbers of characters from the start of the text node at the selection's anchor point.
|
The numbers of characters from the start of the text node at the selection's anchor point.
|
||||||
|
|
||||||
#### `focusKey: String`
|
### `focusKey`
|
||||||
|
`String`
|
||||||
|
|
||||||
The key of the text node at the selection's focus point.
|
The key of the text node at the selection's focus point.
|
||||||
|
|
||||||
#### `focusOffset: Number`
|
### `focusOffset`
|
||||||
|
`Number`
|
||||||
|
|
||||||
The numbers of characters from the start of the text node at the selection's focus point.
|
The numbers of characters from the start of the text node at the selection's focus point.
|
||||||
|
|
||||||
#### `isBackward: Boolean`
|
### `isBackward`
|
||||||
|
`Boolean`
|
||||||
|
|
||||||
Whether the selection is backward. A selection is considered "backward" when its focus point references a location earlier in the document than its anchor point.
|
Whether the selection is backward. A selection is considered "backward" when its focus point references a location earlier in the document than its anchor point.
|
||||||
|
|
||||||
#### `isFocused: Boolean`
|
### `isFocused`
|
||||||
|
`Boolean`
|
||||||
|
|
||||||
Whether the selection currently has focus.
|
Whether the selection currently has focus.
|
||||||
|
|
||||||
@@ -93,60 +99,71 @@ Whether the selection currently has focus.
|
|||||||
|
|
||||||
These properties aren't supplied when creating a selection, but are instead computed based on the real properties.
|
These properties aren't supplied when creating a selection, but are instead computed based on the real properties.
|
||||||
|
|
||||||
#### `isBlurred: Boolean`
|
### `isBlurred`
|
||||||
|
`Boolean`
|
||||||
|
|
||||||
The opposite of `isFocused`, for convenience.
|
The opposite of `isFocused`, for convenience.
|
||||||
|
|
||||||
#### `isCollapsed: Boolean`
|
### `isCollapsed`
|
||||||
|
`Boolean`
|
||||||
|
|
||||||
Whether the selection is collapsed. A selection is considered "collapsed" when the anchor point and focus point of the selection are the same.
|
Whether the selection is collapsed. A selection is considered "collapsed" when the anchor point and focus point of the selection are the same.
|
||||||
|
|
||||||
#### `isExpanded: Boolean`
|
### `isExpanded`
|
||||||
|
`Boolean`
|
||||||
|
|
||||||
The opposite of `isCollapsed`, for convenience.
|
The opposite of `isCollapsed`, for convenience.
|
||||||
|
|
||||||
#### `isForward: Boolean`
|
### `isForward`
|
||||||
|
`Boolean`
|
||||||
|
|
||||||
The opposite of `isBackward`, for convenience.
|
The opposite of `isBackward`, for convenience.
|
||||||
|
|
||||||
#### `startKey: String`
|
### `startKey`
|
||||||
#### `startOffset: Number`
|
### `startOffset`
|
||||||
#### `endKey: String`
|
### `endKey`
|
||||||
#### `endOffset: Number`
|
### `endOffset`
|
||||||
|
|
||||||
A few convenience properties for accessing the first and last point of the selection. When the selection is forward, `start` refers to the `anchor` point and `end` refers to the `focus` point. And when it's backward they are reversed.
|
A few convenience properties for accessing the first and last point of the selection. When the selection is forward, `start` refers to the `anchor` point and `end` refers to the `focus` point. And when it's backward they are reversed.
|
||||||
|
|
||||||
|
|
||||||
## Static Methods
|
## Static Methods
|
||||||
|
|
||||||
#### `Selection.create(properties)`
|
### `Selection.create`
|
||||||
|
`Selection.create(properties: Object) => Selection`
|
||||||
|
|
||||||
Create a new `Selection` instance with `properties`.
|
Create a new `Selection` instance with `properties`.
|
||||||
|
|
||||||
|
|
||||||
## Checking Methods
|
## Checking Methods
|
||||||
|
|
||||||
#### `has{Edge}AtStartOf(node: Node) => Boolean`
|
### `has{Edge}AtStartOf`
|
||||||
|
`has{Edge}AtStartOf(node: Node) => Boolean`
|
||||||
|
|
||||||
Determine whether a selection has an edge at the start of a `node`. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
Determine whether a selection has an edge at the start of a `node`. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
||||||
|
|
||||||
#### `has{Edge}AtEndOf(node: Node) => Boolean`
|
### `has{Edge}AtEndOf`
|
||||||
|
`has{Edge}AtEndOf(node: Node) => Boolean`
|
||||||
|
|
||||||
Determine whether a selection has an edge at the end of a `node`. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
Determine whether a selection has an edge at the end of a `node`. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
||||||
|
|
||||||
#### `has{Edge}Between(node: Node, start: Number, end: Number) => Boolean`
|
### `has{Edge}Between`
|
||||||
|
`has{Edge}Between(node: Node, start: Number, end: Number) => Boolean`
|
||||||
|
|
||||||
Determine whether a selection has an edge in a `node` between its `start` and `end` offset. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
Determine whether a selection has an edge in a `node` between its `start` and `end` offset. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
||||||
|
|
||||||
#### `has{Edge}In(node: Node, start: Number, end: Number) => Boolean`
|
### `has{Edge}In`
|
||||||
|
`has{Edge}In(node: Node, start: Number, end: Number) => Boolean`
|
||||||
|
|
||||||
Determine whether a selection has an edge inside a `node`. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
Determine whether a selection has an edge inside a `node`. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start`, `End` or `Edge` (referring to either point).
|
||||||
|
|
||||||
#### `isAtStartOf(node: Node) => Boolean`
|
### `isAtStartOf`
|
||||||
|
`isAtStartOf(node: Node) => Boolean`
|
||||||
|
|
||||||
Determine whether the selection is at the start of a `node`.
|
Determine whether the selection is at the start of a `node`.
|
||||||
|
|
||||||
#### `isAtEndOf(node: Node) => Boolean`
|
### `isAtEndOf`
|
||||||
|
`isAtEndOf(node: Node) => Boolean`
|
||||||
|
|
||||||
Determine whether the selection is at the end of a `node`.
|
Determine whether the selection is at the end of a `node`.
|
||||||
|
|
||||||
@@ -155,50 +172,50 @@ Determine whether the selection is at the end of a `node`.
|
|||||||
|
|
||||||
Since `Selection`s are immutable, all of the transforming methods return a new instance of the selection.
|
Since `Selection`s are immutable, all of the transforming methods return a new instance of the selection.
|
||||||
|
|
||||||
#### `blur() => Selection`
|
### `blur() => Selection`
|
||||||
|
|
||||||
Change the selection's `isFocused` property to `false`.
|
Change the selection's `isFocused` property to `false`.
|
||||||
|
|
||||||
#### `focus() => Selection`
|
### `focus() => Selection`
|
||||||
|
|
||||||
Change the selection's `isFocused` property to `true`.
|
Change the selection's `isFocused` property to `true`.
|
||||||
|
|
||||||
#### `moveTo{Edge}() => Selection`
|
### `moveTo{Edge}() => Selection`
|
||||||
|
|
||||||
Move both of the selection's points to an edge, collapsing it. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start` or `End`.
|
Move both of the selection's points to an edge, collapsing it. Where `{Edge}` can be one of: `Anchor`, `Focus`, `Start` or `End`.
|
||||||
|
|
||||||
#### `moveToStartOf(node: Node) => Selection`
|
### `moveToStartOf(node: Node) => Selection`
|
||||||
|
|
||||||
Move both of the selection's points to the start of a `node`.
|
Move both of the selection's points to the start of a `node`.
|
||||||
|
|
||||||
#### `moveToEndOf(node: Node) => Selection`
|
### `moveToEndOf(node: Node) => Selection`
|
||||||
|
|
||||||
Move both of the selection's points to the end of a `node`.
|
Move both of the selection's points to the end of a `node`.
|
||||||
|
|
||||||
#### `moveToRangeOf(node: Node) => Selection`
|
### `moveToRangeOf(node: Node) => Selection`
|
||||||
|
|
||||||
Move the selection's anchor point to the start of a `node`, and its focus point to the end of the same `node`.
|
Move the selection's anchor point to the start of a `node`, and its focus point to the end of the same `node`.
|
||||||
|
|
||||||
#### `moveForward([n = 1: Number]) => Selection`
|
### `moveForward([n = 1: Number]) => Selection`
|
||||||
|
|
||||||
Increase the selection's `anchorOffset` and `focusOffset` by `n`, defaulting to `1`.
|
Increase the selection's `anchorOffset` and `focusOffset` by `n`, defaulting to `1`.
|
||||||
|
|
||||||
#### `moveBackward([n = 1: Number]) => Selection`
|
### `moveBackward([n = 1: Number]) => Selection`
|
||||||
|
|
||||||
Decrease the selection's `anchorOffset` and `focusOffset` by `n`, defaulting to `1`.
|
Decrease the selection's `anchorOffset` and `focusOffset` by `n`, defaulting to `1`.
|
||||||
|
|
||||||
#### `extendForward([n = 1: Number]) => Selection`
|
### `extendForward([n = 1: Number]) => Selection`
|
||||||
|
|
||||||
Increase the selection's `focusOffset` by `n`, default to `1`.
|
Increase the selection's `focusOffset` by `n`, default to `1`.
|
||||||
|
|
||||||
#### `extendBackward([n = 1: Number]) => Selection`
|
### `extendBackward([n = 1: Number]) => Selection`
|
||||||
|
|
||||||
Decrease the selection's `focusOffset` by `n`, default to `1`.
|
Decrease the selection's `focusOffset` by `n`, default to `1`.
|
||||||
|
|
||||||
#### `extendToStartOf(node: Node) => Selection`
|
### `extendToStartOf(node: Node) => Selection`
|
||||||
|
|
||||||
Move the selection's `focusOffset` to the start of a `node`.
|
Move the selection's `focusOffset` to the start of a `node`.
|
||||||
|
|
||||||
#### `extendToEndOf(node: Node) => Selection`
|
### `extendToEndOf(node: Node) => Selection`
|
||||||
|
|
||||||
Move the selection's `focusOffset` to the end of a `node`.
|
Move the selection's `focusOffset` to the end of a `node`.
|
||||||
|
Reference in New Issue
Block a user