1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-16 11:22:15 +02:00

docs: Improve styling and wording in Editor.positions

This commit is contained in:
Sunny Hirai 2021-06-06 22:52:20 -07:00
parent 1f08442ab2
commit c86d0b040b

View File

@ -181,11 +181,11 @@ Read `options.unit` to see how this method iterates through positions.
Note: By default void nodes are treated as a single point and iteration will not happen inside their content unless you pass in true for the voids option, then iteration will occur.
`options:`
Options:
- `at?: Location = editor.selection`: The `Location` in which to iterate the postions of.
- `unit?: 'offset' | 'character' | 'word' | 'line' | 'block' = 'offset'`:
- `offset`: Moves to the next offset `Point`. It will include the `Point` at the end of a `Text` object and then move onto the first `Point` of the next `Text` object. This may be counter-intuitive because the end of a `Text` and the beginning of the next `Text` might be thought of as the same position.
- `offset`: Moves to the next offset `Point`. It will include the `Point` at the end of a `Text` object and then move onto the first `Point` (at the 0th offset) of the next `Text` object. This may be counter-intuitive because the end of a `Text` and the beginning of the next `Text` might be thought of as the same position.
- `character`: Moves to the next `character` but is not always the next `index` in the string. This is because Unicode encodings may require multiple bytes to create one character. Unlike `offset`, `character` will not count the end of a `Text` and the beginning of the next `Text` as separate positions to return. Warning: This does not appear to be reliable in some cases like a Smiley Emoji will be identified as 2 characters.
- `word`: Moves to the position immediately after the next `word`
- `line` | `block`: Starts at the beginning position and then the position at the end of the block. Then starts at the beginning of the next block and then the end of the next block.