1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 09:59:48 +02:00

Update change.md to include setValue (#1670)

* Update change.md

* Update change.md

* Update change.md

* Update change.md

* Update change.md
This commit is contained in:
Sunny Hirai
2018-04-27 15:55:08 -07:00
committed by Ian Storm Taylor
parent 7c76fe7120
commit 360c522a45

View File

@@ -78,6 +78,19 @@ validateNode(node) {
}
```
## Full Value Change
### `setValue`
`setValue(properties: Object, [options: Object]) => Change` <br/>
`setValue(value: Value, [options: Object]) => Change` (see warning below)
Set the entire `value` using either a `properties` object or a `Value` object. Can be used to set `value.data` and other properties that cannot otherwise be easily set using the available methods.
Warning: Calling `setValue` with a `Value` object has unpredictable behavior including the loss of the edit history. Only use with a `Value` object if you know what you are doing. For most use cases, we recommend passing `properties` as an `Object` (e.g. `change.setValue({data: myNewDataObject})`.
Hint: Wrapping the call to `setValue` as follows can be helpful if you want to update a value, like in the value's `data` but do not want to have another save point in the undo history: `change.setOperationFlag({save: false}).change({data: myNewDataObject}).setOperationFlag({save: true}).
## Current Value Changes
These changes act on the `document` based on the current `selection`. They are equivalent to calling the [Document Changes](#document-changes) with the current selection as the `range` argument, but they are there for convenience, since you often want to act with the current selection, as a user would.