tiptap/docs/api/commands/set-text-selection.md
2021-09-16 14:41:25 +02:00

20 lines
720 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# setTextSelection
If you think of selection in the context of an editor, youll probably think of a text selection. With `setTextSelection` you can control that text selection and set it to a specified range or position.
See also: [focus](/api/commands/focus), [setNodeSelection](/api/commands/set-node-selection), [deleteSelection](/api/commands/delete-selection), [selectAll](/api/commands/select-all)
## Parameters
`position: number | Range`
Pass a number, or a Range, for example `{ from: 5, to: 10 }`.
## Usage
```js
// Set the cursor to the specified position
editor.commands.setTextSelection(10)
// Set the text selection to the specified range
editor.commands.setTextSelection({ from: 5, to: 10 })
```