Emoji
Insert emoji inline.
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-emoji
使用
import { EmojiPlugin } from '@udecode/plate-emoji/react';
const plugins = [
// ...otherPlugins,
EmojiPlugin,
];
插件
EmojiPlugin
Options
Collapse all
一个用于指定选择表情符号时插入的节点的函数。默认行为是插入一个包含表情符号作为 Unicode 字符的文本节点。
EmojiInputPlugin
处理表情符号插入的输入行为。