docs/components/changelog.cn.mdx
由于 Plate UI 不是一个组件库,因此在此维护更新日志。
使用 CLI 安装组件的最新版本。
@platejs/docx-io 包,支持 Word 文档处理
import-toolbar-button:通过 importDocx 导入 DOCX 文件export-toolbar-button:通过 exportToDocx 导出为 DOCXdocx-export-kit:支持 DOCX 的组件,可使用 DocxExportPlugin.configure({ override: { components } }) 覆盖*Docx 命名的静态组件:
callout-node-static:CalloutElementDocxcode-block-node-static:CodeBlockElementDocx、CodeLineElementDocx、CodeSyntaxLeafDocxcolumn-node-static:ColumnElementDocx、ColumnGroupElementDocxequation-node-static:EquationElementDocx、InlineEquationElementDocxtoc-node-static:TocElementDocxprompts.ts 拆分为多个独立模块:getEditPrompt、getGeneratePrompt、getCommentPrompt、getEditTablePrompt、getChooseToolPromptcommon.ts,提供共享提示工具函数use-chat:增强了解析器选项,提升 AI 内容处理能力cursor-overlay:修复覆盖层定位与行为table-node:修复表格行拖拽,之前行只能拖动不能放下,且未正确显示拖拽线。已补充元素引用的 nodeRef。inline-combobox:添加 Yjs 协作支持——组合框弹窗仅对当前操作用户可见,协作编辑时不会影响其他用户suggestion-kit:移除 BlockSuggestion,使用 SuggestionLineBreak 以修复样式use-chat:修复 AI 评论结束时隐藏的问题platejs/static
*-node-static 组件:导入路径由 @platejs/core/react 改为 platejs/staticeditor-static:PlateStatic 导入路径更新export-toolbar-button:静态工具路径调整import-toolbar-button:静态工具路径调整slate-to-html/page:静态渲染导入路径更新comment-kit、suggestion-kit:静态类型导入路径更新api/ai/command/route.ts:修复 blockSelecting 时 AI 生成内容质量差问题ai-kit:移除 useHooks 里未使用的 api 参数block-selection-kit:为已选中块时增加快捷键(mod+j)唤起 AI 菜单api/ai/command/route.ts:修复 #4669transforms:修复斜杠命令重复插入块,避免在空块中选择同类型块造成重复ai-menu:
AILoadingBar,含加载动画与停止功能ai-toolbar-button:实现简化api/ai/command/route.ts:
gemini-2.5-flash)模型markdown-joiner-transform:新增智能缓存,支持流式 markdown 渲染更流畅use-chat:实现简化并增强错误处理ai-kit:增加 markdown 插件markdown-kit:增加 AI 插件集成link-node:支持 AI 专用点击事件block-context-menu:去除冗余的 AI 选项(现已由 ai-menu 统一处理)block-discussion:样式微调fixed-toolbar-buttons:AI 按钮实现简化block-context-menu:修复多处触发时菜单位置会卡住的问题block-draggable:修复右键事件下块选择功能use-chat:增强支持 AI 评论及流式响应能力ai-menu:菜单增加评论生成与界面优化ai-toolbar-button:支持 AI 评论相关动作block-context-menu:集成 AI 评论至块右键菜单fixed-toolbar-buttons:工具栏添加 AI 评论按钮ai-kit:移除所有提示模板,直接在 api/ai/command/route.ts 使用api/ai/command/route.ts:新增评论支持block-discussion:移除用于弹出讨论弹窗的 useFocusedLast 检查useFocusedLast hook,仅在当前编辑器聚焦时显示浮动工具栏,解决多编辑器场景下工具栏冲突
ai-menublock-discussioncolumn-nodemedia-toolbartable-nodeblock-draggable:
block-draggable:修复表格拖拽时拖拽预览部分错位,支持横向滚动情况下可正确展示内容block-draggable:新增 isAboutToDrag 状态,优化拖拽预览清理ai-kit:支持自定义节点类型indent-kit:IndentPlugin 支持 KEYS.imglist-kit:ListPlugin 支持 KEYS.imgmarkdown-joiner-transform.ts:新增 markdownJoinerTransform,自动将 [,bold,] 转化为 [bold],以便 markdown 反序列化api/ai/command/route.ts:采用 markdownJoinerTransformlist-classic-kit:新增 ListPlugin,恢复列表功能(支持 Tab/Shift+Tab 缩进,回车新建列表项等)block-draggable:拖动列表项时自动选择所有缩进更深的子项block-draggable:使用新的 BlockSelectionPlugin 的 addOnContextMenu API 优化右键菜单代码block-context-menu:修复右键点击块边距区域无法弹出菜单block-draggable:外部包裹 div 增加右键菜单处理,保证边距点击时可选中块block-draggable:支持通过编辑器原生选择区拖动多个块(之前只能用块选择功能)slate-to-html:新增 EditorViewDemo 组件,采用 createStaticEditor 支持静态编辑器渲染list-classic-node:修复影响 TaskListElement 的样式,强制重置列表样式为 nonelist-classic-kit:新增 TaskListPlugin 及 TaskListElementlist-classic-node:新增 TaskListElement 与 TaskListItemElement,包含复选框transforms-classic:新增经典列表转换逻辑insert-toolbar-classic-button:新增插入经典列表类型组件(无序、有序、待办)turn-into-toolbar-classic-button:新增转换为经典列表类型组件floating-toolbar-classic-buttons:新增经典列表浮动工具栏按钮组件floating-toolbar-classic-kit:新增包含上述按钮的插件集editor:新增 EditorView,基于 @platejs/core/react 的新 PlateView,支持静态渲染及复制link-node:移除 useLinklink-node-static:补充缺失的 getLinkAttributesmedia-image-node:attributes.alt 类型转换补充inline-combobox:修复点击编辑器外无法关闭组合框弹窗transform.ts:setBlockMap 新增 toggleCodeBlock,修复 turn-into-toolbar-button.tsx 创建 code_block 的结构错误block-draggable:修复多块拖动及边缘区域定位不准等问题block-selection-kit:现可选择整张表格(table);仅当选区框在表格内部时才选 tr 行table-node:表格增加块选择样式table-node:修复与光标位置有关的 bug,提升性能block-draggable:由 getContainerTypes 改为 getPluginByTypeeditor:修复占位符定位问题 **:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2block-placeholder-kit:占位符颜色调整为 text-muted-foreground/80,保持与编辑器一致Plate 49
合并文件、统一更规范的命名方式、移除不再使用的 export。
组件:
withProps(..., { as: '...' })@udecode/plate 的 KEYS
ParagraphPlugin.key -> KEYS.pINDENT_LIST_KEYS.listStyleType -> KEYS.listTypeListStyleType.Decimal -> KEYS.olListStyleType.Disc -> KEYS.ullist (classic) -> KEYS.listClassicol (classic) -> KEYS.olClassicul (classic) -> KEYS.ulClassicli (classic) -> KEYS.liClassicaction_item (classic) -> KEYS.listTodoClassic*-element、*-leaf 文件重命名为 *-node(及静态文件)ai-anchor-element,合并到 ai-nodeai-loading-bar,合并到 ai-menuai-menu-items,合并到 ai-menualign-dropdown-menu 重命名为 align-toolbar-button,AlignDropdownMenu 重命名为 AlignToolbarButtonapi-ai 重命名为 ai-apiapi-uploadthing 重命名为 media-uploadthing-apiBlockSelection:修复表格块选择code-block-combobox,合并到 code-block-nodecode-line-element,合并到 code-block-node(及静态)code-syntax-leaf,合并到 code-block-node(及静态)color-toolbar-button 重命名为 font-color-toolbar-button,ColorDropdownMenu 重命名为 FontColorToolbarButtoncolor-* 文件,合并到 font-color-toolbar-button
color-dropdown-menu 重命名为 font-color-toolbar-buttoncolumn-group-element,合并到 column-node(及静态)comment-create-form,合并到 commentdraggable 重命名为 block-draggable,DraggableAboveNodes 重命名为 BlockDraggableemoji-input-element 重命名为 emoji-nodeemoji-input-node 外,移除所有 emoji-* 文件,合并到 emoji-toolbar-button
EmojiToolbarDropdown 重命名为 EmojiPopover,EmojiDropdownMenu 重命名为 EmojiToolbarButtonEmojiPicker icons 参数现在可选,默认使用 emojiCategoryIcons 与 emojiSearchIconsimage-preview 重命名为 media-preview-dialog,ImagePreview 重命名为 MediaPreviewDialogimage-element 重命名为 media-image-node
MediaFileElement 重命名为 FileElement(及静态)MediaAudioElement 重命名为 AudioElement(及静态)MediaVideoElement 重命名为 VideoElement(及静态)indent-list-toolbar-button 重命名为 list-toolbar-button
BulletedIndentListToolbarButton 重命名为 BulletedListToolbarButtonNumberedIndentListToolbarButton 重命名为 NumberedListToolbarButtonindent-todo-marker 重命名为 block-listindent-fire-markerindent-todo-toolbar-button,合并到 list-toolbar-buttonIndentTodoToolbarButton 重命名为 TodoListToolbarButtoninline-equation-element 与 equation-popover,合并到 equation-node(及静态)inline-equation-toolbar-button,合并到 equation-toolbar-buttoninsert-dropdown-menu 重命名为 insert-toolbar-button,InsertDropdownMenu 重命名为 InsertToolbarButtonline-height-dropdown-menu 重命名为 line-height-toolbar-button,LineHeightDropdownMenu 重命名为 LineHeightToolbarButtonlink-floating-toolbar 重命名为 link-toolbarlist-indent-toolbar-button,合并到 list-classic-toolbar-buttonListIndentToolbarButton 重命名为 IndentToolbarButtonlist-node 重命名为 list-classic-nodemedia-popover 重命名为 media-toolbar,MediaPopover 重命名为 MediaToolbarmode-dropdown-menu 重命名为 mode-toolbar-button,ModeDropdownMenu 重命名为 ModeToolbarButtonmore-dropdown-menu 重命名为 more-toolbar-button,MoreDropdownMenu 重命名为 MoreToolbarButtonoutdent-toolbar-button,合并到 indent-toolbar-buttontable-icons:Border* 重命名为 Border*Iconslash-input-element 重命名为 slash-input-nodeSuggestionBelowNodes 重命名为 SuggestionLineBreaktable-cell-element,合并到 table-node(及静态)table-row-element,合并到 table-node(及静态)table-dropdown-menu 重命名为 table-toolbar-button,TableDropdownMenu 重命名为 TableToolbarButtontodo-list-node,合并到 list-classic-nodeturn-into-dropdown-menu 重命名为 turn-into-toolbar-button,TurnIntoDropdownMenu 重命名为 TurnIntoToolbarButtonexport-toolbar-button、indent-list-plugins:listStyleTypes 移除 fireuseCommentEditor:改为用 usePlateEditor 取代 useCreateEditorplaceholder、withPlaceholder,替换为 block-placeholder-kit、BlockPlaceholderPluginline-height-toolbar-button:移除 useLineHeightDropdownMenu hookfont-color-toolbar-button:移除 useColorInput hook插件:
所有 *-plugin、*-plugins 文件重命名为 -kit,*Plugin、*Plugins 重命名为 *Kit,**插件集(plugin kit)**为一组已配置组件插件
editor-plugins 重命名为 editor-kitequation-plugins 重命名为 math-kit,equationPlugins 重命名为 MathKitindent-list-plugins 重命名为 list-kit,indentListPlugins 重命名为 ListKitblock-list 增加 BlockList 组件,用于 list-kituse-create-editor,全部迁移为 usePlateEditorai-kit:添加 show 快捷键,移除 ai-menu 的 useHotkeys('mod+j')
comment-kit:添加 setDraft 转换与快捷键
basic-marks-kit、basic-blocks-kit:添加快捷键
transforms、block-draggable:移除 STRUCTURE_TYPES,现以 plugin.node.isContainer 自动推断,使用 editor.meta.containerTypes
所有 useSelectionFragmentProp 移除 structuralTypes 参数
inline-combobox:修复关闭弹窗时 insertPoint 未能及时更新的问题equation-popover:关闭弹窗后聚焦回编辑器inline-equation-element:选中时支持高亮显示React.forwardRefcomponents.json 移除 registriesnpx shadcn 替代 npx shadcxwithRefcn 统一从 @/lib/utils 导入,而非 @udecode/cnclassName、style 属性draggable:
media-placeholder-element:重构为使用 use-upload-file hook,取代 uploadthing
npx shadcn@latest add @plate/api-uploadthingai-chat-editor:支持非标准 markdown 节点slash-input-element:新增 callout 支持block-selection-plugins.tsx:修复快选块失效问题ai/command:fork 版 smoothStream 默认延迟 30ms(仅代码块和表格为 100ms)v48 迁移:
PlateElement、PlateLeaf 和 PlateText 属性由顶层 props 挪入 attributesnodeProps,统一用 attributesblock-discussioncomment-leafdate-elementdraggableexcalidraw-elementhr-element + -staticimage-element + -staticlink-elementmedia-audio-elementmedia-file-elementmedia-placeholder-elementmedia-video-elementmention-elementplaceholdersuggestion-leaftable-cell-element + -statictable-elementtag-elementuse-chat:添加 _abortFakeStreamai-menu:修复菜单项显示错误ai-loading-bar:esc 快捷键处理逻辑移至 ai-menuai/command:分块延迟 100ms(临时性能兼容)autoformat-plugin:支持从非1开头的数字新建缩进列表ai-leaf:新增 aiIndicatorVariants,显示加载状态cursor-overlay:AI 内容流式时隐藏光标覆盖层api/ai/command:修复分块问题新增 discussion-plugin:
editor-plugins 增加 discussionPlugin,并移除 suggestionPlugin 的 configureblock-suggestion、comment 使用 discussionPlugincomment-create-form 自动创建讨论suggestion-leaf 样式调整link-floating-toolbar 支持内部链接,建议/评论活跃时顶部定位ai-anchor-element:新增组件,流式插入前插入节点,流式结束后移除,用于 ai-menu 定位ai-loading-bar:新增组件,显示插入模式流式加载进度条ai-menu:升级到最新版 ai 包ai-menu-items:新增 generateMarkdownSampleai-plugins:移除 prompt 单段落限制editor:新增 PlateContainer 组件export-toolbar-button:修复 html2canvas-pro 导出 PDF 问题import-toolbar-button:修复文件选择异常ai-toolbar-button:补全 @udecode/plate-ai 依赖comment-toolbar-button:补全 comments-plugin 依赖font-size-toolbar-button:补全 popover 依赖tooltip:补全 button 依赖block-context-menu:只读模式下禁止弹出右键菜单block-suggestion:修正样式suggestion-leaf-static:新增静态版本Plate 46 - 新代码块
code-block-element-static、code-block-element、code-block-combobox:改为使用 lowlight 的 class,默认 github 主题code-syntax-leaf-static、code-syntax-leaf:改为使用 lowlight 的 token classprismjs 依赖和相关样式prism 改为 lowlightcode-block-combobox:增加 Auto 语言选项,语言值与 lowlight 对齐autoformat-plugin:禁止在代码块中自动格式化import { all, createLowlight } from 'lowlight';
const lowlight = createLowlight(all);
CodeBlockPlugin.configure({
options: {
lowlight,
},
});
image-preview:阻止 image preview 遮罩层弹出 block 菜单media-popover:image preview 打开时隐藏媒体弹窗Plate 45 - 新评论和建议 UI
block-discussion,作为主要容器,在 plate-element 使用comment,用于单条评论显示comment-create-form,内嵌精简版 Plate 编辑器方便输入comments-popovercomment-avatarcomment-reply-itemscomment-valuecomment-resolve-buttonblock-suggestionsuggestion-leafsuggestion-line-breakplate-element,改为从 @udecode/plate/react 引入 PlateElement。并在 block-selection-plugins 中增加如下:render: {
belowRootNodes: (props) => {
if (!props.className?.includes('slate-selectable')) return null;
return <BlockSelection />;
},
},
comment-more-dropdown:移除 useCommentEditButtonState、useCommentDeleteButtonStateimage-element、media-embed-element、media-video-element、mode-dropdown-menu
const width = useResizableValue('width')image-preview:移除 useScaleInputState、useImagePreviewStatefloating-toolbar:
useEventEditorValue 替换 useEventEditorSelectorsmedia-popover:
FloatingMediaStore.set 替换 floatingMediaActionsuseFloatingMediaValue 替换 useFloatingMediaSelectorstable-element:修复样式,折叠时显示表格边框控件table-row-element:重构table-cell-element:选中时使用品牌色背景table-element、table-row-element:支持行拖拽和选择plate-element:增加 blockSelectionClassName 属性editor:选区区域 z-50draggable:
editor.api.blockSelection.replaceSelectedIds 为 editor.api.blockSelection.clearTooltipButtoncolumn-element、table-cell-element:增加 isSelectionAreaVisible 检查block-selection:拖拽时隐藏editor.api.blockSelection.addSelectedRow 为 editor.api.blockSelection.set,涉及:
ai-menuequation-popoveralign-dropdown-menu:弃用inline-equation-element 和 equation-popover:修复选择行内公式时不应弹出浮窗,否则导致选区丢失emoji-picker-search-bar:增加 autoFocusimport-toolbar-button 和 export-toolbar-button:增加 markdown 支持fixed-toolbar-buttons:增加 import-toolbar-buttonindent-fire-marker.tsx:增加 data-plate-prevent-deserialization 防止火标反序列化,将标签由 span 改为 liindent-todo-marker.tsx:将标签由 span 改为 liimage-element-static.tsx 和 hr-element-static.tsx:修复 nodeProps 未传递给 SlateElementai-chat-editor:const aiEditor = usePlateEditor({ plugins });
useAIChatEditor(aiEditor, content);
ai-plugins:移除 createAIEditor,现在于 ai-chat-editor 创建ai-chat-editor:仅需使用 useAIChatEditor(v42.1)ai-menu:避免冲突,移除 aiEditorRefcommand:增加 focus-visible:outline-noneeditor-static:调整 aiChat 内边距transforms:修复 slash 命令用到的 insertBlock:插入的新块与当前类型一致时新建一块block-selection-plugins:升级 BlockSelectionPluginBlockSelectionPlugin.configure(({ editor }) => ({
options: {
enableContextMenu: true,
isSelectable: (element, path) => {
return (
!['code_line', 'column', 'td'].includes(element.type) &&
!editor.api.block({ above: true, at: path, match: { type: 'tr' } })
);
},
},
}))
table-element、table-element-static
table-iconscolgroup,列宽现由 table-cell-element 控制table-row-element:移除 hideBorder 属性table-cell-element、table-cell-element-static:
table-dropdown-menu:
tooltip:新增 TooltipButtonindent-list-toolbar-button:移除 IndentListToolbarButton,使用 NumberedIndentListToolbarButton 和 BulletedIndentListToolbarButtontable-dropdown-menu:全新插入表格界面column-group-element:修复 ColumnFloatingToolbar 的 onColumnChangeexport-toolbar-button:新增 katex 支持plate-element:移除 relative classNamePlateElement 的组件均已移除冗余 relative classNamefixed-toolbar-buttons:增加 font-size-toolbar-buttonfloating-toolbar:增加 inline-equation-toolbar-buttonturn-into-dropdown-menu:修复转换后应自动聚焦到编辑器insert-dropdown-menu:新增 inline equation 和 equation,修复聚焦问题slash-input-element:新增 equation 和 inline equationtable-element:修复选区isSelectingCell && '[&_*::selection]:bg-none'isSelectingCell && '[&_*::selection]:!bg-transparent'升级 tailwind.config.cjs,优化 HTML 导出字体配置:
fontFamily: {
heading: [
'var(--font-heading)',
'ui-sans-serif',
'-apple-system',
'BlinkMacSystemFont',
'Segoe UI Variable Display',
'Segoe UI',
'Helvetica',
'Apple Color Emoji',
'Arial',
'sans-serif',
'Segoe UI Emoji',
'Segoe UI Symbol',
'Noto Color Emoji',
],
mono: ['var(--font-mono)', ...fontFamily.mono],
sans: [
'var(--font-sans)',
'ui-sans-serif',
'-apple-system',
'BlinkMacSystemFont',
'Segoe UI Variable Display',
'Segoe UI',
'Helvetica',
'Apple Color Emoji',
'Arial',
'sans-serif',
'Segoe UI Emoji',
'Segoe UI Symbol',
'Noto Color Emoji',
],
insertColumnGroup、toggleColumnGroup:使用 columns 选项代替 layout。with-draggables。将 DraggableAboveNodes 添加到 draggable。在 DndPlugin 配置中加入:DndPlugin.configure({ render: { aboveNodes: DraggableAboveNodes } }),
column-element、image-element、media-video-element:移除 useDraggableState,改用 const { isDragging, previewRef, handleRef } = useDraggablecolumn-group-element:移除 useColumnState,改用如下方式:const columnGroupElement = useElement<TColumnGroupElement>(ColumnPlugin.key);
const onColumnChange = (widths: string[]) => {
setColumns(editor, {
at: findNodePath(editor, columnGroupElement),
widths,
});
};
export-toolbar-button:新增 exportToHtmlPlate 41
-static.tsx 结尾。现在这些组件会与默认客户端组件一起添加。editor:在 editorVariants 中新增 select-textdate-element:只读时移除弹窗indent-todo-marker:使用 SlateRenderElementProps 类型代替 PlateRenderElementPropshr-element、media-audio-element、media-embed-element、mention-element:优化光标样式media-file-element:使用 <a> 替换原有的 div + onClickclassName prop 目前均放在 inline prop 之前column-element:
column-group-element:
draggable:
DraggableProvider HOCDropLine 的 children 属性https://github.com/udecode/plate/pull/3809/files
select-editor、tag-element、label、formcmdk 依赖替换为 @udecode/cmdk。该版本可控。command:新增 variantseditor:新增 select variantpopover:新增 animate varianthttps://github.com/udecode/plate/pull/3807/files
toc-element:为修复 html2canvas 问题,移除 <nav> 标签,改用 <div>editor:移除 role="button",以修正 html2canvas 问题Shadcn 同步:
input:新增 text-base md:text-smtextarea:新增 text-base md:text-smeditor(ai、aiChat variants):新增 text-base md:text-smtoolbar:新增 ToolbarSplitButton、ToolbarSplitButtonPrimary、ToolbarSplitButtonSecondarymedia-toolbar-button:采用 ToolbarSplitButtonresizable:只读状态下隐藏 ResizeHandle// plugins
require("tailwind-scrollbar-hide")
// theme.extend.screens
screens: {
/**
* 匹配主指针设备可方便悬浮的设备。用法:main-hover:group-hover:bg-red-500
* 参考:https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hover
*
* 在 iOS 设备中,包含 `group-hover:` CSS 规则的 .group 内按钮需点击两次。为规避此问题,无法方便悬浮的设备使用 `main-hover:` 禁用这些规则。
*/
'main-hover': {
raw: '(hover: hover)',
},
},
editor:
EditorContainer:移除 ref,改用 useEditorContainerRefcaret-primary selection:bg-brand/25EditorContainer 增加 id={editor.uid},以便移除 scroll_container 或你自定义的 iddraggable:
main-hover:group-hover:opacity-100 解决。table-element:修复宽度问题table-row-element、table-cell-element:支持行选择date-element、mention-element:新增 draggable proplink-toolbar-button、link-floating-toolbar、ai-menu 输入框:新增 data-plate-focus 属性cursor-overlay:
DragOverCursorPlugin、SelectionOverlayPlugin,请使用 @udecode/plate-selectionghost-text:超小屏下隐藏,新增 pointer-events-nonefloating-toolbar:新增 overflow-x-auto scrollbar-hide,支持移动端横向滚动fixed-toolbar:新增 scrollbar-hideemoji-picker-content:新增 emoji 字体column-element:默认添加 w-fulluse-is-touch-deviceblock-context-menu:触屏设备上禁用ai-toolbar-button:新增 onMouseDownai-menu-items:增加未定义检查block-selection-plugins:添加inject: {
excludeBelowPlugins: ['tr'],
excludePlugins: ['table', 'code_line', 'column_group', 'column'],
},
floating-toolbar-plugin、fixed-toolbar-pluginhr-element、plate-element、transformsblock-context-menu:点击菜单时阻止失焦block-selection:在 onCloseAutoFocus 中添加 editor.getApi(BlockSelectionPlugin).blockSelection.focus()editor:新增 overflow-x-hidden 样式,防止横向滚动table-element:新增 overflow-x-auto,支持横向滚动editor:样式和新增 <EditorContainer />lib/transforms.ts,包含常用操作的实用转换函数。Icons 文件的依赖,所有图标现均从 lucide-react 导入。dropdown-menucontext-menuinline-comboboxslash-input-element 支持分组与分项目展示ai-menu-itemsalign-dropdown-menublock-context-menubuttoncode-block-comboboxcolor-dropdown-menu-itemscolor-pickercolumn-group-elementcommandcomment-more-dropdowncontext-menudropdown-menuemoji-dropdown-menuemoji-input-elementimage-previewinline-comboboxinputinsert-dropdown-menuline-height-dropdown-menulink-floating-toolbarmedia-popovermention-input-elementmode-dropdown-menumore-dropdown-menupopoverslash-input-elementtable-dropdown-menutable-elementtoggle-elementtoggle-toolbar-buttonindent-todo-marker-component 重命名为 indent-todo-marker。slash-input-element:增加 AI 命令并新增 focusEditor 选项ai-menu、ai-menu-items、ai-toolbar-button、ai-chat-editor、block-context-menu、context-menu、ghost-text、toc-elementcommand:增加 InputCommandtoolbar 新样式editor 演示版本heading-element:移除 isFirstBlock 属性fixed-toolbar、fixed-toolbar-buttons、floating-toolbar、floating-toolbar-buttons、mode-dropdown-menu、turn-into-dropdown-menu、button、cursor-overlay、excalidraw-element、inline-combobox、slash-input-elementshadcx。参见 CLI 和 components.json。dropdown-menu (DropdownMenuContent):阻止 onCloseAutoFocus 的默认行为floating-toolbar (FloatingToolbar):移除 portal,点击外部或浮动链接打开时自动隐藏turn-into-dropdown-menu (TurnIntoDropdownMenu):新增缩进列表项table-dropdown-menu (TableDropdownMenu):在 insertTable 时支持选择emoji-picker:调整 ui,优化表情选择器外观block-selection 组件,用于可视化块选反馈plate-element 组件,可配合 BlockSelection 渲染 plate 元素paragraph-element 及所有块级组件以统一使用 plate-elementdraggable:
useDraggableGutter 与 useDropLineclassNames 属性,统一改为 classNameDraggableProvider 容器Gutter 和 DropLine 组件with-draggables:
className 格式mention-element:解决 MacOS 下输入法输入过程被中断的问题以下组件使用 --highlight 颜色:
comment-leafhighlight-leaf以下组件使用 --highlight 颜色:
comment-leafhighlight-leaf以下组件使用 --brand 颜色:
block-selectiondraggableheading-element:如果标题是首个区块,则不应有顶部间距code-block-combobox:支持按 label 或 value 过滤floating-toolbar:当只读时也显示工具栏emoji-picker:适配 shadcn 主题与样式cursor:当光标数据未定义时也显示选区矩形/光标fixed-toolbar:top-0code-block-comboboxcaption:当元素 caption 属性变化时自动更新 UIinline-combobox 替换原有 comboboxmention-combobox、emoji-combobox 和 slash-comboboxemoji-input-elementmention-input-element 和 slash-input-element,使用新 comboboxdraggable:增加 data-key 属性,便于拖拽操作完成后添加选区CaptionButton 或将媒体元素 ID 传递给 captionActions.showCaptionId 打开标题floating-toolbar 增加 portalElement 属性draggable:加入 portal 以解决裁剪问题,按钮阻止表单提交editor:增加 x 轴内边距,提高拖拽把手可见性site-header:zIndex 调整为 60fixed-toolbar:zIndex 调整为 60indent-todo-marker-component:点击勾选框会丢失焦点column-element、column-group-elementcombobox:撤销操作导致编辑器崩溃list-element:variant 样式缺失mention-element:点击 mention 下拉菜单的滚动条后,Mention 输入会被移除
(#2919)toggle-elementtoggle-toolbar-buttoncomponents.json 支持自定义 ui 目录plate-components.json,避免与 shadcn 的 components.json 冲突toolbar
Toolbar:将 items-stretch 替换为 items-centertoolbarButtonVariants 代替 toggleVariantsvalue prop 类型错误withTooltip,需将 [data-state=on] 替换为 aria-checked 以避免冲突toggle:作为未使用内容已移除tooltip:新增 withTooltip,ToolbarButton 已在使用table-element:需在 TableElement 上层渲染 TableProvider// 变更前
export const TableElement = withRef<typeof PlateElement>(
({ className, children, ...props }, ref) => {
// ...
}
);
// 变更后
export const TableElement = withHOC(
TableProvider,
withRef<typeof PlateElement>(({ className, children, ...props }, ref) => {
// ...
})
);
dropdown-menu:修复 DropdownMenuContent 不应排除 className移除 clsx 依赖,class-variance-utility 已经导出 cx
新增依赖:@udecode/cn
用 @udecode/cn 替换 @/lib/utils.ts,所有从 @/lib/utils 的导入需替换为 @udecode/cn
withProps 现从 @udecode/cn 导入,不再从 @udecode/plate 导入
所有使用 forwardRef 的组件现在使用 withRef。同时引入 withProps、withCn、withVariants 以减少样板代码
在 ESLint settings.tailwindcss.callees 和 IDE classAttributes 配置中添加 withCn
// 变更前
const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
className
)}
{...props}
/>
));
Avatar.displayName = AvatarPrimitive.Root.displayName;
export { Avatar };
// 变更后
export const Avatar = withCn(
AvatarPrimitive.Root,
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full'
);
comboboxinsert-dropdown-menumedia-popovermode-dropdown-menumore-dropdown-menutable-dropdown-menutable-elementturn-into-dropdown-menuimage-element:用 withHOC(ResizableProvide, ...) 包裹组件media-embed-element:同样用 withHOC(ResizableProvide, ...) 包裹组件table-element
table-cell-element
comments-popover
toolbar
editor:新组件 🎉 详见 Editorfixed-toolbar-buttons、floating-toolbar-buttons、mode-dropdown-menu:
usePlateReadOnly 重命名为 useEditorReadOnlycode-block-element:code-block-element.css 有调整table-element
floating-toolbar:
comment-leaf、link-element
body 添加如下类:'[&_.slate-selected]:!bg-primary/20 [&_.slate-selection-area]:border [&_.slate-selection-area]:border-primary [&_.slate-selection-area]:bg-primary/10'button:增加 whitespace-nowrappopover:打印时隐藏caption:打印时隐藏占位内容highlight-leaf:高亮颜色现在基于主色floating-toolbar - 详细更改:
refuseFloatingToolbarState,控制 floatingOptions 默认值fallbackPlacements 避免浮动溢出视口portalElement、floatingOptions、ignoreReadOnly、hideToolbarstate 属性link-floating-toolbar - 详细更改:
floatingOptions 默认值fallbackPlacements,防止浮动溢出mention-element - 新特性:支持加粗、斜体、下划线table-cell-element - 新特性:支持表格单元格背景样式image-element:重构:使用 mediaResizeHandleVariantsmedia-embed-element:重构:使用 mediaResizeHandleVariantsresizable - 详细更改:
mediaResizeHandleVariantstable-cell-element:
caption — 新组件image-element:
caption、resizablemedia-embed-element 现在是完全 headless:
react-lite-youtube-embed、react-tweet,减小包体积caption、resizablemedia-popover — 修复:弹窗关闭异常resizable — 新组件table-element — 修复:弹窗关闭异常comments-popover — 修复:新评论时弹窗无法打开comment-toolbar-button — 新特性:myUserId 为空时不显示excalidraw-element — 修复:拼写错误Plate headless 组件现已发布: