Editor Configuration

📘

Examples available

https://github.com/claspo/claspo-plugin-examples


Editor bootstrap and destroy

  1. Load the main editor script located at EDITOR_SCRIPTS_URL/activator.js
  2. After the activator script was loaded, call window['ClaspoEditor'].init(config, successCallback, errorCallback) to bootstrap editor
  3. When the user closes the editor, call window['ClaspoEditor'].destroy()
const script = document.createElement('script');
script.src = 'EDITOR_SCRIPTS_URL/activator.js';
script.onload = () => {
  window['ClaspoEditor'].init(
    config,
    () => console.log("editor loaded"),
    () => console.log("editor wasn't loaded"),
  );
};
document.body.appendChild(script);

Editor instance methods

NameDescription
initDescribed below
destroyCleans resources
cancelIt acts as a click on the Cancel button in the editor
saveIt acts as a click on the Save button in the editor

init config

Property nameTypeRequiredDescriptionDefault
containerElementHTMLElement | stringYesHTML element or CSS selector where the editor is embedded. Editors takes full width and full height of the element. It’s important to set a size of the element before editor initialization. Editor calculates actual element size and based on that it will calculate the size of it’s blocks.
editorScriptsUrlstringYesEDITOR_SCRIPTS_URL. A trailing slash is required.
staticResourcesUrlstringYesSTATIC_RESOURCES_URL. A trailing slash is required.
getWidgetDataCallbackSee Appearance Management pageYesLoads initial data for editor
saveWidgetDataCallbackSee Appearance Management pageYesThe function is called when the user clicks the "Save" button.
api See Images API pageYesThe editor can request data at runtime. To do so, it calls the corresponding API method.
themeSee Theme pageNoClaspo theme
initialLoadErrorCallback(httpResponseStatus: boolean) => voidNoThis function will be called if any initial request, such as user info or appearance, fails. If the parameter is absent, the UI will show the default initial load error.
countryCodestringNoWhen the user adds a SysPhoneInputComponent to the widget, control.countryCode is set to config.countryCodeUA
previewEnv"DESKTOP" | "MOBILE"NoSets default env for viewport"DESKTOP"
logo{ imageUrl: string; link?: string;}NoAdds logo in the top left corner
localePatch {
[key: string]: {
[key: string]: string
}
}
NoOverrides translations of keys for the specified languages. Example:

{
'WIDGET_TYPE_FLOATING_BOX': {
'en': 'Floating Box',
'ru': 'Плавающее окно',
'uk': 'Плаваюче вікно'
}
}
selectedAppearanceIdnumber (id)NoAfter the editor initialization, the corresponding appearance can be shown instead of the origin one.
hideSaveOptionsMenubooleanNoShows only the "Save" button instead of a menu with several options.false
closeEditorCallback(variant: WidgetVariantI) => voidNoIt's called when the user clicks the "Close" button.console.log will be called
afterSavedCallback(variant: WidgetVariantI) => voidNo It’s called after saveWidgetDataCallback finished successfullyconsole.log will be called
notificationHandlers{
success: (message: string) => void;
info: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
hide: () => void;
}
Noconsole.log will be called
navigateToWidgetCallback(widget: WidgetsListItemI) => voidNoIt's called when the user clicks the "Open widget" button in "Action on click" > "Launch the widget".console.log will be called
trackUserActivityCallback(key: string, params: string) => voidNoAllows user activity tracking
showChatMessageCallback(message: string) => voidNoCurrently, it is used in the components panel to notify the integrator app that a message needs to be shown in support chat like Intercom.
actionOptions{
availableClickActions?: ClDocumentActionType[];
isDisplayingOpenLinkNewTabSwitch?: boolean;
}
No“isDisplayingOpenLinkNewTabSwitch” shows “Open in a new tab” option in “Open link” action {
isDisplayingOpenLinkNewTabSwitch: true,
}
analyticsNotificationsEnabledbooleanNoShows

- “Clicks on text links are not accounted for in Click and Conversion rates" message in text link dialog
true