docs: add content for the focus and setTextSelection command

This commit is contained in:
Hans Pagel 2021-05-27 21:37:47 +02:00
parent 5b9395ee74
commit 98b0e3fe5e
5 changed files with 19 additions and 7 deletions

View File

@ -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 doesnt trigger the update event. Passing `true` doesnt prevent triggering the update event.

View File

@ -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. Thats why youll 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, its 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)
```

View File

@ -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)

View File

@ -1,11 +1,12 @@
# 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.
<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

View File

@ -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