mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 05:26:21 +08:00
docs: add content for the focus and setTextSelection command
This commit is contained in:
parent
5b9395ee74
commit
98b0e3fe5e
@ -6,7 +6,7 @@ Keep in mind that the editor will enforce the configured schema, and the documen
|
||||
See also: [setContent](/api/commands/set-content), [insertContent](/api/commands/insert-content)
|
||||
|
||||
## Parameters
|
||||
`emitUpdate: Boolean (false)`
|
||||
`emitUpdate: boolean (false)`
|
||||
|
||||
By default, it doesn’t trigger the update event. Passing `true` doesn’t prevent triggering the update event.
|
||||
|
||||
|
@ -1,6 +1,14 @@
|
||||
# focus
|
||||
This command sets the focus back to the editor.
|
||||
|
||||
<ContentMissing />
|
||||
When a user clicks on a button outside the editor, the browser sets the focus to that button. In most scenarios you want to focus the editor then again. That’s why you’ll see that in basically every demo here.
|
||||
|
||||
See also: [setTextSelection](/api/commands/set-text-selection)
|
||||
|
||||
## Parameters
|
||||
`position: 'start' | 'end' | number | boolean | null (false)`
|
||||
|
||||
By default, it’s restoring the cursor position (and text selection). Pass a position to move the cursor too.
|
||||
|
||||
## Usage
|
||||
```js
|
||||
@ -12,4 +20,7 @@ editor.commands.focus('start')
|
||||
|
||||
// Set the cursor to the last position
|
||||
editor.commands.focus('end')
|
||||
|
||||
// Set the cursor to position 10
|
||||
editor.commands.focus(10)
|
||||
```
|
||||
|
@ -1,5 +1,5 @@
|
||||
# insertContent
|
||||
The `insertContent` command adds a passed value to the document.
|
||||
The `insertContent` command adds the passed value to the document.
|
||||
|
||||
See also: [setContent](/api/commands/set-content), [clearContent](/api/commands/clear-content)
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
# setTextSelection
|
||||
If you think of selection in the context of an editor, you’ll probably think of a text selection. With `setTextSelection` you can control that text selection and set it to a specified range or position.
|
||||
|
||||
<ContentMissing />
|
||||
See also: [focus](/api/commands/focus), [setNodeSelection](/api/commands/set-node-selection), [deleteSelection](/api/commands/delete-selection)
|
||||
|
||||
## Parameters
|
||||
`position: number | Range`
|
||||
|
||||
TODO
|
||||
Pass a number, or a Range, for example `{ from: 5, to: 10 }`.
|
||||
|
||||
## Usage
|
||||
```js
|
||||
|
@ -155,7 +155,7 @@
|
||||
link: /api/commands/extend-mark-range
|
||||
- title: focus
|
||||
link: /api/commands/focus
|
||||
type: draft
|
||||
type: new
|
||||
- title: insertContent
|
||||
link: /api/commands/insert-content
|
||||
- title: insertContentAt
|
||||
@ -213,7 +213,7 @@
|
||||
type: draft
|
||||
- title: setTextSelection
|
||||
link: /api/commands/set-text-selection
|
||||
type: draft
|
||||
type: new
|
||||
- title: sinkListItem
|
||||
link: /api/commands/sink-list-item
|
||||
type: draft
|
||||
|
Loading…
Reference in New Issue
Block a user