Draggable

A drag handle for moving editor blocks.

Installation

npx shadcx@latest add plate/draggable

Usage

import { DndPlugin } from '@udecode/plate-dnd'; import { NodeIdPlugin } from '@udecode/plate-node-id'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { withDraggables } from './withDraggables';
export function MyEditor() { const editor = usePlateEditor({ plugins: [ // ...otherPlugins, NodeIdPlugin, DndPlugin.configure({ options: { enableScroller: true } }), ], override: { components: withDraggables({ // ...components }), } }); return ( <DndProvider backend={HTML5Backend}> <Plate editor={editor}> <PlateContent /> </Plate> </DndProvider> ); }

Examples

Drag & Drop
Loading...
Files
components/demo.tsx
'use client';

import React from 'react';

import { Plate } from '@udecode/plate-common/react';

import { editorPlugins } from '@/components/editor/plugins/editor-plugins';
import { useCreateEditor } from '@/components/editor/use-create-editor';
import { Editor, EditorContainer } from '@/components/plate-ui/editor';

import { DEMO_VALUES } from './values/demo-values';

export default function Demo({ id }: { id: string }) {
  const editor = useCreateEditor({
    plugins: [...editorPlugins],
    value: DEMO_VALUES[id],
  });

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

Plate Plus

  • "+" button on the left gutter to insert blocks
  • Click on the drag handle to open the block menu
  • Beautifully crafted UI