UNPKG

@actovision/kaptha-email-editor

Version:

React wrapper for Kaptha Email Editor - A powerful drag-and-drop email editor with framework-agnostic API

94 lines (90 loc) 2.26 kB
import * as React from 'react'; /** * @actovision/kaptha-email-editor - React Wrapper for Kaptha Email Editor * * This package provides a React component wrapper that loads Kaptha Email Editor * from CDN as a self-contained bundle and provides a React interface. * * The CDN bundle is framework-agnostic and includes its own React instance, * eliminating React version conflicts. * * @example * ```tsx * import KapthaEmailEditor from '@actovision/kaptha-email-editor'; * * function App() { * return ( * <KapthaEmailEditor * apiKey="kpt_dev_ws001_demo12345678" * minHeight="600px" * onReady={() => console.log('Editor ready!')} * /> * ); * } * ``` */ interface EmailDesign { components: any[]; } interface EditorMethods { loadDesign: (design: EmailDesign) => void; saveDesign: () => EmailDesign; exportHtml: () => Promise<{ html: string; mjml: string; }>; exportMjml: () => string; exportJson: () => EmailDesign; destroy: () => void; } interface CustomBlock { id: string; name: string; category?: string; thumbnail?: string; components: any[]; } interface KapthaEmailEditorProps { /** * API key (required) * Get your free key at: hello@kaptha.com */ apiKey: string; /** * Minimum height of the editor * @default '600px' */ minHeight?: string; /** * Custom blocks to add to the editor */ customBlocks?: CustomBlock[]; /** * Initial design to load */ initialDesign?: EmailDesign; /** * Callback when editor is ready */ onReady?: () => void; /** * Callback when design changes */ onDesignChange?: (design: EmailDesign) => void; /** * Callback when editor loads */ onLoad?: () => void; } declare global { interface Window { KapthaEmailEditor?: any; } } /** * Kaptha Email Editor React Component * * Loads the editor from CDN and provides a React interface */ declare const KapthaEmailEditor: React.ForwardRefExoticComponent<KapthaEmailEditorProps & React.RefAttributes<EditorMethods>>; export { type CustomBlock, type EditorMethods, type EmailDesign, KapthaEmailEditor as default };