DraggableBlockExtension
Intuitive drag-and-drop for content blocks
Transform your editor with smooth, professional drag-and-drop functionality. Rearrange paragraphs, images, and any content blocks with visual feedback and animations.
Key Features
Everything you need for seamless block rearrangement in your editor.
Hover over blocks to reveal drag handles. Click and drag to move content with smooth visual feedback.
Drag blocks directly, use up/down buttons, or even drag via text selection for flexible content rearrangement.
Real-time drag state updates without polling. Access `activeStates.isDragging` for immediate feedback on drag operations.
Quick Start
Get drag-and-drop working in your editor in just a few lines.
Import and add DraggableBlockExtension
Customize drag behavior
Try DraggableBlockExtension
Interactive demo showcasing drag-and-drop features. Hover over blocks, grab handles, and rearrange content!
DraggableBlockExtension Demo
Try dragging blocks, using move buttons, and text selection drag
Reactive State System
Access drag state reactively without performance-killing polling.
Access reactive drag state
The activeStates.isDragging updates immediately when drag operations start and stop, providing real-time feedback without any polling.
Configuration Options
Customize every aspect of the drag-and-drop experience.
| Option | Type | Description |
|---|---|---|
| showMoveButtons | boolean | Show up/down arrow buttons for manual block movement. |
| showUpButton | boolean | Enable the move up button specifically. |
| showDownButton | boolean | Enable the move down button specifically. |
| buttonStackPosition | 'left' | 'right' | Position of the move buttons relative to blocks. |
| enableTextSelectionDrag | boolean | Allow dragging blocks by selecting text within them. |
| theme | object | CSS class names for customizing handles, indicators, and animations. |
| handleRenderer | function | Custom renderer for drag handles with full control. |
| buttonsRenderer | function | Custom renderer for move up/down buttons. |
| dropIndicatorRenderer | function | Custom renderer for the drop indicator line. |
Custom styling with theme classes
Custom handle renderer for full control
API Reference
Commands and state queries for programmatic control.
moveBlock(sourceKey, targetKey, insertAfter)Programmatically move a block to a new position.
moveCurrentBlockUp()Move the currently selected block up one position.
moveCurrentBlockDown()Move the currently selected block down one position.
isDraggingReal-time boolean indicating if a drag operation is in progress.
Using commands programmatically
Best Practices
Tips for the best drag-and-drop experience.
Always provide clear visual cues like handles and drop indicators to guide users through the drag process.
The reactive state system ensures optimal performance without polling. Animations are hardware-accelerated for smooth 60fps experience.
Ensure drag handles are keyboard accessible and provide alternative navigation methods for users who can't use a mouse.
Test with real users to ensure the drag interaction feels natural and intuitive in your specific use case.