Loading...
Files
components/excalidraw-demo.tsx
'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>
  );
}