Loading…
套件使用
安装
最快添加提示框插件的方式是使用 CalloutKit,它包含预配置的 CalloutPlugin 和 Plate UI 组件。
'use client';
import { CalloutPlugin } from '@platejs/callout/react';
import { CalloutElement } from '@/components/ui/callout-node';
export const CalloutKit = [CalloutPlugin.withComponent(CalloutElement)];'use client';
import { CalloutPlugin } from '@platejs/callout/react';
import { CalloutElement } from '@/components/ui/callout-node';
export const CalloutKit = [CalloutPlugin.withComponent(CalloutElement)];CalloutElement: 渲染提示框元素
添加套件
将套件添加到你的插件中:
import { createPlateEditor } from 'platejs/react';
import { CalloutKit } from '@/components/editor/plugins/callout-kit';
const editor = createPlateEditor({
plugins: [
// ...其他插件
...CalloutKit,
],
});import { createPlateEditor } from 'platejs/react';
import { CalloutKit } from '@/components/editor/plugins/callout-kit';
const editor = createPlateEditor({
plugins: [
// ...其他插件
...CalloutKit,
],
});手动使用
安装
pnpm add @platejs/calloutpnpm add @platejs/callout添加插件
在创建编辑器时,将 CalloutPlugin 包含到 Plate 插件数组中。
import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件
CalloutPlugin,
],
});import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件
CalloutPlugin,
],
});配置插件
你可以通过自定义组件来配置 CalloutPlugin 以渲染提示框元素。
import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
import { CalloutElement } from '@/components/ui/callout-node';
const editor = createPlateEditor({
plugins: [
// ...其他插件
CalloutPlugin.withComponent(CalloutElement),
],
});import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
import { CalloutElement } from '@/components/ui/callout-node';
const editor = createPlateEditor({
plugins: [
// ...其他插件
CalloutPlugin.withComponent(CalloutElement),
],
});withComponent: 指定CalloutElement来渲染提示框元素
Plate Plus
- Insert callouts using the slash command
- Ability to change the callout emoji
- Beautifully crafted UI
插件
CalloutPlugin
提示框元素插件。
转换器
tf.insert.callout
向编辑器中插入提示框元素。
钩子
useCalloutEmojiPicker
管理提示框的表情符号选择器功能。
类型
TCalloutElement
interface TCalloutElement extends TElement {
variant?: string;
icon?: string;
}interface TCalloutElement extends TElement {
variant?: string;
icon?: string;
}