Excalidraw
Unleash your creativity with the Excalidraw plugin, which enables you to embed and draw diagrams directly within your editor.
1
100%
Files
'use client';
import * as React from 'react';
import { ExcalidrawPlugin } from '@platejs/excalidraw/react';
import { Plate, usePlateEditor } from 'platejs/react';
import { EditorKit } from '@/components/editor/editor-kit';
import { excalidrawValue } from '@/registry/examples/values/excalidraw-value';
import { Editor, EditorContainer } from '@/components/ui/editor';
import { ExcalidrawElement } from '@/components/ui/excalidraw-node';
export default function ExcalidrawDemo() {
const editor = usePlateEditor({
plugins: [...EditorKit, ExcalidrawPlugin.withComponent(ExcalidrawElement)],
value: excalidrawValue,
});
return (
<Plate editor={editor}>
<EditorContainer variant="demo">
<Editor />
</EditorContainer>
</Plate>
);
}
excalidraw-demo


功能特性
- 集成 Excalidraw 库用于创建绘图和图表
安装
pnpm add @platejs/excalidraw
使用方式
import { ExcalidrawPlugin } from '@platejs/excalidraw/react';
const plugins = [
// ...其他插件
ExcalidrawPlugin,
];插入工具栏按钮
可以将此项添加到插入工具栏按钮来插入 Excalidraw 元素:
{
icon: <PenToolIcon />,
label: 'Excalidraw',
value: KEYS.excalidraw,
}插件
ExcalidrawPlugin
Excalidraw 空元素插件。
API 接口
insertExcalidraw
向编辑器中插入 Excalidraw 元素。
钩子函数
useExcalidrawElement
Excalidraw 组件的行为钩子。