Trailing Block
Ensure a trailing block is always present in the document.
components/demo.tsx
'use client';
import React from 'react';
import { Plate } from '@udecode/plate-common/react';
import { editorPlugins } from '@/components/editor/plugins/editor-plugins';
import { useCreateEditor } from '@/components/editor/use-create-editor';
import { Editor, EditorContainer } from '@/components/plate-ui/editor';
import { DEMO_VALUES } from './values/demo-values';
export default function Demo({ id }: { id: string }) {
const editor = useCreateEditor({
plugins: [...editorPlugins],
value: DEMO_VALUES[id],
});
return (
<Plate editor={editor}>
<EditorContainer variant="demo">
<Editor />
</EditorContainer>
</Plate>
);
}
安装
npm install @udecode/plate-trailing-block
Usage
import { TrailingBlockPlugin } from '@udecode/plate-trailing-block';
const plugins = [
// ...其他插件,
TrailingBlockPlugin.configure({
options: {
level: 0,
type: 'p',
},
}),
];
Plugins
TrailingBlockPlugin
Options
Collapse all
- 默认值:
0
(根层级) - 默认值:
editor.getType(ParagraphPlugin)
- 默认值:
[]
(所有类型)
尾随节点应该所在的层级,第一层为 0。
尾随块的类型。
匹配这些类型中任意一个的节点过滤器。
不匹配这些类型中任意一个的节点过滤器。
自定义过滤函数。