docs/(plugins)/(functionality)/(utils)/trailing-block.cn.mdx
import { TrailingBlockPlugin } from 'platejs';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件
TrailingBlockPlugin,
],
});
该插件开箱即用,具有合理的默认配置,但也可以针对特定用例进行配置:
import { TrailingBlockPlugin } from 'platejs';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件
TrailingBlockPlugin.configure({
options: {
type: 'p', // 段落块
exclude: ['blockquote'], // 不在这些类型后添加
},
}),
],
});
配置选项:
type: 要插入的尾部块类型(默认为段落)exclude: 不应触发尾部块插入的块类型数组allow: 允许的块类型数组(与exclude互斥)filter: 自定义函数用于确定何时添加尾部块TrailingBlockPlugin确保在文档末尾或指定嵌套层级始终存在特定块类型的插件。
核心行为:
level选项支持嵌套结构