Installation

npx shadcn@latest add https://platejs.org/r/code-drawing-node

Examples

Loading...
Files
components/code-drawing-demo.tsx
'use client';

import * as React from 'react';

import { CodeDrawingPlugin } from '@platejs/code-drawing/react';
import { Plate, usePlateEditor } from 'platejs/react';

import { EditorKit } from '@/components/editor/editor-kit';
import { codeDrawingValue } from '@/registry/examples/values/code-drawing-value';
import { Editor, EditorContainer } from '@/components/ui/editor';
import { CodeDrawingElement } from '@/components/ui/code-drawing-node';

export default function CodeDrawingDemo() {
  const editor = usePlateEditor({
    plugins: [
      ...EditorKit,
      CodeDrawingPlugin.withComponent(CodeDrawingElement),
    ],
    value: codeDrawingValue,
  });

  return (
    <Plate editor={editor}>
      <EditorContainer variant="demo">
        <Editor />
      </EditorContainer>
    </Plate>
  );
}