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

update changelog, add deprecation logging

This commit is contained in:
Ian Storm Taylor
2017-10-13 12:21:54 -07:00
parent e53cee3942
commit 253971135f
3 changed files with 38 additions and 0 deletions

View File

@@ -7,6 +7,28 @@ This document maintains a list of changes to the `slate` package with each new v
---
### `0.26.0` — October 13, 2017
###### BREAKING
- **The `decorate` function of schema rules has changed.** Previously, in `decorate` you would receive a text node and the matched node, and you'd need to manually add any marks you wanted to the text node's characters. Now, "decorations" have changed to just be `Selection` objects with marks in the `selection.marks` property. Instead of applying the marks yourself, you simply return selection ranges with the marks to be applied, and Slate will apply them internally. This makes it possible to write much more complex decoration behaviors. Check out the revamped [`code-highlighting`](https://github.com/ianstormtaylor/slate/blob/master/examples/code-highlighting/index.js) example and the new [`search-highlighting`](https://github.com/ianstormtaylor/slate/blob/master/examples/search-highlighting/index.js) example to see this in action.
- **The `set_data` operation type has been replaced by `set_state`.** With the new `state.decorations` property, it doesn't make sense to have a new operation type for every property of `State` objects. Instead, the new `set_state` operation more closely mimics the existing `set_mark` and `set_node` operations.
###### DEPRECATED
- **The `setData` change method has been replaced by `setState`.** Previously you would call `change.setData(data)`. But as new `State` properties are introduced it doesn't make sense to need to add new change methods each time. Instead, the new `change.setState(properties)` more closesely mimics the existing `setMarkByKey` and `setNodeByKey`. To achieve the old behavior, you can do `change.setState({ data })`.
- **The `preserveStateData` option of `state.toJSON` has changed.** The same behavior is now called `preserveData` instead. This makes it consistent with all of the existing options, and the new `preserveDecorations` option as well.
###### NEW
- **You can now set decorations based on external information.** Previously, the "decoration" logic in Slate was always based off of the text of a node, and would only re-render when that text changed. Now, there is a new `state.decorations` property that you can set via `change.setState({ decorations })`. You can use this to add presentation-only marks to arbitrary ranges of text in the document. Check out the new [`search-highlighting`](https://github.com/ianstormtaylor/slate/blob/master/examples/search-highlighting/index.js) example to see this in action.
---
### `0.25.0` — September 21, 2017
###### BREAKING

View File

@@ -1,4 +1,6 @@
import logger from 'slate-dev-logger'
import State from '../models/state'
/**
@@ -27,6 +29,15 @@ Changes.setState = (change, properties) => {
})
}
/**
* Deprecated.
*/
Changes.setData = (change, data) => {
logger.deprecate('0.26.0', 'The `change.setData` method is deprecated, use `change.setState` instead.')
change.setState({ data })
}
/**
* Export.
*

View File

@@ -607,6 +607,11 @@ class State extends Record(DEFAULTS) {
history: this.history.toJSON(),
}
if ('preserveStateData' in options) {
logger.deprecate('0.26.0', 'The `preserveStateData` option to `state.toJSON` has been deprecated in favor of `options.preserveData`.')
options.preserveData = options.preserveStateData
}
if (!options.preserveData) {
delete object.data
}