@claspo/editor
Claspo Editor SDK and types for widget integration
@claspo/editor
@claspo/editor
LayoutType
Enumeration Members
WidgetType
Enumeration Members
AsyncPatternType
Async pattern type for API calls.
Enumeration Members
ContactMappingOptionType
Enumeration Members
ClPreviewEnvironment
Enumeration Members
WidgetProjectConfigId
Enumeration Members
WidgetPublishStatus
Enumeration Members
TypeOfFilesFromCommonDir
Enumeration Members
PrizePoolModelI
Properties
| Property | Type |
|---|---|
id | string |
sourceType | PrizeSourceType |
distributionType? | PrizeDistributionType |
options? | PrizePoolOptionI[] |
PrizePoolOptionI
Properties
EditorI
Global ClaspoEditor interface exposed on window object.
Use window.ClaspoEditor to access the editor API.
Example
// Initialize editor
window.ClaspoEditor.init(config, () => {
console.log('Editor loaded');
}, () => {
console.error('Editor failed to load');
});
// Save changes
window.ClaspoEditor.save({ publishChanges: true });
// Destroy editor
window.ClaspoEditor.destroy();
Properties
EditorConfigI
Main configuration object for initializing the Claspo Editor.
See
https://github.com/Claspo/claspo-plugin-starter-poc/blob/main/quickstart/public/editor.html
Properties
| Property | Type | Description |
|---|---|---|
containerElement | HTMLElement | HTML 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. Remarks Required |
countryCode | string | Default country code for phone input components. See Code at https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements Default: "US" |
theme | EditorThemeI | Theme configuration for the editor UI. |
notificationHandlers | EditorConfigNotificationHandlersI | Custom notification handlers for editor messages Default console.log will be used |
closeEditorCallback | (payload) => void | Callback fired when Close button is clicked. Use this to handle editor closure and cleanup. |
staticResourcesUrl | string | Base URL for static resources (images, fonts, etc.). Must include trailing slash. Example "https://cdn.claspo.io/static/" |
hostUrl | string | Base URL for the host application. Example "https://app.claspo.io/" |
availableComponentsPanel | AvailableComponentsPanelConfigI | Configuration for the left panel component selector |
getRevisionPayloadCallback | (payload) => CreateWidgetRevisionRequestI | Callback to transform revision payload before saving |
api | EditorApiConfigI | HTTP API configuration for all editor operations |
userInfo | UserInfoI | Current user identity and language preferences |
projectConfigs? | WidgetProjectConfigI[] | Project-level configurations |
languagesForMultilingualVersions? | WidgetLanguageI[] | Available languages for multilingual versions of the same widget Default A set of popular languages will be used |
initialLoadErrorCallback? | (payload) => void | Callback fired on initial data loading errors. If not provided, default error UI will be shown. |
logo? | EditorLogoI | Logo configuration displayed in top-left corner. Example { imageUrl: 'https://example.com/logo.png', link: 'https://example.com' } |
useContactFields? | boolean | Enable contact fields mapping functionality. |
localePatch? | any | Override translations by language. Example 'WIDGET_TYPE_FLOATING_BOX': { 'en': 'Floating Box', 'ru': 'Плавающее окно', 'uk': 'Плаваюче вікно', } |
defaultLanguage? | string | The defaultLanguage property serves as a fallback for localePatch when a translation for the user's language is missing. It does not control the editor UI language. See - https://docs.claspo.io/docs/localization - https://www.w3schools.com/tags/ref_language_codes.asp |
showPropertyPaneSettingsInTabs? | boolean | Show property pane settings in tabs layout or on single columns (tabs are hidden) |
defaultAsyncPattern? | AsyncPatternType | Default async pattern for API calls. "PROMISE" by default |
authToken? | string | Authentication token for editor API access |
teaserFeatureConfig? | TeaserFeatureConfigI | Teaser feature configuration |
googleFontsApiKey? | string | Google Fonts API key for font loading |
previewOpenedCallback? | () => void | Callback fired when preview opens via header button |
previewClosedCallback? | () => void | Callback fired when preview closes from header button |
disableImageEditor? | boolean | Disable built-in image editor |
disableLanguageSelect? | boolean | Disable language selection dropdown at the navbar |
disableAbilityToRemoveUploadedFiles? | boolean | Prevent users from removing uploaded files |
AvailableComponentsPanelConfigI
Configuration for the left panel component selector.
Defines which components are available for users to add to widgets.
Properties
| Property | Type | Description |
|---|---|---|
groups | AvailableComponentsGroupI[] | Groups of available components |
showRequestComponentButton? | boolean | Show "Request component" button at the bottom |
AvailableComponentsGroupI
Group of components in the available components panel.
Properties
| Property | Type | Description |
|---|---|---|
label | string | Display label for the group |
components | AvailableComponentI[] | Components in this group |
AvailableComponentI
Configuration for a single available component.
Properties
EditorLinksConfigI
Configuration for external links shown in the editor.
Properties
EditorConfigNotificationHandlersI
Custom notification handlers for editor messages.
Implement these methods to integrate with your notification system.
Example
const notificationHandlers: EditorConfigNotificationHandlersI = {
success: (msg) => toast.success(msg),
error: (msg) => toast.error(msg),
warning: (msg) => toast.warning(msg),
info: (msg) => toast.info(msg),
hide: () => toast.dismiss()
};
Properties
ActionOptionsI
Configuration for click action behavior in the editor.
Properties
ColumnsOptionsI
Configuration for columns component behavior.
Properties
TeaserFeatureConfigI
Configuration for teaser (minimized widget) feature.
Properties
| Property | Type | Description |
|---|---|---|
enabled | boolean | Enable teaser functionality |
defaultDocumentModel | ClDocumentI | Default document model for new teasers |
enabledForLayouts? | LayoutType[] | Layouts where teaser is available |
availableComponentsPanel? | AvailableComponentsPanelConfigI | Component panel configuration for teaser editor |
CloseEditorCallbackPayloadI
Payload passed to EditorConfigI.closeEditorCallback.
Properties
| Property | Type | Description |
|---|---|---|
variant | WidgetVariantI | Current widget variant data |
GetRevisionPayloadCallbackPayloadI
Payload passed to EditorConfigI.getRevisionPayloadCallback.
Properties
| Property | Type | Description |
|---|---|---|
variant | WidgetVariantI | Current widget variant |
appearances | WidgetAppearanceI[] | All widget appearances (desktop, mobile, etc.) |
publishStatus | WidgetPublishStatus | Current publish status |
InitialLoadErrorCallbackPayloadI
Payload passed to EditorConfigI.initialLoadErrorCallback.
Properties
EditorThemeI
Simplified theme configuration for the Claspo Editor.
This interface provides a streamlined API for external developers
with only the essential customization options.
Example
const theme: EditorThemeI = {
primaryColor: '#F3492C',
primaryFontFace: 'Montserrat, sans-serif',
secondaryColor: '#ffffff',
successColor: '#27C173',
errorColor: '#E72324'
};
Properties
ResolvedDataI
Data returned by EditorApiConfigI.getWidgetData.
Contains all information needed to initialize the editor.
Properties
| Property | Type | Description |
|---|---|---|
widgetData | ResolvedWidgetDataI | Main widget data |
teaserData | ResolvedWidgetDataI | Teaser (minimized widget) data, if enabled |
linkedWidgets | WidgetsListItemI[] | List of widgets that can be linked |
prizePools? | PrizePoolModelI[] | Prize pools for gamification widgets |
ResolvedWidgetDataI
Widget-specific data within ResolvedDataI.
Properties
| Property | Type | Description |
|---|---|---|
variant | WidgetVariantDtoI | Widget variant (form) data |
appearances | WidgetAppearanceI[] | All appearances (desktop, mobile, etc.) |
latestRevision | WidgetRevisionI | Latest saved revision |
currentRevision | WidgetRevisionI | Currently loaded revision |
publishStatus | WidgetPublishStatus | Current publish status |
DataToSaveI
Data passed to EditorApiConfigI.saveWidgetData.
Contains both original and modified data for comparison.
Properties
| Property | Type | Description |
|---|---|---|
widgetData | WidgetDataToSaveI | Main widget data to save |
teaserData | WidgetDataToSaveI | Teaser data to save, if enabled |
pristineConfigs | WidgetProjectConfigI[] | Original project configs (for comparison) |
updatedConfigs | WidgetProjectConfigI[] | Modified project configs |
publishChanges | boolean | Whether to publish changes immediately |
WidgetDataToSaveI
Widget-specific data within DataToSaveI.
Properties
| Property | Type | Description |
|---|---|---|
pristineAppearances | WidgetAppearanceI[] | Original appearances (for comparison) |
updatedAppearances | WidgetAppearanceI[] | Modified appearances |
pristineVariant | WidgetVariantI | Original variant (for comparison) |
updatedVariant | WidgetVariantI | Modified variant |
publishStatus | WidgetPublishStatus | Current publish status |
EditorApiConfigI
HTTP API configuration for all editor operations.
All methods can return either Promise or Observable based on EditorConfigI.defaultAsyncPattern.
Example
const api: EditorApiConfigI = {
getWidgetData: () => fetch('/api/widget').then(r => r.json()),
saveWidgetData: (data) => fetch('/api/widget', {
method: 'POST',
body: JSON.stringify(data)
}),
// ... other methods
};
Methods
createWidgetPrizePool()
createWidgetPrizePool(body):
| Observable<{
id: string;
}>
| Promise<{
id: string;
}>;
Create a new prize pool for gamification
Parameters
| Parameter | Type |
|---|---|
body | PrizePoolModelI |
Returns
| Observable<{
id: string;
}>
| Promise<{
id: string;
}>
updateWidgetPrizeOptions()
updateWidgetPrizeOptions(payload): Promise<void> | Observable<void>;
Update prize options in a prize pool
Parameters
| Parameter | Type |
|---|---|
payload | UpdateWidgetPrizeOptionsPayloadI |
Returns
Promise<void> | Observable<void>
Properties
| Property | Type | Description |
|---|---|---|
getWidgetData | () => | Observable<ResolvedDataI> | Promise<ResolvedDataI> | Fetch initial widget data for editor initialization |
saveWidgetData | (data) => Promise<void> | Observable<void> | Save widget data (appearances, variant, configs) |
getWidgetAppearances | (payload) => | Observable<WidgetAppearanceI[]> | Promise<WidgetAppearanceI[]> | Fetch appearances for a specific widget |
createWidgetRevision | (payload) => | Observable<CreateWidgetRevisionResponseI> | Promise<CreateWidgetRevisionResponseI> | Create a new widget revision (save point) |
getWidgetsList | (params) => | Observable<BaseListDtoI<WidgetsListItemI>> | Promise<BaseListDtoI<WidgetsListItemI>> | Fetch list of widgets for linking |
getFilesFromCommonDir | (payload) => | Observable<{ url: string; }[]> | Promise<{ url: string; }[]> | Get files from common directory (icons, backgrounds, etc.) |
removeFile | (payload) => Promise<void> | Observable<void> | Remove an uploaded file |
getImageLibrary | (params) => | Observable<ImageLibraryResponseDtoI> | Promise<ImageLibraryResponseDtoI> | Fetch images from the image library |
getUserImages | (params) => | Observable<UserImagesResponseDtoI> | Promise<UserImagesResponseDtoI> | Fetch user-uploaded images |
uploadImage | (payload) => | Observable<{ url: string; }> | Promise<{ url: string; }> | Upload an image file |
uploadImageByUrl | (payload) => | Observable<{ url: string; }> | Promise<{ url: string; }> | Upload an image from URL |
copyImageByUrl | (payload) => | Observable<{ url: string; }> | Promise<{ url: string; }> | Copy an image by URL to widget storage |
translate | (params) => | Observable<{ response: TranslateRequestJsonI; }> | Promise<{ response: TranslateRequestJsonI; }> | Translate text content |
getContactMappingOptions | () => | Observable<ClContactMappingOptionI[]> | Promise<ClContactMappingOptionI[]> | Fetch available contact mapping options |
getContactFieldGroups? | () => | Observable<EsAdditionalFieldsListI[]> | Promise<EsAdditionalFieldsListI[]> | Fetch contact field groups |
createWidget? | (payload) => | Observable<CreateWidgetResponseI> | Promise<CreateWidgetResponseI> | Create a new widget |
GetWidgetAppearancesPayloadI
Payload for EditorApiConfigI.getWidgetAppearances.
Properties
CreateWidgetRevisionPayloadI
Payload for EditorApiConfigI.createWidgetRevision.
Extends
Properties
| Property | Type | Description | Inherited from |
|---|---|---|---|
widgetId | number | Widget ID | - |
revisionId | string | Revision ID | - |
changesSaved | boolean | - | CreateWidgetRevisionRequestI.changesSaved |
payload | WidgetRevisionPayloadI | - | CreateWidgetRevisionRequestI.payload |
GetFilesFromCommonDirPayloadI
Payload for EditorApiConfigI.getFilesFromCommonDir.
Properties
| Property | Type | Description |
|---|---|---|
type? | TypeOfFilesFromCommonDir | Type of files to retrieve (icons, backgrounds, etc.) |
RemoveFilePayloadI
Payload for EditorApiConfigI.removeFile.
Properties
UploadImagePayloadI
Payload for EditorApiConfigI.uploadImage.
Properties
UploadImageByUrlPayloadI
Payload for EditorApiConfigI.uploadImageByUrl.
Properties
CopyImageByUrlPayloadI
Payload for EditorApiConfigI.copyImageByUrl.
Properties
| Property | Type | Description |
|---|---|---|
imageUrl | string | URL of the image to copy |
widgetId | number | Widget ID to associate the copied image with |
type? | TypeOfFilesFromCommonDir | Type category for the copied image |
UpdateWidgetPrizeOptionsPayloadI
Payload for EditorApiConfigI.updateWidgetPrizeOptions.
Properties
| Property | Type | Description |
|---|---|---|
poolId | string | Prize pool ID |
options | PrizePoolOptionI[] | Updated prize options |
SetAutoTranslatePayloadI
Payload for EditorApiConfigI.setAutoTranslate.
Properties
GetTemplatePayloadI
Payload for EditorApiConfigI.getTemplate.
Properties
CreateWidgetResponseI
Response from EditorApiConfigI.createWidget.
Properties
| Property | Type | Description |
|---|---|---|
variant | WidgetVariantI | Created widget variant |
appearances | WidgetAppearanceI[] | Created widget appearances |
EditorLogoI
Logo configuration for the editor header.
Example
const logo: EditorLogoI = {
imageUrl: 'https://example.com/logo.png',
link: 'https://example.com'
};
Properties
ClContactMappingOptionI
Contact mapping option for form field mapping.
Used to map form inputs to contact fields in CDP.
Properties
| Property | Type | Description |
|---|---|---|
name | string | Unique identifier for the mapping option |
label | string | Display label for the option |
group | string | Group name for categorization |
isDedupe | boolean | Whether this field is used for deduplication |
isCustom | boolean | Whether this is a custom field |
type? | ContactMappingOptionType | Type of contact mapping |
values? | string[] | Predefined values for select-type fields |
options? | ContactMappingOptionLimitsI | Additional options and limits |
isNew? | boolean | Flag indicating this is a newly created field |
additionalFieldType? | EsAdditionalFieldType | Type of additional field (for custom fields) |
BaseListDtoI
Type Parameters
| Type Parameter |
|---|
T |
Properties
UserInfoI
Properties
ContactMappingOptionLimitsI
Properties
ClDocumentI
Extends
ClDocumentI
Properties
WidgetProjectConfigI
Properties
| Property | Type |
|---|---|
id | WidgetProjectConfigId |
value | string |
WidgetsListItemI
Properties
| Property | Type |
|---|---|
id | number |
name | string |
publishStatus | WidgetPublishStatus |
createdDate | string |
updatedDate | string |
variantIds | number[] |
config | WidgetVariantDtoI |
WidgetModelI
Properties
| Property | Type |
|---|---|
id | number |
name | string |
publishStatus | WidgetPublishStatus |
createdDate | string |
updatedDate | string |
variants | WidgetVariantDtoI[] |
config | WidgetVariantDtoI |
WidgetVariantDtoI
Properties
| Property | Type |
|---|---|
formId | number |
id | number |
config | WidgetVariantConfigDtoI |
appearances | WidgetAppearanceBriefI[] |
linkedToVariantId | number |
type | WidgetType |
revision? | string |
publishedRevision? | string |
WidgetAppearanceI
Properties
WidgetLanguageI
Properties
WidgetVariantI
Properties
| Property | Type |
|---|---|
formId | number |
id | number |
config | WidgetVariantConfigI |
appearances | WidgetAppearanceBriefI[] |
linkedToVariantId | number |
type | WidgetType |
revision | string |
publishedRevision | string |
EsAdditionalFieldsListI
Properties
BaseFormsListRequestParamsI
Properties
| Property | Type |
|---|---|
layoutTypes? | LayoutType[] |
order? | BaseListOrderOption |
search? | string |
offset? | number |
limit? | number |
sort? | BaseListSortOption |
types? | WidgetType[] |
projectId? | number |
filters? | FormListRequestFilter |
publishStatus? | WidgetPublishStatus |
publishDateFrom? | string |
publishDateTo? | string |
withDeleted? | boolean |
analyticsDateFrom? | string |
analyticsDateTo? | string |
CreateFormParamsI
Properties
| Property | Type |
|---|---|
name | string |
variant | CreateFormParamsVariantI |
publishStatus? | WidgetPublishStatus |
TranslateRequestI
Properties
| Property | Type |
|---|---|
json | TranslateRequestJsonI |
sourceLanguage | string |
targetLanguage | string |
TranslateRequestJsonI
Properties
CreateWidgetRevisionRequestI
Extended by
Properties
CreateWidgetRevisionResponseI
Properties
WidgetRevisionI
Properties
ImageLibraryRequestParamsI
Properties
ImageLibraryResponseDtoI
Properties
UserImagesRequestParamsI
Properties
UserImagesResponseDtoI
Properties
Updated 3 days ago
