Appearance
Callable functions on Topol Plugin
You are reading the Email Editor v3 docs
Email Editor v4 is the current version. See this page in the v4 docs, or how to upgrade to v4.
The TopolPlugin global exposes methods for driving the editor from the host application, covering everything from saving and undo/redo to language management and dark mode. Each method is called on the window.TopolPlugin global:
js
window.TopolPlugin.save();Methods Reference
changeEmailToDesktop() => voidSwitches the editing canvas back to desktop view. Learn more
changeEmailToMobile() => voidSwitches the editing canvas to mobile view. Learn more
chooseFile(url: string) => voidReturns the selected file URL to the editor (for custom file manager). Learn more
createLanguage(lang: string) => voidCreates a new language mutation for the given language code and fires onLanguageCreated. Learn more
createNotification(notification: INotification) => voidDisplays a custom notification in the editor. Always shown, even with disableAlerts enabled. Learn more
deleteLanguage(lang: string) => voidDeletes a language mutation, after the editor shows a confirmation modal. Learn more
destroy() => voidTears down the editor: removes the iframe and empties the container element it was mounted into.
getMutations() => voidRequests the current list of language mutations; the editor returns it through the onGetMutations callback without modifying any state. Learn more
init(topolOptions: ITopolOptions) => voidInitializes the editor: creates the editor iframe inside the element from options.id and applies the passed options. Learn more
load(json: JSON) => voidLoads a template into the editor; accepts a JSON string or a parsed object. Learn more
openPremadeTemplatesSelection() => voidOpens the premade templates picker dialog. Learn more
redo() => voidRedoes the last undone change and fires onRedoChange. Learn more
refreshComments(key: string) => voidRefreshes the comment list; if key matches an open conversation, its detail refreshes too. Pass "" to refresh only the list. Learn more
refreshSyncedSections() => voidRefreshes synced sections listing and reloads placed sections with the latest changes. Learn more
save(options?: { lang?: string }) => voidRenders the current template server-side, then triggers the onSave(json, html, mutations, syncedSections) callback. The optional lang selects which language mutation's HTML is returned. Learn more
selectLanguage(lang: string) => voidSwitches the active editing language and fires onLanguageSelected. Learn more
setActiveMembers(activeMembers: string[]) => voidReplaces the presence list shown in the top bar — a display indicator, not co-editing. Learn more
setPreviewHTML(html: string | null) => voidOverrides the HTML shown in the preview pane — used with the onPreview callback to preview server-rendered output. Pass null to clear the override.
setPrimaryLanguage(lang: string) => voidMakes the given language the primary mutation, creating it first if it does not exist yet. Learn more
setSavedBlocks(savedBlocks: ISavedBlock[]) => voidReplaces the saved blocks list — call it after your application handles a block save, edit, or delete. Learn more
setTemplateName(newName: string) => voidSets the template name shown in the editor. Does not re-fire onTemplateRename, so it is safe to call from that callback. Learn more
toggleAutosaves() => voidOpens or closes the autosave history panel. Learn more
toggleBlocksAndStructuresVisibility() => voidBlurs or unblurs elements hidden by mobile-first visibility settings in the current view. Learn more
toggleChatAI() => voidOpens or closes the AI chat panel. Learn more
toggleComments() => voidOpens or closes the comments sidebar. Learn more
toggleControlPanel() => voidShows or hides the right-side control panel. Learn more
toggleDarkMode() => voidToggles dark mode rendering of the preview — for host applications with their own theme switch. Learn more
togglePreview() => voidEnters or leaves preview mode; leaving fires onPreviewClose. Learn more
togglePreviewSize() => voidToggles the preview viewport between mobile (375 px) and desktop width. Learn more
translateAllLanguages() => voidAI-translates every non-primary language from the primary in one pass, overwriting existing translations. Learn more
translateLanguage(lang: string, sourceLang?: string) => voidAI-translates a single language mutation, sourcing from the primary language unless sourceLang is given. Learn more
undo() => voidUndoes the last change and fires onUndoChange. Learn more
updateCustomBlockContent(content: string) => voidWrites new HTML content into the currently selected custom block. Learn more
updateOptions(options: Partial<ITopolOptions>) => voidReconfigures a running editor with a partial options object. Learn more
updateTemplate(json: JSON, options?: IUpdateTemplateOptions) => voidReplaces the whole template in a running editor and fires onTemplateUpdated; pass skipSnapshot: true to skip the undo snapshot. Learn more
Example Usage
js
// Load a template
window.TopolPlugin.load(templateJson);
// Trigger save
window.TopolPlugin.save();
// Save a specific language mutation
window.TopolPlugin.save({ lang: "en" });
// Update authorization header
window.TopolPlugin.updateApiAuthorizationHeader("Bearer new_token");
// Reconfigure a running editor
window.TopolPlugin.updateOptions({ language: "de" });
// Tear down the editor
window.TopolPlugin.destroy();TypeScript Interface
ts
export default interface ITopolPlugin {
changeEmailToDesktop: () => void;
changeEmailToMobile: () => void;
chooseFile: (url: string) => void;
createLanguage: (lang: string) => void;
createNotification: (notification: INotification) => void;
deleteLanguage: (lang: string) => void;
destroy: () => void;
getMutations: () => void;
init: (topolOptions: ITopolOptions) => void;
load: (json: JSON) => void;
openPremadeTemplatesSelection: () => void;
redo: () => void;
refreshComments(key: string): void;
refreshSyncedSections: () => void;
save: (options?: { lang?: string }) => void;
selectLanguage: (lang: string) => void;
setActiveMembers: (activeMembers: string[]) => void;
setMergeTags(mergeTags: Array<unknown>): void;
setPreviewHTML: (html: string | null) => void;
setPrimaryLanguage: (lang: string) => void;
setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
setTemplateName(newName: string): void;
toggleAutosaves: () => void;
toggleBlocksAndStructuresVisibility: () => void;
toggleChatAI: () => void;
toggleControlPanel: () => void;
toggleComments: () => void;
toggleDarkMode: () => void;
togglePreview: () => void;
togglePreviewSize: () => void;
translateAllLanguages: () => void;
translateLanguage: (lang: string, sourceLang?: string) => void;
undo: () => void;
updateApiAuthorizationHeader: (
newAuthHeader: string | Record<string, string>
) => void;
updateCustomBlockContent(content: string): void;
updateOptions: (options: Partial<ITopolOptions>) => void;
updateTemplate: (json: JSON, options?: IUpdateTemplateOptions) => void;
}
interface IUpdateTemplateOptions {
skipSnapshot?: boolean;
}