From 26f4b2521c67b90aca96ca99be9f58e6509ec042 Mon Sep 17 00:00:00 2001 From: Sunny Hirai Date: Mon, 7 Jun 2021 08:59:27 -0700 Subject: [PATCH] docs: Clarified that Editor.positions in reverse with a word changes the returned positions --- docs/api/nodes/editor.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/nodes/editor.md b/docs/api/nodes/editor.md index 52e9c89bb..05f47721c 100644 --- a/docs/api/nodes/editor.md +++ b/docs/api/nodes/editor.md @@ -186,10 +186,10 @@ Options: - `at?: Location = editor.selection`: The `Location` in which to iterate the positions 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` (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` + - `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: The character offsets for Unicode characters 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`. In `reverse` mode, moves to the position immediately before the previous `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. -- `reverse?: boolean = false`: When `true` iterate backwards. +- `reverse?: boolean = false`: When `true` returns the positions in reverse order. In the case of the `unit` being `word`, the actual returned positions are different (i.e. we will get the start of a word in reverse instead of the end). - `voids?: boolean = false`: When `true` include void Nodes. #### `Editor.previous(editor: Editor, options?) => NodeEntry | undefined`