Events
The editorEvents
Two ways to react to changes: the Unlayer-style event bus, or a React callback.
design:updated#
Register through the ref inside onReady. It fires on every design mutation (handlers receive no arguments, call saveDesign/exportHtml to read current state).
ts
const onReady = () => {
const handler = () => {
editorRef.current?.editor.saveDesign((d) => autosave(d));
};
editorRef.current?.editor.addEventListener("design:updated", handler);
};error#
Fires when the editor is not running as it was set up, with { code, message }. Pass onError (React prop, @error in Vue, (error) in Angular, the onError option in vanilla) or listen with addEventListener("error", fn). Each code fires once.
invalid_embed_token: the token does not exist or was revoked. The editor runs on the free plan.domain_not_allowed: this page's domain is not on the token's allow-list. Free plan.token_expired: the account's plan ended. Free plan.runtime_unreachable: the MailKaro API could not be reached. Free plan.editor_not_started: the editor frame did not answer within 20 seconds (a wrongembedUrl, or the frame was refused).
tsx
<EmailEditor token="pk_live_..." onError={(e) => report(e.code, e.message)} />onReady / onLoad#
Both fire exactly once on mount, onLoad first. Use them to load an initial design or wire listeners.
React callback (lower-level)#
If you use EmailEditor directly, pass onDesignChange, it receives the full design on every change.
tsx
<EmailEditor onDesignChange={(design) => autosave(design)} />