Changelog History
Page 7
-
v0.31.0 Changes
November 16, 2017NEW โ Added a new
Operation
model. This model is used to store operations for the history stack, and (de)serializes them in a consistent way for collaborative editing use cases.BREAKING Operation objects in Slate are now immutable records. Previously they were native, mutable JavaScript objects. Now, there's a new immutable
Operation
model in Slate, ensuring that all of the data insideValue
objects are immutable. And it allows for easy serialization of operations usingoperation.toJSON()
for when sending them between editors. This should not affect most users, unless you are relying on changing the values of the low-level Slate operations (simply reading them is fine).Operation lists in Slate are now immutable lists. Previously they were native, mutable JavaScript arrays. Now, to keep consistent with other immutable uses, they are immutable lists. This should not affect most users.
-
v0.30.0 Changes
October 27, 2017BREAKING โ Remove all previously deprecated code paths. This helps to reduce some of the complexity in Slate by not having to handle these code paths anymore. And it helps to reduce file size. When upgrading, it's highly recommended that you upgrade to the previous version first and ensure there are no deprecation warnings being logged, then upgrade to this version.
-
v0.29.0 Changes
October 27, 2017NEW โ Added the new
Value
model to replaceState
. The new model is exactly the same, but with a new name. There is also a shimmedState
model exported that warns when used, to ease migration.BREAKING The
set_state
operation has been renamedset_value
. This shouldn't affect almost anyone, but in the event that you were relying on the low-level operation types you'll need to update this.๐ ###### DEPRECATED
The "state" has been renamed to "value" everywhere. All of the current references are maintained as deprecations, so you should be able to upgrade and see warnings logged instead of being greeted with a broken editor. This is to reduce the confusion between React's "state" and Slate's editor value, and in an effort to further mimic the native DOM APIs.
-
v0.28.0 Changes
October 25, 2017NEW State
objects now have an embeddedstate.schema
property. This new schema property is used to automatically normalize the state as it changes, according to the editor's current schema. This makes normalization much easier.BREAKING The
Schema
objects in Slate have changed! Previously, they used to be where you could define normalization rules, define rendering rules, and define decoration rules. This was overloaded, and made other improvements hard. Now, rendering and decorating is done via the newly added plugin functions (renderNode
,renderMark
,decorateNode
). And validation is done either via the lower-levelvalidateNode
plugin function, or via the newschema
objects.The
normalize*
change methods no longer take aschema
argument. Previously you had to maintain a reference to your schema, and pass it into the normalize methods when you called them. SinceState
objects now have an embeddedstate.schema
property, this is no longer needed.
-
v0.27.0 Changes
October 14, 2017BREAKING The
Range
model is now calledLeaf
. This is to disambiguate with the concept of "ranges" that is used throughout the codebase to be synonymous to selections. For example in methods likegetBlocksAtRange(selection)
.The
text.ranges
property in the JSON representation is nowtext.leaves
. When passing in JSON withtext.ranges
you'll now receive a deprecation warning in the console in development.๐ ###### DEPRECATED
The
Selection
model is now calledRange
. This is to make it more clear what a "selection" really is, to make many of the other methods that act on "ranges" make sense, and to more closely parallel the native DOM API for selections and ranges. A mockSelection
object is still exported with deprecatedstatic
methods, to make the transition to the new API easier.The
Text.getRanges()
method is nowText.getLeaves()
. It will still work, and it will return a list of leaves, but you will see a deprecation warning in the console in development.
-
v0.26.0 Changes
October 13, 2017BREAKING 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.
-
v0.25.0 Changes
September 21, 2017BREAKING The
insertBlock
change method no longer replaces empty blocks. Previously if you usedinsertBlock
and the selection was in an empty block, it would replace it. Now you'll need to perform that check yourself and use the newreplaceNodeByKey
method instead.The
Block.create
andInline.create
methods no longer normalize. Previously if you used one of them to create a block or inline with zero nodes in it, they would automatically add a single empty text node as the only child. This was unexpected in certain situations, and if you were relying on this you'll need to handle it manually instead now.
-
v0.24.0 Changes
September 11, 2017NEW Slate is now a "monorepo". Instead of a single package, Slate has been divided up into individual packages so that you can only require what you need, cutting down on file size. In the process, some helpful modules that used to be internal-only are now exposed.
There's a new
slate-hyperscript
helper. This was possible thanks to the work onslate-sugar
, which paved the way.๐ฆ The
slate-prop-types
package is now exposed. Previously this was an internal module, but now you can use it for adding prop types to any components or plugins you create.๐ฆ The
slate-simulator
package is now exposed. Previously this was an internal testing utility, but now you can use it in your own tests as well. It's currently pretty bare bones, but we can add to it over time.BREAKING immutable
is now a peer dependency of Slate. Previously it was a regular dependency, but this prevented you from bringing your own version, or you'd have duplication. You'll need to ensure you install it!๐ฆ The
Html
,Plain
andRaw
serializers are broken into new packages. Previously you'd import them fromslate
. But now you'll import them fromslate-html-serializer
andslate-plain-serializer
. And theRaw
serializer that was deprecated is now removed.๐ฆ The
Editor
andPlaceholder
components are broken into a new React-specific package. Previously you'd import them fromslate
. But now youimport { Editor } from 'slate-react'
instead.
-
v0.23.0 Changes
September 10, 2017NEW Slate models now have
Model.fromJSON(object)
andmodel.toJSON()
methods. These methods operate with the canonical JSON form (which used to be called "raw"). This way you don't need toimport
a serializer to retrieve JSON, if you have the model you can serialize/deserialize.Models also have
toJS
andfromJS
aliases. This is just to match Immutable.js objects, which have both methods. For Slate though, the methods are equivalent.BREAKING ๐ The
isNative
property ofState
has been removed. Previously this was used for performance reasons to avoid re-rendering, but it is no longer needed. This shouldn't really affect most people because it's rare that you'd be relying on this property to exist.๐ ###### DEPRECATED
๐ The
Raw
serializer is now deprecated. The entire "raw" concept is being removed, in favor of allowing all models to be able to serialize and deserialize to JSON themselves. Instead of using theRaw
serializer, you can now use thefromJSON
andtoJSON
on the models directly.The
toRaw
options for thePlain
andHtml
serializers are now calledtoJSON
. This is to stay symmetrical with the removal of the "raw" concept everywhere.๐ The
terse
option for JSON serialization has been deprecated! This option causes lots of abstraction leakiness because it means there is no one canonical JSON representation of objects. You had to work with either terse or not terse data.The
Html
serializer no longer uses theterse
representation. This shouldn't actually be an issue for anyone because the main manifestation of this has a deprecation notice with a patch in place for now.0๏ธโฃ The
defaultBlockType
of theHtml
serializer is now calleddefaultBlock
. This is just to make it more clear that it supports not only setting the defaulttype
but alsodata
andisVoid
.
-
v0.22.10
November 10, 2019