mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 02:49:56 +02:00
add change.setOperationFlag for setting the save and merge flags
This commit is contained in:
@@ -41,7 +41,7 @@ function onKeyDown(e, data, change) {
|
||||
|
||||
- **The `onChange` and `on[Before]Change` handlers now receive `Change` objects.** Previously they would also receive a `state` object, but now they receive `change` objects like the rest of the plugin API.
|
||||
|
||||
- **The `.apply({ save })` option is now `state.change({ save })` instead.** This is the easiest way to use it, but requires that you know whether to save or not up front. If you want to use it inline after already saving some changes, you can use the `change.setSave(save)` flag instead. This shouldn't be necessary for 99% of use cases though.
|
||||
- **The `.apply({ save })` option is now `state.change({ save })` instead.** This is the easiest way to use it, but requires that you know whether to save or not up front. If you want to use it inline after already saving some changes, you can use the `change.setOperationFlag('save', true)` flag instead. This shouldn't be necessary for 99% of use cases though.
|
||||
|
||||
- **The `.undo()` and `.redo()` transforms don't save by default.** Previously you had to specifically tell these transforms not to save into the history, which was awkward. Now they won't save the operations they're undoing/redoing by default.
|
||||
|
||||
|
@@ -126,7 +126,32 @@ class Change {
|
||||
}
|
||||
|
||||
/**
|
||||
* Noop.
|
||||
* Set an operation flag by `key` to `value`.
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {Any} value
|
||||
* @return {Change}
|
||||
*/
|
||||
|
||||
setOperationFlag(key, value) {
|
||||
this.flags[key] = value
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset an operation flag by `key`.
|
||||
*
|
||||
* @param {String} key
|
||||
* @return {Change}
|
||||
*/
|
||||
|
||||
unsetOperationFlag(key) {
|
||||
delete this.flags[key]
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @return {State}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user