Heading 1
This is a top-level heading, typically used for main titles and major section headers.
Heading 2
Secondary headings help organize content into clear sections and subsections.
Heading 3
Third-level headings provide further content structure and hierarchy.
"Blockquotes are perfect for highlighting important information, quotes from external sources, or emphasizing key points in your content."
Use headings to create a clear document structure that helps readers navigate your content effectively. Combine them with blockquotes to emphasize important information.
Horizontal rules help visually separate different sections of your content, creating clear breaks between topics or ideas.
1
100%
Files
'use client';
import * as React from 'react';
import { Plate, usePlateEditor } from 'platejs/react';
import { EditorKit } from '@/components/editor/editor-kit';
import { Editor, EditorContainer } from '@/components/ui/editor';
import { DEMO_VALUES } from './values/demo-values';
export default function Demo({ id }: { id: string }) {
const editor = usePlateEditor({
plugins: EditorKit,
value: DEMO_VALUES[id],
});
return (
<Plate editor={editor}>
<EditorContainer variant="demo">
<Editor />
</EditorContainer>
</Plate>
);
}
Basic block elements like headings, quotes, and code blocks.
basic-blocks-demo


功能特性
- 确保文档末尾始终存在特定类型的块
手动使用
添加插件
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选项支持嵌套结构 - 防止空文档,确保至少存在一个块
- 遵循过滤选项控制尾部块的添加时机