🎉 The Slate Plugins project has evolved to Plate 🎉
To migrate, find and replace all occurrences of:
slate-plugins
toplate
SlatePlugins
toPlate
SlatePlugin
toPlatePlugin
This is the last version of
@udecode/slate-plugins[-x]
, please install@udecode/plate[-x]
.
- #869
7c26cf32
Thanks @zbeyens! - - New plugin optiondeserialize.getFragment
: Function called oneditor.insertData
to filter the fragment to insert.- New plugin option
deserialize.preInsert
: Function called oneditor.insertData
just beforeeditor.insertFragment
. Default: if the block above the selection is empty and the first fragment node type is not inline, set the selected node type to the first fragment node type. If returns true, the next handlers will be skipped.
- New plugin option
- #855
75b39f18
Thanks @zbeyens! - Sometimes we want to preventDefault without stopping the handler pipeline, so we remove this check. In summary, to stop the pipeline, a handler has to returntrue
or runevent.stopPropagation()
- #853
abaf4a11
Thanks @zbeyens! - Before, the handlers had to returnfalse
to prevent the next handlers to be called. Now, we reuseisEventHandled
internally used by[email protected]
which has the opposite behavior: a handler has to returntrue
to stop the pipeline. Additionally, the pipeline stops if at any momentevent.isDefaultPrevented()
orevent.isPropagationStopped()
returnstrue
, except if the handler returnsfalse
. See the updated docs in "Creating Plugins".
- #840
42360b44
Thanks @zbeyens! - fix:- Plugin handlers are now run when a handler is passed to
editableProps
- If one handler returns
true
, slate internal corresponding handler is not called anymore
- Plugin handlers are now run when a handler is passed to
- #773
15048e6f
Thanks @zbeyens! - fix: before, store setValue was called at the start ofonChange
pipeline. Now, it's called at the end of the pipeline so we can make use of this value as the "previous value" in pluginsonChange
.
- #723
806e1632
Thanks @Aedron! - feat: newSlatePlugins
option -renderEditable
: CustomEditable
node
- #687
dfbde8bd
Thanks @zbeyens! - changes:- renamed:
useTSlate
touseEditorState
useTSlateStatic
touseEditorRef
useStoreEditor
touseStoreEditorRef
- removed:
useEditorId
in favor ofuseEditorRef().id
useEditorOptions
in favor ofuseEditorRef().options
useSlatePluginOptions
in favor ofgetSlatePluginOptions(useEditorRef(), pluginKey)
useSlatePluginType
in favor ofgetSlatePluginType(useEditorRef(), pluginKey)
pipeOnDOMBeforeInput
in favor ofpipeHandler
pipeOnKeyDown
in favor ofpipeHandler
- types:
- renamed:
SlatePluginsState
toSlatePluginsStates
State
toSlatePluginsState
- removed:
OnDOMBeforeInput
in favor ofDOMHandler<'onDOMBeforeInput'>
OnKeyDown
in favor ofKeyboardHandler
- renamed:
- renamed:
- #687
dfbde8bd
Thanks @zbeyens! - changes:useEditableProps
(used bySlatePlugins
):- new fields returned: all handler props from the plugins (if defined)
- new core plugins with the following fields:
onFocus: setEventEditorId('focus', id)
onBlur: setEventEditorId('blur', id)
- You can add your own handlers in a plugin
EditorStateEffect
: a new component used bySlatePlugins
to update the editor state.setEventEditorId
: a new action. Set an editor id by event key.eventEditorStore
,useEventEditorStore
: a new store. Store where the keys are event names and the values are editor ids.useEventEditorId
: a new selector. Get the editor id byevent
key.useStoreEditorSelection
: a new selector. Get the editor selection which is updated on editor change.useStoreEditorState
: a new selector. Get editor state which is updated on editor change. Similar touseSlate
.SlatePlugin
: the previous plugin could implement the following handlers:onChange
,onDOMBeforeInput
andonKeyDown
. The plugins now implement all DOM handlers: clipboard, composition, focus, form, image, keyboard, media, mouse, selection, touch, pointer, ui, wheel animation and transition events.SlatePluginsState
(store interface):- a new field
keyChange
incremented bySlatePlugins
onuseSlate
update. - a new field
selection = editor.selection
updated onuseSlate
update.
- a new field
pipeHandler
: a new function. Generic pipe for handlers.