Appearance
Options configurable in Topol Options
Topol options are used to set features which Topol provides. Pass them under the config property when creating the editor; callbacks are passed as top-level properties next to config (see the Callbacks Reference below).
Options are validated
The editor validates config against its options schema on initialization and on every updateOptions() call. A value of the wrong type (for example colors: "#000" instead of ["#000"]) makes the editor throw an Invalid options provided error that names the offending field, and the editor does not start: it reports the failure through onEditorError with source: "init", removes its iframe and never calls onInit (or the updateOptions() call is rejected). Unknown keys are not an error - they are silently ignored.
Options Reference
authorizeobjectrequiredRequired credentials ({ apiKey, entityId }) to initialize the editor securely. Learn more
aiLabeledElementsboolean default: falseAdds an AI content text field to every section and block, stored on the element as aiGenerateContent for your own AI pipeline. Learn more
apiIAPICustom API endpoints for backend integration. Learn more
apiAuthorizationHeaderstring | objectAuthorization header sent with requests to your custom API endpoints. Learn more
autosaveIntervalnumberInterval in seconds between autosave attempts. Learn more
colorsstring[]Custom color palette for the color picker. Learn more
contentBlocksobjectControls which block types are available (disable or hide individual blocks). Learn more
currentUserIOptionsUserInformation about the current user for comments and collaboration. Learn more
customBlocksarrayCustom block definitions with specific behavior or integrations. Learn more
customFileManagerboolean default: falseEnables custom file manager mode for your own upload workflow. Learn more
customFontsobjectCustom fonts available in the editor. Learn more
customLanguagePreset{ langs: { name, code, nativeName }[]; override?: boolean }Languages offered when adding a page language, replacing the built-in ISO 639 list (override: false appends to it). Learn more
defaultTemplateSettingsobjectTypography, colors, and element defaults applied to a newly created page. Learn more Its langs array ({ code, primary }[]) sets the languages a new page starts with and turns multilingual on. Learn more
disableAiAssistantboolean default: falseDisables the AI assistant feature. Learn more
disableAlertsboolean default: falseDisables editor alert notifications. Learn more
disableShortcutsboolean | EditorShortcut[] default: falseTurns the editor's keyboard shortcuts off: true disables all of them, an array only the listed ones. Values: save (Ctrl/Cmd+S), saveAndClose (Ctrl/Cmd+Shift+S), undo (Ctrl/Cmd+Z), redo (Ctrl/Cmd+Shift+Z), preview (Ctrl/Cmd+P), developerMode (Ctrl/Cmd+~), escape (deselect), addBelow (Ctrl/Cmd+Enter), delete (Ctrl/Cmd+Delete or Backspace), duplicate (Ctrl/Cmd+D), cut (Ctrl/Cmd+X) and copy (Ctrl/Cmd+C of a selected structure or block). A disabled shortcut is left to the browser. Useful when your host drives saving through editor.save() and must not receive exports it did not request.
enableAutosavesboolean default: falseEnables automatic saving at regular intervals. Learn more
enableCommentsboolean default: falseEnables the commenting system for collaboration. Learn more
enableFileManagerInGifboolean default: falseAllows picking GIF images through the file manager. Only has an effect together with customFileManager: true. Learn more
fileManagerPreferencesobjectUI preferences for the built-in file manager. Learn more
fontSizesnumber[]Available font sizes in the editor. Learn more
hideSelectionPanelboolean default: falseCollapses the right-side selection panel (properties of the selected element). Learn more
hideSelectionPanelExpandboolean default: falseHides the expand control on the selection panel. Learn more
hideSettingsTabboolean default: falseHides the settings tab in the editor. Learn more
hideTopbarControlsstring[]Hides specific controls from the top bar. Learn more
htmlMinifiedboolean default: falseOutputs minified HTML on export. Learn more
imageCompressionOptionsobjectConfigures automatic image compression settings (defaults in the callout below). Learn more
imageEditorOptionsobjectOptions for the built-in image editor, e.g. hiding specific controls. Learn more
imageMaxSizenumber default: 2097152 (2 MB)Maximum allowed image upload size in bytes. Learn more
languagestring default: "en"Editor UI language code (two-letter, from the supported list). Learn more
lightboolean default: falseEnables light theme mode. Learn more
multilingualboolean default: falseEnables page languages (mutations): a language dropdown in the Top Bar to create, switch and delete language versions of the page. Learn more
premadeSectionsobject | array | falseConfiguration for the premade design sections library. Pass false to disable it entirely. Learn more
premadeTemplatesboolean default: falseEnables the premade template library. Learn more
premadeTemplatesOptionsobjectUI options for the premade template library (hideSearch). Learn more
removeTopBarboolean default: falseRemoves the top bar completely. Learn more
saveAndCloseButton"dropdown" | "separate" default: "dropdown"Where Save & Close lives when both save buttons are visible: under the Save button's … menu, or as a standalone button next to Save. Learn more
renameTemplateboolean default: falseEnables template renaming functionality. Learn more
rolestringUser role determining permissions (manager, editor, reader). Learn more
savedSectionsboolean default: falseEnables the saved sections library. Learn more
showUnsavedDialogBeforeExitboolean default: trueEnabled by default. Set to false to suppress the browser confirmation dialog when leaving with unsaved changes. Learn more
startWithOpenElementsPanelboolean default: falseOpens the elements panel (the add element tab of the main menu) on the first load of the editor — reapplying options later does not reopen it. If the start screen with premade templates is shown, the panel opens once the user picks a template or starts from scratch. It stays closed on touch devices and narrow screens.
syncedSectionsEnabledboolean default: falseEnables synced sections across multiple pages. Learn more
teamUsersIOptionsUser[]Team members available for @mentions in comments. Learn more
templateIdstring | numberTemplate identifier used for comments and other API features. Learn more
textOverrideobjectCustom text overrides for UI labels, keyed by dot-separated locale paths. Applied on top of the active translation, whether that comes from language or the default English. A later updateOptions({ language }) loads the new language without them, so pass textOverride again in the same call. Learn more
themeobject default: dark presetCustom theme configuration for editor appearance. Learn more
titlestring default: "Landing page editor"Template title shown in the window bar. Only visible when windowBar or renameTemplate is set. Learn more
windowBarstring[]Controls displayed in the window bar. Learn more
Defaults worth knowing
imageCompressionOptionsdefaults:qualityJpeg: 0.95,qualityPng: 0.8,enableAutoResize: true,enableCompression: true.- When
themeis not set, the editor uses the dark preset;theme.preset: "light"also switches thelightoption on, so the two interact. - Supported
languagecodes:en,fr,pt,es,ja,zh,ru,tr,de,sv,sk,nl,it,fi,ro,cs,pl,ko,vi,he,ar. Regional variants such asen-USare not supported - an unsupported code fails options validation and the editor does not start.
Callbacks Reference
Callbacks are passed as top-level properties when creating the editor, next to config - not inside the options object:
js
const editor = LandingPageEditor({
config: { authorize: { apiKey: "YOUR_API_KEY", entityId: "user-123" } },
onSave({ json, html }) {
/* ... */
},
});One payload object per callback
Every callback receives at most one argument: an object with named properties (onSave({ json, html }), onUndoChange({ count }), onEditorError({ source, message, detail }), ...). Callbacks that carry no data (onInit, onLoaded, onPreviewClose, ...) are called with no arguments. New fields can be added to a payload later without breaking your handlers, so destructure what you need and ignore the rest.
onSave({ json, html, syncedSections, mutations? }) => void | Promise<void>Called when user saves the template. json is the template definition, html the rendered page as a string, syncedSections the ids of the synced sections placed in the page (an empty array when there are none), to look up in your storage and pass to the JSON to HTML endpoint when you re-render the page with their current content, and mutations the page languages as { code, primary }[] (only for a multilingual page). May return a Promise: the editor keeps its saving state until it settles, and a rejection is shown as a save error - so an async handler that persists to your backend reports failures to the user for free. A Promise that never settles is released after 30 seconds with a console warning. Learn more
onSaveAndClose({ json, html, syncedSections }) => void | Promise<void>Called when user saves and closes the editor. Same payload and Promise handling as onSave; a rejection keeps the editor open. Closing the editor UI is your job in this handler. When you do not define onSaveAndClose, the payload goes to onSave instead and the editor iframe is removed by the loader afterwards.
onOpenFileManager()Called when file manager should open. Learn more
onImageDelete({ items })Called when files or folders are deleted in the file manager, so you can clean up your own storage.
onLoaded()Called after a template passed to load() has been applied. It fires after every load() call and not when the editor starts, so it is the wrong place to load the first template: a load() inside onLoaded fires onLoaded again and loops. Load the first template from onInit instead.
onInit()Called once the editor is fully initialized and ready.
onUndoChange({ count })Called when undo history changes. count is the number of undo steps available.
onRedoChange({ count })Called when redo history changes. count is the number of redo steps available.
onPreview({ html })Called when user triggers preview mode. html is the rendered page as a string.
onPreviewClose()Called when the preview is closed.
onAlert({ notification })Receives each editor notification in place of the built-in toast; fires only while disableAlerts is true. Notifications pushed with createNotification() are rendered in the editor and never arrive here. notification carries type, text and the other notification fields. Learn more
onEditorClose() => void | Promise<void>Called when the user closes the editor from the window bar (the close button is enabled with windowBar). Closing the editor UI is your job in this handler; when you do not define it, the editor iframe is removed by the loader instead. May return a Promise. Named onEditorClose because the loader reserves onClose for its own lifecycle.
onUnsavedChangesChange({ hasUnsavedChanges })Called when the unsaved-changes state flips. hasUnsavedChanges is true while there are unsaved edits. A save clears the state only once the host callback has settled and only if the page still matches what was sent, so edits made during a save keep hasUnsavedChanges at true.
onOpenCustomBlockDialog({ block })Called when custom block dialog should open. block is the custom block data including its current content. Send the edited content back with updateCustomBlockContent. Learn more
onTemplateRename({ name })Called when user clicks the rename button. name is the current template name. Learn more
getNonce() => Promise<string>Turns on nonce authentication. The editor calls it when it loads and again before the current nonce expires, and expects a fresh nc_… nonce that your backend signed with the Secret key. If it doesn't settle within 15 seconds, the refresh counts as failed, and the editor keeps using the previous nonce while it is still valid. Learn more
onEditorError({ source, message, detail? })Called when an error occurs in the editor. source is "integration" (the NPM wrapper could not start the editor), "init" (the editor could not start: invalid options, failed authorization or an unresolvable host page; after an authorization failure it follows the "authorize" error), "authorize", "nonceAuth" (a background nonce refresh failed), "network", "load" (the template JSON could not be read) or "save", message a human-readable description and detail the raw error data when available (for network errors, the response body; for save, { stage: "render" | "host" }). A save error fires whenever a save does not complete: the render failed (no onSave fires) or your onSave / onSaveAndClose Promise rejected (the callback fired first, then this error). Named onEditorError because the loader reserves onError for its own lifecycle.
When many users hit errors at the same time, check status.topol.io for an incident on Topol's side.
onLanguageCreated({ code, mutations })A page language was added. mutations is the full list as { code, primary }[]. Learn more
onLanguageDeleted({ code, mutations })A page language was removed.
onPrimaryLanguageChanged({ code, mutations })Another language became the primary one.
onLanguageSelected({ code })The language shown in the editor changed; code is null for a page without languages.
onGetMutations({ mutations })Answer to the getMutations() method.
TypeScript Interface
Options passed under config:
ts
interface IPluginOptions {
authorize: {
apiKey: string;
entityId: string | number;
};
aiLabeledElements?: boolean;
api?: IAPI;
apiAuthorizationHeader?: Record<string, string> | string;
autosaveInterval?: number;
colors?: Array<string>;
contentBlocks?: Partial<
Record<
| "text"
| "image"
| "gif"
| "button"
| "divider"
| "spacer"
| "social"
| "video"
| "form"
| "html",
{
disabled?: boolean;
disabledText?: string;
hidden?: boolean;
disabledBadge?: string;
}
>
>;
currentUser?: IOptionsUser;
customBlocks?: TopolCustomBlockData[];
customFileManager?: boolean;
customLanguagePreset?: {
langs: { name: string; code: string; nativeName: string }[];
override?: boolean;
};
customFonts?: {
override?: boolean;
fonts: Array<IFont>;
};
defaultTemplateSettings?: TopolTemplateSettings;
disableAiAssistant?: boolean;
disableAlerts?: boolean;
disableShortcuts?: boolean | EditorShortcut[];
enableAutosaves?: boolean;
enableComments?: boolean;
enableFileManagerInGif?: boolean;
fileManagerPreferences?: {
defaultTilesView?: boolean;
hidePexelsIntegration?: boolean;
maxUploadingFiles?: number; // positive integer
};
fontSizes?: Array<number>;
hideSelectionPanel?: boolean;
hideSelectionPanelExpand?: boolean;
hideSettingsTab?: boolean;
hideTopbarControls?: Array<string>;
htmlMinified?: boolean;
imageCompressionOptions?: {
qualityJpeg?: number;
qualityPng?: number;
enableAutoResize?: boolean;
enableCompression?: boolean;
};
imageEditorOptions?: {
hideControls?: Array<string>;
};
imageMaxSize?: number;
language?: ILanguage;
light?: boolean;
multilingual?: boolean;
premadeSections?: IOptionsPremadeSection;
premadeTemplates?: boolean;
premadeTemplatesOptions?: {
hideSearch?: boolean;
};
removeTopBar?: boolean;
saveAndCloseButton?: "dropdown" | "separate";
renameTemplate?: boolean;
role?: "manager" | "editor" | "reader";
savedSections?: boolean;
showUnsavedDialogBeforeExit?: boolean;
startWithOpenElementsPanel?: boolean;
syncedSectionsEnabled?: boolean;
teamUsers?: IOptionsUser[];
templateId?: number | string;
textOverride?: Record<string, string>;
theme?: ITheme;
title?: string;
windowBar?: Array<string>;
}
type ILanguage =
| "en" | "fr" | "pt" | "es" | "ja" | "zh" | "ru" | "tr" | "de" | "sv"
| "sk" | "nl" | "it" | "fi" | "ro" | "cs" | "pl" | "ko" | "vi" | "he" | "ar";
interface IOptionsUser {
userId: string; // must be a string here, unlike authorize.entityId
name: string;
profilePhotoUrl: string;
}
interface IFont {
label: string;
style: string;
url?: string;
}
// premadeSections accepts one of four shapes:
type IOptionsPremadeSection =
| { blocks: PremadeSections | LegacyPremadeSections; override: boolean }
| Array<{ id?: number; name: string; blocks: PremadeSection[] }>
| { content?: unknown; ecomm?: unknown; footers?: unknown; headers?: unknown }
| false; // disables premade sections entirelyCallbacks are passed as top-level properties alongside config:
ts
interface ISavePayload {
json: object; // template definition
html: string; // rendered page
syncedSections?: number[]; // ids of the synced sections in the template
}
interface IDeletedItem {
name: string;
type: "file" | "folder";
path: string;
url?: string;
key: string | null;
}
type EditorShortcut =
| "save"
| "saveAndClose"
| "undo"
| "redo"
| "preview"
| "developerMode"
| "escape"
| "addBelow"
| "delete"
| "duplicate"
| "cut"
| "copy";
interface ILandingPageEditorProps {
config: IPluginOptions;
onSave?(payload: ISavePayload): void | Promise<void>;
onSaveAndClose?(payload: ISavePayload): void | Promise<void>;
onOpenFileManager?(): void;
onImageDelete?(payload: { items: IDeletedItem[] }): void;
onLoaded?(): void;
onInit?(): void;
onUndoChange?(payload: { count: number }): void;
onRedoChange?(payload: { count: number }): void;
onPreview?(payload: { html: string }): void;
onPreviewClose?(): void;
onAlert?(payload: { notification: INotification }): void;
onEditorClose?(): void | Promise<void>;
onUnsavedChangesChange?(payload: { hasUnsavedChanges: boolean }): void;
onOpenCustomBlockDialog?(payload: { block: unknown }): void;
onTemplateRename?(payload: { name: string }): void;
/** Turns on nonce authentication; resolve to a fresh `nc_…` nonce. */
getNonce?(): Promise<string>;
onEditorError?(payload: {
source:
| "integration"
| "init"
| "authorize"
| "nonceAuth"
| "network"
| "load"
| "save";
message: string;
detail?: unknown;
}): void;
}Common pitfall
Do not wrap callbacks in a callbacks: { ... } object inside config - the editor ignores that key entirely and no callback will ever fire. Always pass callbacks as top-level properties next to config.
INFO
defaultTemplateSettings nested fields are all optional and merge over the built-in defaults; invalid values are silently dropped rather than raising an error. Learn more
