Caption
Add captions to your blocks.
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-caption
使用
import { CaptionPlugin } from '@udecode/plate-caption/react';
import {
AudioPlugin,
FilePlugin,
ImagePlugin,
MediaEmbedPlugin,
VideoPlugin,
} from '@udecode/plate-media/react';
const plugins = [
// ...otherPlugins,
ImagePlugin,
VideoPlugin,
AudioPlugin,
FilePlugin,
MediaEmbedPlugin,
CaptionPlugin.configure({
options: {
plugins: [
ImagePlugin,
VideoPlugin,
AudioPlugin,
FilePlugin,
MediaEmbedPlugin,
],
},
}),
];
插件
CaptionPlugin
Options
Collapse all
具有标题的块的插件键。
聚焦到标题末尾的路径。
聚焦到标题开头的路径。
可见标题的 ID。
标题是否可见。
API
TCaptionElement
Attributes
Collapse all
扩展 TElement
.
标题值。
API Components
Caption
Props
Collapse all
CaptionTextarea
Props
Collapse all