Loading…
Kit Usage
Installation
The fastest way to add the callout plugin is with the CalloutKit, which includes pre-configured CalloutPlugin with the Plate UI component.
'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: Renders callout elements.
Add Kit
Add the kit to your plugins:
import { createPlateEditor } from 'platejs/react';
import { CalloutKit } from '@/components/editor/plugins/callout-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...CalloutKit,
],
});import { createPlateEditor } from 'platejs/react';
import { CalloutKit } from '@/components/editor/plugins/callout-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...CalloutKit,
],
});Manual Usage
Installation
pnpm add @platejs/calloutpnpm add @platejs/calloutAdd Plugin
Include CalloutPlugin in your Plate plugins array when creating the editor.
import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
CalloutPlugin,
],
});import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
CalloutPlugin,
],
});Configure Plugin
You can configure the CalloutPlugin with a custom component to render callout elements.
import { CalloutPlugin } from '@platejs/callout/react';
import { createPlateEditor } from 'platejs/react';
import { CalloutElement } from '@/components/ui/callout-node';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
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: [
// ...otherPlugins,
CalloutPlugin.withComponent(CalloutElement),
],
});withComponent: AssignsCalloutElementto render callout elements.
Plate Plus
- Insert callouts using the slash command
- Ability to change the callout emoji
- Beautifully crafted UI
Plugins
CalloutPlugin
Callout element plugin.
Transforms
tf.insert.callout
Insert a callout element into the editor.
Hooks
useCalloutEmojiPicker
Manage the emoji picker functionality for callouts.
Types
TCalloutElement
interface TCalloutElement extends TElement {
variant?: string;
icon?: string;
}interface TCalloutElement extends TElement {
variant?: string;
icon?: string;
}