Major Changes
-
editor.getType()
now takes apluginKey: string
instead of aplugin: PlatePlugin
instance.- Example: Use
editor.getType(ParagraphPlugin.key)
instead ofeditor.getType(ParagraphPlugin)
.
- Example: Use
- Plugins without a
key
property will not be registered into the editor. - Passing
disabled: true
prop toPlateContent
will now also set the editor toreadOnly: true
state internally. - Editor DOM state properties have been moved under
editor.dom
namespace:editor.currentKeyboardEvent
is noweditor.dom.currentKeyboardEvent
.editor.prevSelection
is noweditor.dom.prevSelection
.
- Editor metadata properties have been moved under
editor.meta
namespace:editor.isFallback
is noweditor.meta.isFallback
editor.key
is noweditor.meta.key
editor.pluginList
is noweditor.meta.pluginList
editor.shortcuts
is noweditor.meta.shortcuts
editor.uid
is noweditor.meta.uid
NodeIdPlugin
is now enabled by default as part of the core plugins. This automatically assigns unique IDs to block nodes.- Migration: If you were not previously using
NodeIdPlugin
and wish to maintain the old behavior (no automatic IDs), explicitly disable it in your editor configuration:const editor = usePlateEditor({ // ...other options nodeId: false, // Disables automatic node ID generation });
- Migration: If you were not previously using
- The
components
prop has been removed fromserializeHtml
andPlateStatic
.- Migration: Pass the
components
tocreateSlateEditor({ components })
or the individual plugins instead.
- Migration: Pass the
- Plugin Shortcuts System Changes:
- Shortcut keys defined in
editor.shortcuts
are now namespaced by the plugin key (e.g.,code.toggle
forCodePlugin
). - The
priority
property for shortcuts is used to resolve conflicts when multiple shortcuts share the exact same key combination, not for overriding shortcuts by name. preventDefault
for plugin shortcuts now defaults totrue
, unless the handler returnsfalse
(i.e. not handled). This means browser default actions for these key combinations will be prevented unless explicitly allowed.- Migration: If you need to allow browser default behavior for a specific shortcut, set
preventDefault: false
in its configuration:MyPlugin.configure({ shortcuts: { myAction: { keys: 'mod+s', preventDefault: false, // Example: Allow browser's default save dialog }, }, });
- Migration: If you need to allow browser default behavior for a specific shortcut, set
- Shortcut keys defined in
-
- Renamed all
@udecode/plate-*
packages to@platejs/*
. Replace@udecode/plate-
with@platejs/
in your code.
- Renamed all
Minor Changes
- #4327 by @zbeyens –
- New editor DOM state fields available under
editor.dom
:editor.dom.composing
: Boolean, true if the editor is currently composing text (e.g., during IME input).editor.dom.focused
: Boolean, true if the editor currently has focus.editor.dom.readOnly
: Boolean, true if the editor is in read-only mode. Passing thereadOnly
prop toPlateContent
will sync its value to this state and to theuseEditorReadOnly
hook.
- New editor metadata fields:
editor.meta.components
- stores the plugin components by key
- New hook
useEditorComposing
: Allows subscription to the editor's composing state (editor.dom.composing
) outside ofPlateContent
. createPlateEditor
andusePlateEditor
now accept areadOnly
option to initialize the editor in a read-only state. For dynamic read-only changes after initialization, continue to use thereadOnly
prop on the<Plate>
or<PlateContent>
component.- New plugin field:
editOnly
(boolean or object).- When
true
or when specific properties are true in the object, Plate will disable certain plugin behaviors (handlers, rendering, injections) in read-only mode and re-enable them if the editor becomes editable. - By default,
render
,handlers
, andinject
are considered edit-only (true
).normalizeInitialValue
defaults to always active (false
). - Example:
editOnly: { render: false, normalizeInitialValue: true }
would make rendering active always, but normalization only in edit mode.
- When
- New plugin field:
node.clearOnEdge
(boolean).- When enabled for mark plugins (
node.isLeaf: true
), this feature automatically clears the mark when the user types at the boundary of the marked text. This provides a natural way to "exit" a mark. This is utilized by suggestion and comment marks.
- When enabled for mark plugins (
- New plugin field:
render.as
(keyof HTMLElementTagNameMap
).- Specifies the default HTML tag name to be used by
PlateElement
(default:'div'
) orPlateLeaf
(default:'span'
) when rendering the node, but only if no customnode.component
is provided for the plugin. - Example:
render: { as: 'h1' }
would make the plugin render its node as an<h1>
tag by default without the need to provide a custom component.
- Specifies the default HTML tag name to be used by
- New plugin field:
node.isContainer
(boolean).- When
true
, indicates that the plugin's elements are primarily containers for other content.
- When
- New plugin field:
node.isStrictSiblings
(boolean).- When
true
, indicates that the element enforces strict sibling type constraints and only allows specific siblings (e.g.,td
can only havetd
siblings,column
can only havecolumn
siblings). - Used by
editor.tf.insertExitBreak
functionality to determine appropriate exit points in nested structures.
- When
- New plugin field:
rules
(object).- Configures common editing behaviors declaratively instead of overriding editor methods. See documentation for more details.
rules.break
: Controls Enter key behavior (empty
,default
,emptyLineEnd
,splitReset
)rules.delete
: Controls Backspace key behavior (start
,empty
)rules.merge
: Controls block merging behavior (removeEmpty
)rules.normalize
: Controls normalization behavior (removeEmpty
)rules.selection
: Controls cursor positioning behavior (affinity
)rules.match
: Conditional rule application based on node properties
- Plugin shortcuts can now automatically leverage existing plugin transforms by specifying the transform name, in addition to custom handlers.
- New editor transform methods for keyboard handling:
editor.tf.escape
: Handle Escape key events. Returnstrue
if the event is handled.editor.tf.moveLine
: Handle ArrowDown and ArrowUp key events withreverse
option for direction. Returnstrue
if the event is handled.editor.tf.selectAll
: Handle Ctrl/Cmd+A key events for selecting all content. Returnstrue
if the event is handled.editor.tf.tab
: Handle Tab and Shift+Tab key events withreverse
option for Shift+Tab. Returnstrue
if the event is handled.
- New editor DOM state fields available under