1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-20 05:11:53 +02:00

Update Operation API documentation (#5239)

* fix typo in implementation

* doc based on implementation

* fix doc typo
This commit is contained in:
Sim Ho 2022-12-29 18:38:03 -05:00 committed by GitHub
parent d7353677e3
commit 55effa953c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 5 deletions

View File

@ -2,4 +2,30 @@
`Operation` objects define the low-level instructions that Slate editors use to apply changes to their internal state. Representing all changes as operations is what allows Slate editors to easily implement history, collaboration, and other features.
_The `Operation` API reference needs to be added._
### Check methods
#### `isNodeOperation(value: any) => boolean`
Check if a value is a `NodeOperation` object. Returns the value as a `NodeOperation` if it is one.
#### `isOperation(value: any) => boolean`
Check if a value is an `Operation` object. Returns the value as an `Operation` if it is one.
#### `isOperationList(value: any) => boolean`
Check if a value is a list of `Operation` objects. Returns the value as an `Operation[]` if it is one.
#### `isSelectionOperation(value: any) => boolean`
Check if a value is a `SelectionOperation` object. Returns the value as a `SelectionOperation` if it is one.
#### `isTextOperation(value: any) => boolean`
Check if a value is a `TextOperation` object. Returns the value as a `TextOperation` if it is one.
### Static methods
#### `inverse(op: Operation) => Operation`
Invert an operation, returning a new operation that will exactly undo the original when applied.

View File

@ -150,7 +150,7 @@ export interface OperationInterface {
// eslint-disable-next-line no-redeclare
export const Operation: OperationInterface = {
/**
* Check of a value is a `NodeOperation` object.
* Check if a value is a `NodeOperation` object.
*/
isNodeOperation(value: any): value is NodeOperation {
@ -158,7 +158,7 @@ export const Operation: OperationInterface = {
},
/**
* Check of a value is an `Operation` object.
* Check if a value is an `Operation` object.
*/
isOperation(value: any): value is Operation {
@ -226,7 +226,7 @@ export const Operation: OperationInterface = {
},
/**
* Check of a value is a `SelectionOperation` object.
* Check if a value is a `SelectionOperation` object.
*/
isSelectionOperation(value: any): value is SelectionOperation {
@ -234,7 +234,7 @@ export const Operation: OperationInterface = {
},
/**
* Check of a value is a `TextOperation` object.
* Check if a value is a `TextOperation` object.
*/
isTextOperation(value: any): value is TextOperation {