SDK Methods
Complete reference for all methods available on the Pexelize editor instance. These methods are available across all framework wrappers and the vanilla JS SDK.
Design
| Method | Signature | Return | Description |
|---|---|---|---|
loadDesign | (design: DesignJson) => void | void | Replace the current design with the provided JSON. |
getDesign | () => DesignJson | DesignJson | Return the current design as JSON. |
setBodyValues | (values: Partial<BodyValues>) => void | void | Update body-level values (background color, width, font family, etc.). |
setMergeTags | (tags: MergeTag[]) => void | void | Replace the merge tags available in the editor. |
setDesignTags | (tags: Record<string, string>) => void | void | Replace design tag values (rendered at export time). |
setDisplayConditions | (conditions: DisplayCondition[]) => void | void | Replace the display conditions available for rows. |
Export
| Method | Signature | Return | Description |
|---|---|---|---|
exportHtml | () => Promise<ExportHtmlData> | Promise<ExportHtmlData> | Export the design as responsive HTML. Returns { html, design }. |
exportImage | (options?: ExportImageOptions) => Promise<ExportImageData> | Promise<ExportImageData> | Export the design as a PNG/JPEG image. Returns { url, width, height }. |
exportPdf | (options?: ExportPdfOptions) => Promise<ExportPdfData> | Promise<ExportPdfData> | Export the design as a PDF. Returns { url, pages }. |
Configuration
| Method | Signature | Return | Description |
|---|---|---|---|
setLocale | (locale: string) => void | void | Change the editor UI language at runtime. |
setTextDirection | (dir: 'ltr' | 'rtl') => void | void | Change text direction at runtime. |
setTranslations | (translations: Record<string, Record<string, string>>) => void | void | Update or add translation strings. |
Tools
| Method | Signature | Return | Description |
|---|---|---|---|
setToolsConfig | (config: ToolsConfig) => void | void | Show/hide/lock specific content tools. |
registerCustomTool | (tool: CustomTool) => void | void | Register a custom tool at runtime. |
unregisterCustomTool | (toolId: string) => void | void | Remove a previously registered custom tool. |
Appearance
| Method | Signature | Return | Description |
|---|---|---|---|
setTheme | (theme: ThemeMode) => void | void | Switch between 'light' and 'dark' themes. |
setAccentColor | (color: AccentColor) => void | void | Change the editor accent color. |
setViewMode | (mode: ViewMode) => void | void | Switch between 'desktop', 'tablet', and 'mobile' views. |
setEditorMode | (mode: EditorMode) => void | void | Switch between 'email' and 'web' editor modes. |
Preview
| Method | Signature | Return | Description |
|---|---|---|---|
showPreview | () => void | void | Open the design preview modal. |
hidePreview | () => void | void | Close the design preview modal. |
Undo / Redo
| Method | Signature | Return | Description |
|---|---|---|---|
undo | () => void | void | Undo the last action. |
redo | () => void | void | Redo the last undone action. |
canUndo | () => boolean | boolean | Whether there are actions to undo. |
canRedo | () => boolean | boolean | Whether there are actions to redo. |
Element Control
| Method | Signature | Return | Description |
|---|---|---|---|
selectElement | (elementId: string) => void | void | Programmatically select a content element by ID. |
deselectElement | () => void | void | Clear the current selection. |
deleteElement | (elementId: string) => void | void | Remove a content element by ID. |
duplicateElement | (elementId: string) => void | void | Duplicate a content element by ID. |
moveElement | (elementId: string, direction: 'up' | 'down') => void | void | Move an element up or down within its column. |
Validation
| Method | Signature | Return | Description |
|---|---|---|---|
validate | () => ValidationResult | ValidationResult | Run validation checks and return errors/warnings. |
getValidationErrors | () => ValidationError[] | ValidationError[] | Get the current list of validation errors. |
Lifecycle
| Method | Signature | Return | Description |
|---|---|---|---|
isReady | () => boolean | boolean | Whether the editor is fully initialized. |
destroy | () => void | void | Destroy the editor and clean up resources. |
info
All Promise-returning methods reject with an EditorError if the operation fails. Wrap calls in try/catch for proper error handling.
warning
Calling methods before isReady() returns true (or before the ready event fires) will throw an error. Always wait for initialization to complete.