@udecode/[email protected]
-
#2537 by @haydencarlson –
MediaEmbedElement
is now more headless with a smaller bundle size. Update the following components:npx @udecode/plate-ui@latest add media-embed-element
- now uses
react-lite-youtube-embed
for YouTube videos. - now uses
react-tweet
for Twitter tweets.
- now uses
npx @udecode/plate-ui@latest add image-element
Breaking changes:
- Moved
Resizable
to@udecode/plate-resizable
- Moved
Caption
,CaptionTextarea
to@udecode/plate-caption
- Removed
useMediaEmbed
,MediaEmbedVideo
,MediaEmbedTweet
,Tweet
,parseMediaUrl
,mediaStore
- Removed
@udecode/resizable
,scriptjs
,react-textarea-autosize
dependencies MediaPlugin
- removed
rules
. Useparsers
option instead. - removed
disableCaption
. UsecreateCaptionPlugin
instead.
- removed
- Caption is now a separate plugin. Install
@udecode/plate-caption
and add it to your plugins:
import { ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED } from '@udecode/plate-media'; createCaptionPlugin({ options: { pluginKeys: [ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED] }, });
@udecode/[email protected]
- #2541 by @zbeyens –
- Package renamed to
@udecode/plate-resizable
. ResizeHandle
is now fully headless: no style is applied by default. Add your ownResizable
,ResizeHandle
components:npx @udecode/plate-ui@latest add resizable
- Package renamed to
@udecode/[email protected]
- Removed
TableCellElementResizable
. UseuseTableCellElementResizableState
anduseTableCellElementResizable
instead.
Headless UI.
@udecode/[email protected]
- #2471 by @zbeyens – This package is now a CLI to generate components. Install it as a dev dependency. See https://platejs.org/docs/components/cli.
Migration:
- Manual installation.
- For each unresolved import not listed in the following major changes (components from
@udecode/plate-ui-x
), generate the component using the CLI.
@udecode/[email protected]
- #2471 by @zbeyens – Removed:
AccountCircleIcon
CheckIcon
MoreVertIcon
RefreshIcon
AvatarImage
CommentLinkButton
CommentLinkDialog
CommentLinkDialogCloseButton
CommentLinkDialogCopyLink
CommentLinkDialogInput
PlateCommentLeaf
foruseCommentLeafState
@udecode/[email protected]
- #2471 by @zbeyens – Removed:
Draggable
DraggableBlock
DraggableBlockToolbar
DraggableBlockToolbarWrapper
DraggableDropline
DraggableGutterLeftProps
DraggableRoot
DragHandle
@udecode/[email protected]
- #2471 by @zbeyens – Removed:
FloatingLink
FloatingLinkEditButton
FloatingLinkTextInput
UnlinkButton
LaunchIcon
Link
LinkIcon
LinkOffIcon
ShortTextIcon
@udecode/[email protected]
@udecode/[email protected]
-
#2471 by @zbeyens – Plate 2.0 – Headless UI. Read the docs about the new UI pattern: https://platejs.org/docs/components.
- Removed
@udecode/plate-ui
dependency. - Removed
@udecode/plate-emoji
dependency. You can install it separately. - Removed
styled-components
peerDependency.
Replaced
@udecode/plate-headless
dependency (deprecated) by:@udecode/plate-alignment
@udecode/plate-autoformat
@udecode/plate-basic-elements
@udecode/plate-basic-marks
@udecode/plate-block-quote
@udecode/plate-break
@udecode/plate-code-block
@udecode/plate-combobox
@udecode/plate-comments
@udecode/plate-common
@udecode/plate-find-replace
@udecode/plate-floating
@udecode/plate-font
@udecode/plate-heading
@udecode/plate-highlight
@udecode/plate-horizontal-rule
@udecode/plate-indent
@udecode/plate-indent-list
@udecode/plate-kbd
@udecode/plate-line-height
@udecode/plate-link
@udecode/plate-list
@udecode/plate-media
@udecode/plate-mention
@udecode/plate-node-id
@udecode/plate-normalizers
@udecode/plate-paragraph
@udecode/plate-reset-node
@udecode/plate-select
@udecode/plate-serializer-csv
@udecode/plate-serializer-docx
@udecode/plate-serializer-html
@udecode/plate-serializer-md
@udecode/plate-suggestion
@udecode/plate-tabbable
@udecode/plate-table
@udecode/plate-trailing-block
@udecode/resizable
- Removed
@udecode/[email protected]
- #2471 by @zbeyens – Upgraded peer dependencies:
slate-react: >=0.95.0
Removed:useElementPrpos
useWrapElement
createComponentAs
createElementAs
@udecode/[email protected]
- #2471 by @zbeyens – Removed:
TableCellElement
TableCellElementResizableWrapper
TableCellElementRoot
TableElement
TableElementCol
TableElementColGroup
TableElementRoot
TableElementTBody
TableRowElement
ArrowDropDownCircleIcon
BorderAllIcon
BorderBottomIcon
BorderLeftIcon
BorderNoneIcon
BorderOuterIcon
BorderRightIcon
BorderTopIcon
@udecode/[email protected]
- #2369 by @zbeyens – Support
[email protected]
,[email protected]
and[email protected]
by upgrading the peer dependencies.
@udecode/[email protected]
0077402
by @zbeyens –- This package has been split into multiple packages for separation of concerns and decoupled versioning:
@udecode/utils
is a collection of miscellaneous utilities. Can be used by any project.@udecode/slate
is a collection ofslate
experimental features and bug fixes that may be moved intoslate
one day. It's essentially composed of the generic types. Can be used by vanillaslate
consumers without plate.@udecode/slate-react
is a collection ofslate-react
experimental features and bug fixes that that may be moved intoslate-react
one day. It's essentially composed of the generic types. Can be used by vanillaslate-react
consumers without plate.@udecode/plate-core
is the minimalistic core of plate. It essentially includesPlate
,PlateProvider
and their dependencies. Note this package is not dependent on the*-utils
packages.@udecode/slate-utils
is a collection of utils depending on@udecode/slate
. Can be used by vanillaslate
consumers without plate.@udecode/plate-utils
is a collection of utils depending on@udecode/slate-react
and@udecode/plate-core
@udecode/plate-common
re-exports the 6 previous packages and is a dependency of all the other packages. It's basically replacing@udecore/plate-core
as a bundle.
- Removed
getPreventDefaultHandler
since it is no longer needed. Migration:- If using
@udecode/plate
or@udecode/plate-headless
: none - Else: find & replace
@udecode/plate-core
by@udecode/plate-common
- If using
- This package has been split into multiple packages for separation of concerns and decoupled versioning:
@udecode/[email protected]
- #2240 by @OliverWales –
- Add
allowedSchemes
plugin option- Any URL schemes other than
http(s)
,mailto
andtel
must be added toallowedSchemes
, otherwise they will not be included in links
- Any URL schemes other than
- Add
@udecode/[email protected]
- #2251 by @zbeyens –
TablePlugin
optiondisableUnsetSingleColSize
has been renamed and inverted intoenableUnsetSingleColSize
. New default is disabled. Migration:- if using
disableUnsetSingleColSize: true
, the option can be removed - if using
disableUnsetSingleColSize: false
, useenableUnsetSingleColSize: true
- if using
getTableColumnIndex
second parameter type is now:cellNode: TElement
@udecode/[email protected]
-
#2237 by @tmorane – Unstyled logic has been moved to
@udecode/plate-dnd
// before import { createDndPlugin } from '@udecode/plate-ui-dnd'; // after import { createDndPlugin } from '@udecode/plate-dnd';
Only
withPlateDraggable
,withPlateDraggables
andPlateDraggable
are left in@udecode/plate-ui-dnd
. Renamed:withDraggables
->withPlateDraggables
. In the second parameter, draggable props options have been moved underdraggableProps
:
// before { onRenderDragHandle: () => {} styles, } // after { draggableProps: { onRenderDragHandle: () => {} styles, }, }
@udecode/[email protected]
- #2251 by @zbeyens – Headless components and hooks moved to
@udecode/plate-table
, so the following components have been renamed:TableElement
->PlateTableElement
- removed table border to set it at the cell level
margin-left: 1px
to support cell borders- if all columns have a fixed size, the table will have a dynamic width instead of always 100%
TableRowElement
->PlateTableRowElement
TableCellElement
->PlateTableCellElement
- removed td border in favor of td::before. The latter is responsible of having the border and the selected background color.
- z-index: td is 0, td::before is 10, td::before in selected state is 20, handle is 30, handle resize is 40.
- removed
selectedCell
div in favor of::before
TablePopover
->PlateTablePopover
Styled props have been removed.
@udecode/[email protected]
- #2097 by @zbeyens –
- upgrade deps, including typescript support for the new editor methods:
// from "slate": "0.78.0", "slate-history": "0.66.0", "slate-react": "0.79.0" // to "slate": "0.87.0", "slate-history": "0.86.0", "slate-react": "0.88.0"
@udecode/[email protected]
- #2097 by @zbeyens –
- due to esm issues, dnd plugin is not part of plate package anymore. To use it, install
@udecode/plate-ui-dnd
// before import { createDndPlugin } from '@udecode/plate'; // after import { createDndPlugin } from '@udecode/plate-ui-dnd';
- upgrade peerDeps:
// from "slate": ">=0.78.0", "slate-history": ">=0.66.0", "slate-react": ">=0.79.0" // to "slate": ">=0.87.0", "slate-history": ">=0.86.0", "slate-react": ">=0.88.0"
- due to esm issues, dnd plugin is not part of plate package anymore. To use it, install
@udecode/[email protected]
- #1889 by @zbeyens –
@udecode/plate-selection
package moved out from@udecode/plate
because of simonwep/selection#124- Migration:
- If not using
createBlockSelectionPlugin
, no migration is needed. - Otherwise, install
@udecode/plate-selection
and importcreateBlockSelectionPlugin
from that package.
- If not using
@udecode/[email protected]
-
usePlateStore
:- Plate no longer has a global store containing all the editor states (zustand). Each editor store is now defined in a React context tree (jotai). If you need to access all the editor states at once (as you could do before), you'll need to build that layer yourself.
- Plate store is now accessible only below
PlateProvider
orPlate
(provider-less mode). It means it's no longer accessible outside of a Plate React tree. If you have such use-case, you'll need to build your own layer to share the state between your components. - You can nest many
PlateProvider
with different scopes (id
prop). Default scope isPLATE_SCOPE
- Hook usage:
const value = usePlateSelectors(id).value()
const setValue = usePlateActions(id).value()
const [value, setValue] = usePlateStates(id).value()
- removed from the store:
editableProps
, use the props insteadenabled
, use conditional rendering insteadisReady
, no point anymore as it's now directly ready
useEventPlateId
is still used to get the last focused editor id.- Functions are stored in an object
{ fn: <here> }
const setOnChange = usePlateActions(id).onChange()
setOnChange({ fn: newOnChange })
Plate
- if rendered below
PlateProvider
, it will renderPlateSlate > PlateEditable
- if rendered without
PlateProvider
, it will renderPlateProvider > PlateSlate > PlateEditable
- default
id
is no longermain
, it's nowPLATE_SCOPE
- if rendered below
PlateProvider
- Each provider has an optional
scope
, so you can have multiple providers in the same React tree and use the plate hooks with the correspondingscope
. - Plate effects are now run in
PlateProvider
initialValue, value, editor, normalizeInitialValue, normalizeEditor
are no longer defined in an effect (SSR support)
- Props:
- now extends the previous
Plate
props - if using
PlateProvider
, set the provider props on it instead ofPlate
.Plate
would only neededitableProps
andPlateEditableExtendedProps
- if not using it, set the provider props on
Plate
- now extends the previous
- Each provider has an optional
// Before <PlateProvider> <Toolbar> <AlignToolbarButtons /> </Toolbar> <Plate<MyValue> editableProps={editableProps} <MyValue> initialValue={alignValue} plugins={plugins} /> </PlateProvider> // After <PlateProvider<MyValue> initialValue={alignValue} plugins={plugins}> <Toolbar> <AlignToolbarButtons /> </Toolbar> <Plate<MyValue> editableProps={editableProps} /> </PlateProvider> // After (provider-less mode) <Plate<MyValue> editableProps={editableProps} initialValue={alignValue} plugins={plugins} />
- types:
- store
editor
is no longer nullable - store
value
is no longer nullable id
type is nowPlateId
- store
- renamed:
SCOPE_PLATE
toPLATE_SCOPE
getEventEditorId
togetEventPlateId
getPlateActions().resetEditor
touseResetPlateEditor()
- removed:
plateIdAtom
usePlateId
forusePlateSelectors().id()
EditablePlugins
forPlateEditable
SlateChildren
PlateEventProvider
forPlateProvider
withPlateEventProvider
forwithPlateProvider
usePlate
usePlatesStoreEffect
useEventEditorId
foruseEventPlateId
platesStore, platesActions, platesSelectors, usePlatesSelectors
getPlateActions
forusePlateActions
getPlateSelectors
forusePlateSelectors
getPlateEditorRef
forusePlateEditorRef
getPlateStore, usePlateStore
EditorId
forPlateId
@udecode/[email protected]
- #1871 by @zbeyens –
- Removed these imports because of build errors:
prismjs/components/prism-django
prismjs/components/prism-ejs
prismjs/components/prism-php
- Removed these imports because of build errors:
@udecode/[email protected]
- #1871 by @zbeyens –
- Removed
[ELEMENT_CODE_BLOCK]: CodeBlockElement
from Plate UI. You can define it in your app.
- Removed
@udecode/[email protected]
@udecode/[email protected]
- #1721 by @zbeyens –
- deprecate
@udecode/plate-image
and@udecode/plate-media-embed
, those got merged into@udecode/plate-media
- deprecate
@udecode/[email protected]
- #1721 by @zbeyens –
- removed:
useImageElement
foruseElement
MediaEmbedUrlInput
forFloatingMediaUrlInput
parseEmbedUrl
forparseMediaUrl
EmbedProviders
- renamed:
ImageImg
toImage
ImageCaptionTextarea
toCaptionTextarea
useImageCaptionString
touseCaptionString
ImageResizable
toResizable
- removed:
@udecode/[email protected]
- #1721 by @zbeyens –
TableElementBase
props:- replace
onRenderContainer
byfloatingOptions
or by replacingELEMENT_TABLE
in thecreatePlateUI
function.
- replace
TablePopover
is now a floating instead of tippy- deps:
- replaced
plate-ui-popover
byplate-floating
- replaced
@udecode/[email protected]
@udecode/[email protected]
- #1677 by @zbeyens –
- deps:
- replaced
@udecode/plate-ui-popper
by@udecode/plate-floating
- replaced
comboboxStore
:- removed
popperContainer
, usefloatingOptions
instead - removed
popperOptions
, usefloatingOptions
instead
- removed
- deps:
@udecode/[email protected]
- #1677 by @zbeyens –
createLinkPlugin
- removed
onKeyDownLink
for floating link - removed
hotkey
fortriggerFloatingLinkHotkeys
- removed
- removed:
getAndUpsertLink
forupsertLink
upsertLinkAtSelection
forupsertLink
LinkToolbarButton
:onClick
now callstriggerFloatingLink
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
- #1677 by @zbeyens –
- remove
@udecode/plate-ui-popper
andreact-popper
deps for@udecode/plate-floating
BalloonToolbarProps
:- removed
popperOptions
forfloatingOptions
- removed
- remove
useBalloonToolbarPopper
foruseFloatingToolbar
@udecode/[email protected]
- #1633 by @tjramage – Moved
serializeHtml
and its utils to@udecode/plate-serializer-html
as it has a new dependency: html-entities.- If you're using
@udecode/plate
, no migration is needed - Otherwise, import it from
@udecode/plate-serializer-html
- If you're using
@udecode/[email protected]
Plate
children are now rendered as last children ofSlate
(previously first children). To reproduce the previous behavior, movechildren
tofirstChildren
@udecode/[email protected]
@udecode/[email protected]
- #1585 by @zbeyens – Removed
@udecode/plate-juice
from@udecode/plate
. Install it if using@udecode/plate-serializer-docx
:yarn install @udecode/plate-juice
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
- #1585 by @zbeyens – Moved
react-dnd react-dnd-html5-backend
deps to peer-dependencies. Install these if using@udecode/plate-ui-dnd
:yarn install react-dnd react-dnd-html5-backend
@udecode/[email protected]
- #1579 by @zbeyens – renamed:
useDndBlock
options:blockRef
->nodeRef
removePreview
->preview.disable
useDropBlockOnEditor
->useDropBlock
useDropBlock
options:blockRef
->nodeRef
setDropLine
->onChangeDropLine
signature change:
getHoverDirection
:
// before
(
dragItem: DragItemBlock,
monitor: DropTargetMonitor,
ref: any,
hoverId: string
)
// after
{
dragItem,
id,
monitor,
nodeRef,
}: GetHoverDirectionOptions
@udecode/[email protected]
-
#1500 by @zbeyens – Thanks @ianstormtaylor for the initial work on ianstormtaylor/slate#4177.
This release includes major changes to plate and slate types:
- Changing the
TEditor
type to beTEditor<V>
whereV
represents the "value" being edited by Slate. In the most generic editor,V
would be equivalent toTElement[]
(since that is what is accepted as children of the editor). But in a custom editor, you might haveTEditor<Array<Paragraph | Quote>>
. - Other
TEditor
-and-TNode
-related methods have been also made generic, so for example if you usegetLeafNode(editor, path)
it knows that the return value is aTText
node. But more specifically, it knows that it is the text node of the type you've defined in your custom elements (with any marks you've defined). - This replaces the declaration merging approach, and provides some benefits. One of the drawbacks to declaration merging was that it was impossible to know whether you were dealing with an "unknown" or "known" element, since the underlying type was changed. Similarly, having two editors on the page with different schemas wasn't possible to represent. Hopefully this approach with generics will be able to smoothly replace the declaration merging approach. (While being easy to migrate to, since you can pass those same custom element definitions into
TEditor
still.)
- Changing the
Define your custom types
- Follow https://platejs.org/docs/typescript example.
Slate types
Those Slate types should be replaced by the new types:
Editor
->TEditor<V extends Value = Value>
- Note that
TEditor
methods are not typed based onValue
as it would introduce a circular dependency. You can usegetTEditor(editor)
to get the editor with typed methods.
- Note that
ReactEditor
->TReactEditor<V extends Value = Value>
HistoryEditor
->THistoryEditor<V extends Value = Value>
EditableProps
->TEditableProps<V extends Value = Value>
Node
->TNode
Element
->TElement
Text
->TText
NodeEntry
->TNodeEntry
NodeProps
->TNodeProps
Slate functions
Those Slate functions should be replaced by the new typed ones:
- As the new editor type is not matching the slate ones, all
Transforms
,Editor
,Node
,Element
,Text
,HistoryEditor
,ReactEditor
functions should be replaced: The whole API has been typed into Plate core. See https://github.com/udecode/plate/packages/core/src/slate createEditor
->createTEditor
withReact
->withTReact
withHistory
->withTHistory
Generic types
-
<T = {}>
could be used to extend the editor type. It is now replaced by<E extends PlateEditor<V> = PlateEditor<V>>
to customize the whole editor type. -
When the plugin type is customizable, these generics are used:
<P = PluginOptions, V extends Value = Value, E extends PlateEditor<V> = PlateEditor<V>>
, whereP
is the plugin options type. -
Editor
functions are using<V extends Value>
generic, whereV
can be a custom editor value type used inPlateEditor<V>
. -
Editor
functions returning a node are using<N extends ENode<V>, V extends Value = Value>
generics, whereN
can be a custom returned node type. -
Editor
callbacks (e.g. a plugin option) are using<V extends Value = Value, E extends PlateEditor<V> = PlateEditor<V>>
generics, whereE
can be a custom editor type. -
Node
functions returning a node are using<N extends Node, R extends TNode = TNode>
generics. -
These generics are used by
<V extends Value, K extends keyof EMarks<V>>
:getMarks
,isMarkActive
,removeMark
,setMarks
,ToggleMarkPlugin
,addMark
,removeEditorMark
-
WithOverride
is a special type case as it can return a new editor type:// before export type WithOverride<T = {}, P = {}> = ( editor: PlateEditor<T>, plugin: WithPlatePlugin<T, P> ) => PlateEditor<T>; // after - where E is the Editor type (input), and EE is the Extended Editor type (output) export type WithOverride< P = PluginOptions, V extends Value = Value, E extends PlateEditor<V> = PlateEditor<V>, EE extends E = E > = (editor: E, plugin: WithPlatePlugin<P, V, E>) => EE;
-
type TEditor<V extends Value>
-
type PlateEditor<V extends Value>
Renamed functions
getAbove
->getAboveNode
getParent
->getParentNode
getText
->getEditorString
getLastNode
->getLastNodeByLevel
getPointBefore
->getPointBeforeLocation
getNodes
->getNodeEntries
isStart
->isStartPoint
isEnd
->isEndPoint
Replaced types
Removing node props types in favor of element types (same props + extends TElement
). You can use TNodeProps
to get the node data (props).
LinkNodeData
->TLinkElement
ImageNodeData
->TImageElement
TableNodeData
->TTableElement
MentionNodeData
->TMentionElement
MentionNode
->TMentionElement
MentionInputNodeData
->TMentionInputElement
MentionInputNode
->TMentionInputElement
CodeBlockNodeData
->TCodeBlockElement
MediaEmbedNodeData
->TMediaEmbedElement
TodoListItemNodeData
->TTodoListItemElement
ExcalidrawNodeData
->TExcalidrawElement
Utils
match
signature change:
<T extends TNode>(
obj: T,
path: TPath,
predicate?: Predicate<T>
)
deleteFragment
is now usingEditor.deleteFragment
@udecode/[email protected]
getEmptyTableNode
default options changed. Migration:
// From (0 row count and col count, previously it was 2)
getEmptyTableNode(editor);
// To
getEmptyTableNode(editor, { rowCount: 2, colCount: 2 });
@udecode/[email protected]
Generic types
type StyledElementProps<V extends Value, N extends TElement = EElement<V>, TStyles = {}>
@udecode/[email protected]
- #1377 by @zbeyens – Before,
BalloonToolbar
could be outsidePlate
. Now,BallonToolbar
should be a child ofPlate
to support multiple editors.
@udecode/[email protected]
- #1303 by @zbeyens –
Plate
editor
prop can now be fully controlled: Plate is not applyingwithPlate
on it anymore
PlatePlugin.deserializeHtml
- can't be an array anymore
- moved
validAttribute
,validClassName
,validNodeName
,validStyle
todeserializeHtml.rules
property
- renamed
plateStore
toplatesStore
platesStore
is now a zustood storeeventEditorStore
is now a zustood storegetPlateId
now gets the last editor id if not focused or blurred- used by
usePlateEditorRef
andusePlateEditorState
- used by
- removed:
usePlateEnabled
forusePlateSelectors(id).enabled()
usePlateValue
forusePlateSelectors(id).value()
usePlateActions
:resetEditor
forgetPlateActions(id).resetEditor()
clearState
forplatesActions.unset()
setInitialState
forplatesActions.set(id)
setEditor
forgetPlateActions(id).editor(value)
setEnabled
forgetPlateActions(id).enabled(value)
setValue
forgetPlateActions(id).value(value)
getPlateState
usePlateState
usePlateKey
@udecode/[email protected]
- #1303 by @zbeyens –
- renamed
plate-x-ui
toplate-ui-x
: all packages depending onstyled-components
hasplate-ui
prefix - renamed
plate-x-serializer
toplate-serializer-x
- is now exporting only these (new) packages:
@udecode/plate-headless
: all unstyled packages@udecode/plate-ui
: all styled packages
- renamed
PlateState
toPlateStoreState
@udecode/[email protected]
-
IndentListPluginOptions
forPlatePlugin
Rename:
getIndentListInjectComponent
toinjectIndentListComponent
@udecode/[email protected]
-
#1234 by @zbeyens – Breaking changes:
- removed
components
prop:
// Before <Plate plugins={plugins} components={components} />; // After // option 1: use the plugin factory let plugins = [ createParagraphPlugin({ component: ParagraphElement, }), ]; // option 2: use createPlugins plugins = createPlugins(plugins, { components: { [ELEMENT_PARAGRAPH]: ParagraphElement, }, }); <Plate plugins={plugins} />;
- removed
options
prop:
// Before <Plate plugins={plugins} options={options} />; // After // option 1: use the plugin factory let plugins = [ createParagraphPlugin({ type: 'paragraph', }), ]; // option 2: use createPlugins plugins = createPlugins(plugins, { overrideByKey: { [ELEMENT_PARAGRAPH]: { type: 'paragraph', }, }, }); <Plate plugins={plugins} />;
key
- replacing
pluginKey
- is now required: each plugin needs a key to be retrieved by key.
- replacing
- all handlers have
plugin
as a second parameter:
// Before export type X<T = {}> = (editor: PlateEditor<T>) => Y; // After export type X<T = {}, P = {}> = ( editor: PlateEditor<T>, plugin: WithPlatePlugin<T, P> ) => Y;
serialize
no longer haselement
andleaf
properties:
type SerializeHtml = RenderFunction< PlateRenderElementProps | PlateRenderLeafProps >;
Renamed:
injectParentComponent
toinject.aboveComponent
injectChildComponent
toinject.belowComponent
overrideProps
toinject.props
transformClassName
,transformNodeValue
,transformStyle
first parameter is no longereditor
as it's provided bythen
if needed.- the previously
getOverrideProps
is now the core behavior ifinject.props
is defined.
serialize
toserializeHtml
deserialize
todeserializeHtml
- can be an array
- the old deserializer options are merged to
deserializeHtml
type DeserializeHtml = { /** * List of HTML attribute names to store their values in `node.attributes`. */ attributeNames?: string[]; /** * Deserialize an element. * Use this instead of plugin.isElement if you don't want the plugin to renderElement. * @default plugin.isElement */ isElement?: boolean; /** * Deserialize a leaf. * Use this instead of plugin.isLeaf if you don't want the plugin to renderLeaf. * @default plugin.isLeaf */ isLeaf?: boolean; /** * Deserialize html element to slate node. */ getNode?: (element: HTMLElement) => AnyObject | undefined; query?: (element: HTMLElement) => boolean; /** * Deserialize an element: * - if this option (string) is in the element attribute names. * - if this option (object) values match the element attributes. */ validAttribute?: string | { [key: string]: string | string[] }; /** * Valid element `className`. */ validClassName?: string; /** * Valid element `nodeName`. * Set '*' to allow any node name. */ validNodeName?: string | string[]; /** * Valid element style values. * Can be a list of string (only one match is needed). */ validStyle?: Partial< Record<keyof CSSStyleDeclaration, string | string[] | undefined> >; /** * Whether or not to include deserialized children on this node */ withoutChildren?: boolean; };
- handlers starting by
on...
are moved tohandlers
property.
// Before onDrop: handler; // After handlers: { onDrop: handler; }
Removed:
renderElement
is favor of:isElement
is a boolean that enables element rendering.- the previously
getRenderElement
is now the core behavior.
renderLeaf
is favor of:isLeaf
is a boolean that enables leaf rendering.- the previously
getRenderLeaf
is now the core behavior.
inlineTypes
andvoidTypes
for:isInline
is a boolean that enables inline rendering.isVoid
is a boolean that enables void rendering.
- the following plugins are now part of the core plugins, so you need to remove these from your
plugins
prop:
const corePlugins = [ createReactPlugin(), createHistoryPlugin(), createEventEditorPlugin(), createInlineVoidPlugin(), createInsertDataPlugin(), createDeserializeAstPlugin(), createDeserializeHtmlPlugin(), ];
plugins
is not a parameter anymore as it can be retrieved ineditor.plugins
withInlineVoid
is now using pluginsisInline
andisVoid
plugin properties.
Renamed:
getPlatePluginType
togetPluginType
getEditorOptions
togetPlugins
getPlatePluginOptions
togetPlugin
pipeOverrideProps
topipeInjectProps
getOverrideProps
topluginInjectProps
serializeHTMLFromNodes
toserializeHtml
getLeaf
toleafToHtml
getNode
toelementToHtml
xDeserializerId
toKEY_DESERIALIZE_X
deserializeHTMLToText
tohtmlTextNodeToString
deserializeHTMLToMarks
tohtmlElementToLeaf
andpipeDeserializeHtmlLeaf
deserializeHTMLToElement
tohtmlElementToElement
andpipeDeserializeHtmlElement
deserializeHTMLToFragment
tohtmlBodyToFragment
deserializeHTMLToDocumentFragment
todeserializeHtml
deserializeHTMLToBreak
tohtmlBrToNewLine
deserializeHTMLNode
todeserializeHtmlNode
deserializeHTMLElement
todeserializeHtmlElement
Removed:
usePlateKeys
,getPlateKeys
usePlateOptions
forgetPlugin
getPlateSelection
forgetPlateEditorRef().selection
flatMapByKey
getEditableRenderElement
andgetRenderElement
forpipeRenderElement
andpluginRenderElement
getEditableRenderLeaf
andgetRenderLeaf
forpipeRenderLeaf
andpluginRenderLeaf
getInlineTypes
getVoidTypes
getPlatePluginTypes
getPlatePluginWithOverrides
mapPlatePluginKeysToOptions
withDeserializeX
forPlatePlugin.editor.insertData
Changed types:
PlateEditor
:- removed
options
forpluginsByKey
- removed
WithOverride
is not returning an extended editor anymore (input and output editors are assumed to be the same types for simplicity).PlateState
- renamed
keyChange
tokeyEditor
- removed
plugins
foreditor.plugins
- removed
pluginKeys
- removed
selection
foreditor.selection
- actions:
- removed
setSelection
,setPlugins
,setPluginKeys
- removed
incrementKeyChange
for
- removed
- renamed
Renamed types:
XHTMLY
toXHtmlY
Deserialize
toDeseralizeHtml
Removed types:
PlatePluginOptions
:type
toPlatePlugin.type
component
toPlatePlugin.component
deserialize
toPlatePlugin.deserializeHtml
getNodeProps
toPlatePlugin.props.nodeProps
hotkey
toHotkeyPlugin
clear
toToggleMarkPlugin
defaultType
is hardcoded top.type
OverrideProps
forPlatePlugin.inject.props
Serialize
forPlatePlugin.serializeHtml
NodeProps
forAnyObject
OnKeyDownElementOptions
forHotkeyPlugin
OnKeyDownMarkOptions
forToggleMarkPlugin
WithInlineVoidOptions
GetNodeProps
forPlatePluginProps
DeserializeOptions
,GetLeafDeserializerOptions
,GetElementDeserializerOptions
,GetNodeDeserializerOptions
,GetNodeDeserializerRule
,DeserializeNode
forPlatePlugin.deserializeHtml
PlateOptions
RenderNodeOptions
DeserializedHTMLElement
- removed
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
- #1234 by @zbeyens – Removed:
getCodeBlockPluginOptions
forgetPlugin
getCodeLinePluginOptions
forgetPlugin
@udecode/[email protected]
@udecode/[email protected]
- #1234 by @zbeyens – Removed:
getMentionInputPluginOptions
forgetPlugin
getMentionInputType
forgetPluginType
COMBOBOX_TRIGGER_MENTION
@udecode/[email protected]
@udecode/[email protected]
-
#1234 by @zbeyens – Breaking changes:
- all plugins options are now defined in the plugin itself
- plugins which now have nested plugins instead of array:
createBasicElementsPlugin
createCodeBlockPlugin
createHeadingPlugin
createListPlugin
createTablePlugin
createBasicMarksPlugin
Removed:
createEditorPlugins
forcreatePlateEditor
(without components) andcreatePlateEditorUI
(with Plate components)createPlateOptions
forcreatePlugins
- all
DEFAULTS_X
: these are defined in the plugins - all
getXDeserialize
: these are defined in the plugins - all
WithXOptions
for extended plugins - all
getXRenderElement
- some plugin option types are removed for
PlatePlugin
Renamed:
createPlateComponents
tocreatePlateUI
- all
getXY
handlers toyX
(e.g.getXOnKeyDown
toonKeyDownX
) - all
XPluginOptions
toXPlugin
- all
pluginKey
parameter tokey
except in components
Renamed types:
DecorateSearchHighlightOptions
toFindReplacePlugin
Updated deps:
"slate": "0.70.0"
"slate-react": "0.70.1"
Removed deps (merged to core):
plate-common
plate-ast-serializer
plate-html-serializer
plate-serializer
@udecode/[email protected]
- #1234 by @zbeyens – Renamed:
createDeserializeCSVPlugin
tocreateDeserializeCsvPlugin
deserializeCSV
todeserializeCsv
@udecode/[email protected]
-
createDeserializeMdPlugin
:- is now disabled if there is html data in the data transfer.
Renamed:
createDeserializeMDPlugin
tocreateDeserializeMdPlugin
deserializeMD
todeserializeMd
- renamed:
SPEditor
toPEditor
(note thatPlateEditor
is the new default)SPRenderNodeProps
toPlateRenderNodeProps
SPRenderElementProps
toPlateRenderElementProps
SPRenderLeafProps
toPlateRenderLeafProps
useEventEditorId
tousePlateEventId
useStoreEditorOptions
tousePlateOptions
useStoreEditorRef
tousePlateEditorRef
useStoreEditorSelection
tousePlateSelection
useStoreEditorState
tousePlateEditorState
useStoreEditorValue
tousePlateValue
useStoreEnabled
tousePlateEnabled
useStorePlate
tousePlatePlugins
useStorePlatePluginKeys
tousePlateKeys
useStoreState
tousePlateState
getPlateId
: Get the last focused editor id, else get the last blurred editor id, else get the first editor id, elsenull
getPlateState
:- removed first parameter
state
- previously when giving no parameter, it was returning the first editor. Now it's returning the editor with id =
getPlateId()
. It meansuseEventEditorId('focus')
is no longer needed forusePlateEditorRef
usePlateEditorState
usePlateX
...
- removed first parameter
setAlign
: optionalign
renamed tovalue
- removed
getAlignOverrideProps()
in favor ofgetOverrideProps(KEY_ALIGN)
- removed
getIndentOverrideProps()
in favor ofgetOverrideProps(KEY_INDENT)
- rename
onKeyDownHandler
togetIndentOnKeyDown()
IndentPluginOptions
- rename
types
tovalidTypes
- rename
cssPropName
tostyleKey
- rename
transformCssValue
totransformNodeValue
- rename
setLineHeight
: optionlineHeight
renamed tovalue
- removed
getLineHeightOverrideProps
in favor ofgetOverrideProps(KEY_LINE_HEIGHT)
getMentionOnSelectItem
:- removed
createMentionNode
in favor of plugin options - removed
insertSpaceAfterMention
in favor of plugin options
- removed
MentionCombobox
props:- removed
trigger
in favor of plugin options - removed
insertSpaceAfterMention
in favor of plugin options - removed
createMentionNode
in favor of plugin options
- removed
- renamed
ToolbarAlign
toAlignToolbarButton
- renamed
ToolbarCodeBlock
toCodeBlockToolbarButton
- renamed
ToolbarElement
toBlockToolbarButton
- renamed
ToolbarImage
toImageToolbarButton
- renamed
ToolbarLink
toLinkToolbarButton
- renamed
ToolbarList
toListToolbarButton
- renamed
ToolbarLineHeight
toLineHeightToolbarDropdown
- renamed
ToolbarMark
toMarkToolbarButton
- renamed
ToolbarMediaEmbed
toMediaEmbedToolbarButton
- renamed
ToolbarSearchHighlight
toSearchHighlightToolbar
- renamed
ToolbarTable
toTableToolbarButton
The align plugin is no longer wrapping a block, but instead setting an align
property to an existing block.
createAlignPlugin
:- removed
pluginKeys
,renderElement
anddeserialize
- removed
- removed:
ELEMENT_ALIGN_LEFT
ELEMENT_ALIGN_CENTER
ELEMENT_ALIGN_RIGHT
ELEMENT_ALIGN_JUSTIFY
KEYS_ALIGN
in favor ofKEY_ALIGN
getAlignDeserialize
upsertAlign
in favor ofsetAlign
Migration (normalizer):
- for each node:
- run
parent = getParent(editor, path)
, ifparent[0].type
is one of the alignment values:- run
setAlign(editor, { align }, { at: path })
- run
unwrapNodes(editor, { at: path })
- run
- run
ToolbarAlignProps
:- removed
type
in favor ofalign
- removed
unwrapTypes
- added
align
- removed
The mention plugin is now using the combobox.
- removed
useMentionPlugin
in favor ofcreateMentionPlugin
- migration: replace
useMentionPlugin().plugin
bycreateMentionPlugin()
- migration: replace
- removed options:
mentionableSearchPattern
insertSpaceAfterMention
maxSuggestions
: moved tocomboboxStore
trigger
: moved tocomboboxStore
mentionables
: moved toitems
incomboboxStore
mentionableFilter
: moved tofilter
incomboboxStore
- removed
matchesTriggerAndPattern
in favor ofgetTextFromTrigger
- removed
MentionNodeData
in favor ofComboboxItemData
export interface ComboboxItemData {
/**
* Unique key.
*/
key: string;
/**
* Item text.
*/
text: any;
/**
* Whether the item is disabled.
* @default false
*/
disabled?: boolean;
/**
* Data available to `onRenderItem`.
*/
data?: unknown;
}
- removed
MentionSelect
in favor ofMentionCombobox
- removed
setPositionAtSelection
in favor ofuseBalloonToolbarPopper
- removed
useBalloonMove
in favor ofuseBalloonToolbarPopper
- removed
usePopupPosition
in favor ofuseBalloonToolbarPopper
- removed
useBalloonShow
in favor ofuseBalloonToolbarPopper
BalloonToolbar
props: - removed
direction
in favor ofpopperOptions.placement
- renamed
scrollContainer
topopperContainer
BalloonToolbar
: removedhiddenDelay
prop.
There was multiple instances of styled-components
across all the packages.
So we moved styled-components
from dependencies to peer dependencies.
styled-components
was not listed in your dependencies
Add styled-components
to your dependencies
autoformatBlock
:- signatude changed
// Before
(
editor: TEditor,
type: string,
at: Location,
options: Pick<AutoformatRule, 'preFormat' | 'format'>
)
// After
(editor: TEditor, options: AutoformatBlockOptions)
- moved the checks from
withAutoformat
autoformatInline
:- renamed to
autoformatMark
- signatured changed
- renamed to
// Before
(
editor: TEditor,
options: Pick<AutoformatRule, 'type' | 'between' | 'markup' | 'ignoreTrim'>
)
// After
(
editor: TEditor,
options: AutoformatMarkOptions
)
AutoformatRule
is nowAutoformatBlockRule | AutoformatMarkRule | AutoformatTextRule;
mode: 'inline'
renamed tomode: 'mark'
markup
andbetween
have been replaced bymatch: string | string[] | MatchRange | MatchRange[]
: The rule applies when the trigger and the text just before the cursor matches. Formode: 'block'
: lookup for the end match(es) before the cursor. Formode: 'text'
: lookup for the end match(es) before the cursor. Ifformat
is an array, also lookup for the start match(es). Formode: 'mark'
: lookup for the start and end matches. Note:'_*'
,['_*']
and{ start: '_*', end: '*_' }
are equivalent.trigger
now defaults to the last character ofmatch
ormatch.end
(previously' '
)
- the plugin now checks that there is no character before the start match to apply autoformatting. For example, nothing will happen by typing
a*text*
.