mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 23:12:52 +02:00
Fix docs on queries to show editor argument (#2285)
This commit is contained in:
committed by
Ian Storm Taylor
parent
53fd59bc62
commit
175b25ae51
@@ -207,7 +207,7 @@ The same thing goes for queries, which can be defined in plugins and re-used acr
|
|||||||
```js
|
```js
|
||||||
const yourPlugin = {
|
const yourPlugin = {
|
||||||
queries: {
|
queries: {
|
||||||
getActiveListItem(value) {
|
getActiveListItem(editor) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ const yourPlugin = {
|
|||||||
And then you can use them:
|
And then you can use them:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
change.getActiveListItem(change.value)
|
change.getActiveListItem()
|
||||||
```
|
```
|
||||||
|
|
||||||
This reusability is key to being able to organize your commands and queries, and compose them together to create more advanced behaviors.
|
This reusability is key to being able to organize your commands and queries, and compose them together to create more advanced behaviors.
|
||||||
|
@@ -160,7 +160,7 @@ Each command has a signature of `(change, ...args)`.
|
|||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
queries: {
|
queries: {
|
||||||
getActiveList(value) {
|
getActiveList(editor) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ Each command has a signature of `(change, ...args)`.
|
|||||||
|
|
||||||
The `queries` shorthand defines a set of custom queries that are made available in the editor, and as first-class methods on the `change` objects created by the editor.
|
The `queries` shorthand defines a set of custom queries that are made available in the editor, and as first-class methods on the `change` objects created by the editor.
|
||||||
|
|
||||||
Each query has a signature of `(...args)`.
|
Each query has a signature of `(editor, ...args)`.
|
||||||
|
|
||||||
### `schema`
|
### `schema`
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ For example, you might define an `getActiveList` query:
|
|||||||
```js
|
```js
|
||||||
const plugin = {
|
const plugin = {
|
||||||
queries: {
|
queries: {
|
||||||
getActiveList(value) {},
|
getActiveList(editor) {},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -73,8 +73,7 @@ const plugin = {
|
|||||||
And then be able to re-use that logic easily in different places in your codebase, or pass in the query name to a plugin that can use your custom logic itself:
|
And then be able to re-use that logic easily in different places in your codebase, or pass in the query name to a plugin that can use your custom logic itself:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { value } = change
|
const list = change.getActiveList()
|
||||||
const list = change.getActiveList(value)
|
|
||||||
|
|
||||||
if (list) {
|
if (list) {
|
||||||
...
|
...
|
||||||
|
Reference in New Issue
Block a user