slate v0.26.0 Release Notes
Release Date: 2017-10-13 // over 6 years ago-
BREAKING
The
decorate
function of schema rules has changed. Previously, indecorate
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 beSelection
objects with marks in theselection.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 revampedcode-highlighting
example and the newsearch-highlighting
example to see this in action.The
set_data
operation type has been replaced byset_state
. With the newstate.decorations
property, it doesn't make sense to have a new operation type for every property ofState
objects. Instead, the newset_state
operation more closely mimics the existingset_mark
andset_node
operations.🗄 ###### DEPRECATED
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 viachange.setState({ decorations })
. You can use this to add presentation-only marks to arbitrary ranges of text in the document. Check out the newsearch-highlighting
example to see this in action.The
setData
change method has been replaced bysetState
. Previously you would callchange.setData(data)
. But as newState
properties are introduced it doesn't make sense to need to add new change methods each time. Instead, the newchange.setState(properties)
more closesely mimics the existingsetMarkByKey
andsetNodeByKey
. To achieve the old behavior, you can dochange.setState({ data })
.The
preserveStateData
option ofstate.toJSON
has changed. The same behavior is now calledpreserveData
instead. This makes it consistent with all of the existing options, and the newpreserveDecorations
option as well.