Documentation
v1.0.0GitHub
UI Component
🎨
Visual Editor
Main drag-and-drop interface for building AI prompts visually
Overview
The Visual Editor is the core component of the vibecode framework, providing an intuitive drag-and-drop interface for creating structured AI prompts. It combines block-based editing with real-time preview and export functionality.
Drag & Drop
Intuitive block manipulation with visual feedback
Block System
Modular prompt components with type safety
Real-time Preview
Live XML generation and formatting
Usage Example
Basic Implementation
import { VisualEditor } from '@vibecode/core';
import { useEditorEvents } from '@vibecode/hooks';
import { templateRegistry } from '@vibecode/templates';
function App() {
const editorEvents = useEditorEvents();
return (
<div className="h-screen flex">
<VisualEditor
blocks={editorEvents.blocks}
focusedBlockId={editorEvents.focusedBlockId}
onAddBlock={editorEvents.onAddBlock}
onUpdateBlock={editorEvents.onUpdateBlock}
onDeleteBlock={editorEvents.onDeleteBlock}
onMoveBlock={editorEvents.onMoveBlock}
onReorderBlocks={editorEvents.onReorderBlocks}
onSetFocusedBlock={editorEvents.onSetFocusedBlock}
templates={templateRegistry.getAll()}
/>
</div>
);
}Props API
VisualEditor Props
blocksBlock[]requiredArray of blocks to render in the editor
focusedBlockIdstring | nullID of the currently focused block
onAddBlock(type: BlockType, afterBlockId?: string) => voidCalled when a new block is added
onUpdateBlock(blockId: string, updates: Partial<Block>) => voidCalled when a block is modified
onDeleteBlock(blockId: string) => voidCalled when a block is deleted
classNamestringoptionalAdditional CSS classes for styling
Key Features
Drag & Drop Interface
- • Smooth drag interactions with visual feedback
- • Drop zones with intelligent block placement
- • Auto-scroll during drag operations
- • Keyboard navigation support
Block Management
- • Add blocks from palette or slash commands
- • Inline editing with auto-save
- • Block duplication and templates
- • Undo/redo functionality
Live Preview
- • Real-time XML generation as you type
- • Token count estimation
- • Export to multiple formats
- • Preview panel with syntax highlighting