6.6 KiB
Changelog
This document maintains a list of changes to the slate-react
package with each new version. Until 1.0.0
is released, breaking changes will be added as minor version bumps, and smaller changes won't be accounted for since the library is moving quickly.
0.8.0
— October 25, 2017
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
plugin.onBeforeChange
function was removed. Previously there was both anonBeforeChange
handler and anonChange
handler. Now there is just anonChange
handler, and the core plugin adds it's own logic before others.
NEW
-
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. -
A new
renderNode
plugin function was added. This is the new way to render nodes, instead of using the schema. Any plugin can define arenderNode(props)
function which is passed the props to render the custom node component with. This is similar toreact-router
'srender={...}
prop if you are familiar with that. -
A new
renderPlaceholder
plugin function was added. This is similar to therenderNode
helper, except for rendering placeholders. -
A new
decorateNode
plugin function was added. This is similar to the oldrule.decorate
function from schemas. Any plugin can define adecorateNode(node)
function and that can return extra decoration ranges of marks to apply to the document. -
A new
validateNode
plugin function was added. This is the new way to do specific, custom validations. (There's also the new schema, which is the easier way to do most common validations.) Any plugin can define avalidateNode(node)
function that will be called to ensure nodes are valid. If they are valid, the function should return nothing. Otherwise, it should return a change function that normalizes the node to make it valid again.
0.7.0
— October 18, 2017
BREAKING
- The
<Placeholder>
component no longer exists! Previously there was aPlaceholder
component exported fromslate-react
, but it had lots of problems and a confusing API. Instead, placeholder logic can now be defined via theschema
by providing aplaceholder
component to render what a node is matched.
0.6.0
— October 16, 2017
BREAKING
- The
data
argument to event handlers has been removed. Previously event handlers had a signature of(event, data, change, editor)
, but now they have a signature of just(event, change, editor)
. This leads to simpler internal Slate logic, and less complex relationship dependencies between plugins. All of the information inside the olddata
argument can be accessed via the similar properties on theevent
argument, or via thegetEventRange
,getEventTransfer
andsetEventTransfer
helpers.
NEW
-
Added a new
setEventTransfer
helper. This is useful if you're working withonDrop
oronPaste
event and you want to set custom data in the event, to retrieve later or for others to consume. It takes a datatype
and avalue
to set the type do. -
Event handlers now have access to new events. The
onClick
,onCompositionEnd
,onCompositionStart
,onDragEnd
,onDragEnter
,onDragExit
,onDragLeave
,onDragOver
,onDragStart
, andonInput
events are all now newly exposed. Your plugin logic can use them to solve some more advanced use cases, and even override the internal Slate logic when necessary. 99% of use cases won't require them still, but they can be useful to have when needed.
0.5.0
— October 15, 2017
DEPRECATED
- The
data
objects in event handlers have been deprecated. There were a few different issues with these "helpers":data.key
didn't account for international keyboards, many properties awkwardly duplicated information that was available onevent.*
, but not completely, and many properties were confusing as to when they applied. If you were using these, you'll now need to use the nativeevent.*
properties instead. There's also a helpfulis-hotkey
package for more complex hotkey matching.
NEW
-
Added a new
getEventRange
helper. This gets the affectedRange
of Slate document given a DOMevent
. This is useful in theonDrop
oronPaste
handlers to retrieve the range in the document where the drop or paste will occur. -
Added a new
getEventTransfer
helper. This gets any Slate-related data from anevent
. It is modelled after the DOM'sDataTransfer
API, and is useful for retrieve the data being dropped or pasted inonDrop
oronPaste
events.
0.4.0
— October 14, 2017
BREAKING
- Updated work with
slate@0.27.0
. The new version of Slate renames the oldRange
model toLeaf
, and the oldSelection
model toRange
.
NEW
-
Added a new
findDOMRange
helper. Give a SlateRange
object, it will return a DOMRange
object with the correct start and end points, making it easier to work with lower-level DOM selections. -
Added a new
findRange
helper. Given either a DOMSelection
or DOMRange
object and a SlateState
, it will return a SlateRange
representing the same part of the document, making it easier to work with DOM selection changes. -
Added a new
findNode
helper. Given a DOMElement
, it will find the closest SlateNode
that it represents, making
0.3.0
— October 13, 2017
BREAKING
- The decoration logic has been updated to use
slate@0.26.0
. This allows for more complex decoration logic, and even decorations based on external information.
0.2.0
— September 29, 2017
BREAKING
onBeforeChange
is now called automatically again in<Editor>
. This was removed before, in attempt to decrease the "magic" that the editor was performing, since it normalizes when new props are passed to it, creating instant changes. But we discovered that it is actually necessary for now, so it has been added again.
0.1.0
— September 17, 2017
🎉