mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-13 18:53:59 +02:00
Add documentation for the Operation.data
property (#2377)
* Add documentation for the `Operation.data` property * Fix typo in documentation for `Operation` model
This commit is contained in:
committed by
Ian Storm Taylor
parent
b773d44ae9
commit
a8972f3f3d
@@ -6,6 +6,12 @@ All of the [`Commands`](./commands.md) methods result in operations being create
|
|||||||
|
|
||||||
There are a handful of Slate operation types. The goal is to have the fewest possible types, while still maintaining the necessary semantics for collaborative editing to work.
|
There are a handful of Slate operation types. The goal is to have the fewest possible types, while still maintaining the necessary semantics for collaborative editing to work.
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
See each operation separately below to see what they consist of.
|
||||||
|
|
||||||
|
Note that all operations have a `data` property which can be used to attach arbitrary data to the operation, just like the [`Node`](./node.md) models ([`Block`](./block.md), [`Inline`](./inline.md), etc).
|
||||||
|
|
||||||
## Text Operations
|
## Text Operations
|
||||||
|
|
||||||
### `insert_text`
|
### `insert_text`
|
||||||
@@ -17,6 +23,7 @@ There are a handful of Slate operation types. The goal is to have the fewest pos
|
|||||||
offset: Number,
|
offset: Number,
|
||||||
text: String,
|
text: String,
|
||||||
marks: List,
|
marks: List,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -30,6 +37,7 @@ Inserts a `text` string at `offset` into a text node at `path`, with optional `m
|
|||||||
path: List,
|
path: List,
|
||||||
offset: Number,
|
offset: Number,
|
||||||
text: String,
|
text: String,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -46,6 +54,7 @@ Removes a string of `text` at `offset` into a text node at `path`.
|
|||||||
offset: Number,
|
offset: Number,
|
||||||
length: Number,
|
length: Number,
|
||||||
mark: Mark,
|
mark: Mark,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -60,6 +69,7 @@ Adds a `mark` to the text node at `path` starting at an `offset` and spanning `l
|
|||||||
offset: Number,
|
offset: Number,
|
||||||
length: Number,
|
length: Number,
|
||||||
mark: Mark,
|
mark: Mark,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -75,6 +85,7 @@ Removes a `mark` from a text node at `path` starting at an `offset` and spanning
|
|||||||
length: Number,
|
length: Number,
|
||||||
mark: Mark,
|
mark: Mark,
|
||||||
properties: Object,
|
properties: Object,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -89,6 +100,7 @@ Set new `properties` on any marks that match an existing `mark` in a text node a
|
|||||||
type: 'insert_node',
|
type: 'insert_node',
|
||||||
path: List,
|
path: List,
|
||||||
node: Node,
|
node: Node,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -102,6 +114,7 @@ Insert a new `node` at `path`.
|
|||||||
path: List,
|
path: List,
|
||||||
position: Number,
|
position: Number,
|
||||||
properties: Object,
|
properties: Object,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -114,6 +127,7 @@ Merge the node at `path` with its previous sibling. The `position` refers to eit
|
|||||||
type: 'move_node',
|
type: 'move_node',
|
||||||
path: List,
|
path: List,
|
||||||
newPath: Array,
|
newPath: Array,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -126,6 +140,7 @@ Move the node at `path` to a `newPath`.
|
|||||||
type: 'remove_node',
|
type: 'remove_node',
|
||||||
path: List,
|
path: List,
|
||||||
node: Node,
|
node: Node,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -139,6 +154,7 @@ Remove the node at `path`.
|
|||||||
path: List,
|
path: List,
|
||||||
properties: Object,
|
properties: Object,
|
||||||
node: Node,
|
node: Node,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -153,6 +169,7 @@ Set new `properties` on the node at `path`.
|
|||||||
position: Number,
|
position: Number,
|
||||||
target: Number,
|
target: Number,
|
||||||
properties: Object,
|
properties: Object,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -167,6 +184,7 @@ Split the node at `path` at `position`. The `position` refers to either the inde
|
|||||||
type: 'set_selection',
|
type: 'set_selection',
|
||||||
properties: Object,
|
properties: Object,
|
||||||
selection: Selection,
|
selection: Selection,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -179,6 +197,7 @@ Set new `properties` on the selection.
|
|||||||
type: 'set_value',
|
type: 'set_value',
|
||||||
properties: Object,
|
properties: Object,
|
||||||
value: Value,
|
value: Value,
|
||||||
|
data: Map,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user