Skip to main content
The DragHandle extension adds a draggable handle to blocks in your editor, allowing users to reorder content by dragging. It uses Floating UI for intelligent positioning and supports nested content like list items and blockquotes.

Installation

Basic Usage

Styling the Drag Handle

Configuration Options

() => HTMLElement
required
Function that renders and returns the drag handle element.
ComputePositionConfig
Configuration for position computation using the Floating UI library. See Floating UI documentation for details.Default:
Example:
() => VirtualElement | null
Function that returns a virtual element for positioning. Useful when the drag handle needs to be positioned relative to a specific DOM element.
boolean
Whether the drag handle is locked in place and visibility.Default: false
function
Callback function called when a node is hovered over or unhovered.Parameters:
  • node: The hovered node (or null if unhovered)
  • editor: The editor instance
(e: DragEvent) => void
Callback fired when dragging starts.
(e: DragEvent) => void
Callback fired when dragging ends.
boolean | NestedOptions
Enable drag handles for nested content like list items and blockquotes.Default: falseSimple enable:
With configuration:
Nested Options:
DragHandleRule[]
Custom rules to determine which nodes are draggable. These run after the default rules.
boolean
Whether to include default rules for common cases like list items.Default: true
string[]
Restrict nested dragging to specific container types.
'left' | 'right' | 'both' | 'none'
Control when to prefer parent over nested node based on cursor position.
  • 'left' (default): Prefer parent near left/top edges
  • 'right': Prefer parent near right/top edges (for RTL)
  • 'both': Prefer parent near any horizontal edge
  • 'none': Disable edge detection
Or pass a config object:

Commands

command
Lock the drag handle in place and visibility.
command
Unlock the drag handle.
command
Toggle the drag handle lock state.

Advanced Examples

Custom Drag Handle with Icon

Track Drag Events

Enable Nested Dragging for Lists

Custom Rules for Nested Dragging

Right-Side Placement (RTL)

Lock/Unlock Programmatically

React Integration

Styling Examples

Animated Drag Handle

Nested Content Styling

Source Code

View the source code on GitHub: