slate v0.46.0 Release Notes
Release Date: 2019-05-01 // almost 5 years ago-
BREAKING
Mark operations no longer have
offset
orlength
properties. Since text nodes now contain a unique set of marks, it wouldn't make sense for a single mark-related operation to result in a splitting of nodes. Instead, when a mark is added to only part of a text node, it will result in asplit_node
operation as well as anadd_mark
operation.Text operations no longer have a
marks
property. Previously it was used to add text with a specific set of marks. However this is no longer necessary, and when text is added with marks it will result in aninsert_text
operation as well as anadd_mark
operation.Using
Text.create
orText.createList
with aleaves
property will error. Now that text nodes no longer have leaves, you will need to pass in thetext
string andmarks
directly when creating a new text node. (However, you can still create entire values usingValue.create
in a backwards compatible way for convenience while migrating.)// This works, although deprecated, which is the common case... Value.create(oldValueJson) // ...but this will error! Text.create(oldTextJson)
Value.toJSON
returns the new data model format, without leaves. AlthoughValue.fromJSON
andValue.create
allow the old format in deprecated mode, callingValue.toJSON
will return the new data format. If you still need the old one you'll need to iterate the document tree converting text nodes yourself.The low-level
Value.*
andNode.*
mutation methods have changed. These changes follow the operation signature changes, since the methods take the same arguments as the operations themselves. For example:// Previously... value.addMark(path, offset, length, mark) // ...is now: value.addMark(path, mark)
These are low-level methods, so this change shouldn't affect the majority of use cases.
๐ ###### DEPRECATED
๐ Initializing editors with
Text
nodes with aleaves
property is deprecated. In this new version of Slate, creating a new value withValue.create
with the old leaf data model is still allowed for convenience in migration, but it will be removed in a coming version. (However, using the low-levelText.create
will throw an error!)// This works, although deprecated, which is the common case... Value.create(oldValueJson) // ...but this will error! Text.create(oldTextJson)