visual-editor-client
Client library for controlling the visual editor from a parent window.
This package provides the controller API and UI components for building property panels and controlling the visual editor running in an iframe.
Installation
npm install visual-editor-client
# or
pnpm add visual-editor-client
# or
yarn add visual-editor-client
Usage
Controller Hook
import { useVisualEditor } from "visual-editor-client";
import { PropertyPanel, SpacingControl } from "visual-editor-client/ui";
function EditorPanel() {
const iframeRef = useRef<HTMLIFrameElement>(null);
const {
isReady,
selection,
properties,
setProperties,
editMode,
setEditMode,
} = useVisualEditor(iframeRef.current);
return (
<div>
<iframe ref={iframeRef} src="http://localhost:5178" />
<button onClick={()
API
Controller Hooks
useVisualEditor(iframe) - Combined hook with all functionality
useController(iframe) - Create controller instance
useReady(controller) - Track ready state
useEditMode(controller) - Manage edit mode
useSelection(controller) - Track selected element
useProperties(controller, propertyNames?) - Track multiple properties
useProperty(controller, propertyName) - Track single property
useOperations(controller) - Element operations (delete, duplicate, move)
useNavigation(controller) - Element navigation (parent, child, siblings)
UI Components
PropertyPanel - Container for property controls
PropertySection - Group related controls
PropertySeparator - Visual separator
SpacingControl - Padding/margin control
TypographyControl - Font size and weight
ColorControl - Color picker
All components are unstyled and accept className/classNames props for full styling control.
License
MIT