Appearance
Reusable Content
Five options control what users can insert into a page and reuse across pages: savedSections gives each user a personal section library, syncedSectionsEnabled keeps shared sections identical across pages, premadeSections and premadeTemplates supply ready-made designs, and customBlocks registers block types of your own. A sixth option, contentBlocks, trims which built-in block types appear at all.
The interface calls saved and premade sections structures: "Premade structures", "Save as structure", and "Name of saved structure". The options were called savedBlocks and premadeBlocks before. The editor no longer reads those names, so an option left under one is ignored.
savedSections
The savedSections option (boolean, default false) enables the user's personal section library:
typescript
{
savedSections: true
}With it enabled, users save custom sections (hero headers, footers, content modules) into a personal library and reuse them across landing pages. The library is backed by your api.SAVED_SECTIONS endpoint; there is no local, in-memory variant, so the option only works together with the endpoint.
Saved structures can be organized into folders:
- The save dialog has a Save to folder picker. It shows the path to the chosen folder, lists its subfolders, and has a New folder button.
- Items in the panel can be moved with Move to folder.
Names are unique within a folder, across saved structures, synced structures, and folders:
- Saving or renaming to a name that's already taken shows "An item named "X" already exists in this folder."
- Moving an item into a folder that already holds its name adds a number, such as "X (1)".
The editor checks names against the list your endpoint returned, so your API doesn't need to enforce uniqueness.
syncedSectionsEnabled
The syncedSectionsEnabled option (boolean, default false) enables sections that stay consistent across multiple pages:
typescript
{
syncedSectionsEnabled: true
}A synced section is linked, not copied: updating it updates every page that uses it, which suits headers, footers, disclaimers, and promotional banners. Without the option, sections are edited independently per page. Synced sections are stored through the same api.SAVED_SECTIONS endpoint as saved sections.
Re-rendering on your backend
When you convert a saved page to HTML yourself through the JSON to HTML endpoint, pass the current content of every synced section the page uses in the syncedSections request field (onSave hands you their ids as syncedSections; send each one's definition and translation). The endpoint swaps each referenced section (syncedId) for the supplied definition before rendering, so pages pick up the latest version of a shared header or footer even if they were saved before it changed. Without the field, the page renders with the section content embedded in the saved template JSON.
premadeSections
The premadeSections option (array | object | false, optional) controls the library of ready-to-use design sections that users can insert with a single click.
When it is not set, the editor shows its built-in premade section library, grouped as Header, Content, E-commerce, and Footer. When the editor runs in Czech, it shows the Czech version of the library.
To supply your own blocks, pass an array of named groups. Each group holds blocks with a name, a preview image img, and the section definition JSON. A plain array replaces the built-in library:
typescript
premadeSections: [
{
name: "Heroes",
blocks: [
{
name: "Hero 1",
img: "https://example.com/previews/hero-1.png",
definition: { /* section JSON, e.g. exported from a saved template */ }
}
]
}
]To extend the built-in set instead of replacing it, use the wrapper form with override: false; your groups are added alongside the default library (override: true behaves like the plain array and replaces it):
typescript
premadeSections: {
override: false,
blocks: [ /* same array of groups as above */ ]
}To disable the premade sections library completely, pass false:
typescript
premadeSections: falsepremadeTemplates
The premadeTemplates option (boolean, default false) enables the full-page template library:
typescript
{
premadeTemplates: true
}With it enabled, users browse and start from complete premade templates (product pages, lead-generation pages, event signup pages) instead of a blank page or whatever template you load. The picker can also be opened from your own UI:
js
LPE.openPremadeTemplatesSelection();By default the library is served by Topol from app.topol.io. To serve your own library instead, point the PREMADE_TEMPLATES, PREMADE_TEMPLATE_CATEGORIES, and PREMADE_TEMPLATE_KEYWORDS endpoints at your backend; see Premade Templates API below.
A companion option, premadeTemplatesOptions (object, optional), tunes the picker's UI:
typescript
{
premadeTemplates: true,
premadeTemplatesOptions: {
hideSearch: true
}
}hideSearch(boolean): removes the search field from the template picker, which suits a small curated library where search adds nothing.
customBlocks
The customBlocks option (array, default []) registers your own block types, which users then add and configure like native blocks. This fits unique components such as dynamic CTAs, custom layouts, or platform-specific integrations.
Basic custom block:
typescript
customBlocks: [
{
key: "custom-text-key",
name: "My Customised Text",
icon: "box",
disabled: false,
type: "text",
attributes: {
align: "right",
padding: "10px 10px"
},
content: "Custom Text block"
}
]The fields every custom block accepts:
key(string, required): your identifier for the block. It is written into the template JSON, so keep it stable.name(string, required): the label shown in the Elements panel.type(string, optional):"text","image","button","video", or"mix"for a block that combines several elements.icon(string, optional):"box"or"rss"for the two built-in icons, anhttps://image URL, or an inline<svg>…</svg>string. Anything else falls back to the"box"icon.attributes(object, optional): the block's default attributes, withmdAttributes,smAttributes, andxsAttributesoverriding them at the tablet, mobile-landscape, and mobile breakpoints.content(string, optional): the block's initial content.disabled(boolean, optional) anddisabledBadge(string, optional): grey the block out in the Elements panel and label it, the same waycontentBlocksdoes for built-in blocks.
Mixed block with multiple elements:
typescript
customBlocks: [
{
key: "custom-mix",
name: "Custom mixed block",
icon: "box",
disabled: false,
type: "mix",
blocks: [
{
type: "text",
attributes: { align: "left" },
content: "My custom content"
},
{
type: "button",
attributes: {
align: "center",
"background-color": "#417505"
},
content: "Click me!"
}
]
}
]Custom HTML with dialog:
typescript
customBlocks: [
{
key: "custom-block-key",
name: "My Custom Block",
dialog: true,
icon: "box",
content: "<p>initial content</p>",
dialogButtonText: "Open Custom Dialog",
disabled: false
}
]A dialog-style custom block needs the onOpenCustomBlockDialog callback. Like all callbacks, it is passed as a top-level property next to config. When the user finishes editing in your dialog, send the new content back with updateCustomBlockContent:
typescript
const LPE = LandingPageEditor({
config: TOPOL_OPTIONS,
onOpenCustomBlockDialog({ block }) {
// Open your own dialog with the block's current content.
openMyDialog(block.content).then((editedContent) => {
LPE.updateCustomBlockContent(editedContent);
});
},
});block.content is the content of the placed block as it stands now, so reopening the dialog shows the user's latest edit. The new content always goes to the block whose dialog was opened, even if the user selects another block while your dialog is open. If the user cancels, don't call updateCustomBlockContent and the block stays as it was. Each update is a single step in the editor's undo history.
contentBlocks
The contentBlocks option (object, optional) controls which block types appear in the Elements panel, and whether they are disabled. It is an object keyed by block type; valid keys are text, image, gif, button, divider, spacer, social, video, and html. Custom blocks are controlled through their own disabled and disabledBadge fields in customBlocks. Each entry accepts:
hidden(boolean): removes the block from the Elements panel entirely.disabled(boolean): keeps the block visible but not usable.disabledText(string): tooltip text shown on a disabled block.disabledBadge(string): badge label shown on a disabled block (e.g."PRO").
typescript
{
contentBlocks: {
html: { hidden: true },
video: { disabled: true, disabledText: "Upgrade to use video", disabledBadge: "PRO" }
}
}When contentBlocks is not set, every block type listed above is available. The disabled variant is useful for upsell flows, where a block advertises a higher plan instead of vanishing.
API Integration for Saved Sections
Saved sections and synced sections are stored on your server, with support for folders, search, pagination, and preview images. Enable the features and point api.SAVED_SECTIONS at your backend:
typescript
const TOPOL_OPTIONS = {
savedSections: true,
syncedSectionsEnabled: true,
api: {
SAVED_SECTIONS: "https://your-domain.com/saved-blocks"
}
};Both features share the single api.SAVED_SECTIONS endpoint and are differentiated by the type field in requests and responses, which is one of saved_section, synced_section, or folder. In the URLs below, {API.SAVED_SECTIONS} stands for the base URL you configured.
WARNING
Before implementing the endpoints, check how to work with API endpoints.
All keys are camelCase; each one is listed with its type in the backend key reference.
List Saved Sections, Synced Sections and Folders
- URL:
/{API.SAVED_SECTIONS} - Method:
GET - Content-Type:
application/json
Params:
| key | value | required |
|---|---|---|
| key | authorization api key | true |
| hostname | hostname | true |
| entityId | entityId corresponds to authorize.entityId in Options | true |
| perPage | number of items per page; when omitted, return every item of the level (no default page size) | false |
| currentPage | number of page to return | false |
| sortBy | "name" or "date" or "type" | false |
| desc | "true" | false |
| folderId | id of folder to return | false |
| search | string to search | false |
| type | "saved_section", "synced_section" or "folder" to filter by type ("folder" returns only folders) | false |
This endpoint is called when the editor lists all saved sections/synced sections, changes sort, page or folder, searches by string, or whenever LPE.refreshSyncedSections() is called on the editor instance.
The folder pickers (create section, move to folder) call it without perPage and currentPage and expect the whole level back, and they rebuild the breadcrumb of a nested folder with type=folder (only folders are needed there). If your endpoint applies a default page size when perPage is absent anyway, answer with the real lastPage: the editor then falls back to walking the level page by page with perPage=100 (up to 100 pages; past that it shows the loaded part and tells the user the list is incomplete). Returning lastPage: 1 together with a truncated list leaves the pickers with only that first page.
Response:
json
{
"success": true,
"data": {
"data": [
{
"id": 1,
"name": "name of saved section, synced section, or folder",
"type": "saved_section",
"createdAt": "ISO 8601 time",
"definition": { "tagName": "mj-section", "children": ["..."] },
"image": "https://url-to-preview-image.jpg",
"folderId": 2
}
],
"lastPage": 5,
"parentFolderId": null
}
}In all saved-sections payloads, definition is the section JSON as an object (or an array of section objects), not a serialized string.
When the page is multilingual, saved and synced sections also carry a translation field: a map of language key to block uid to the translated fields, keyed by the uids of the stored definition. The page's Primary language is included as a full copy of the blocks' texts, so the map names every language the section exists in. The editor sends it on create and on every edit of a synced section, and reads it back from the listing and from the synced section detail, so persist it next to definition and return it unchanged. Languages the editing page does not have are preserved by the editor, so one page never wipes another page's translations. Pass the same field in syncedSections when you render the page through the JSON to HTML endpoint; a section instance that carries syncedLang in the page JSON renders that stored language when the page has no languages of its own. A syncedSections entry without translation replaces the section with its definition in every language: the stored definition has its own block uids, so the translations the page holds for that section no longer match and are dropped. Leave syncedSections out to render the copy embedded in the page, translations included.
json
{
"definition": { "tagName": "mj-section", "children": ["..."] },
"translation": {
"en": {
"aB3dE": { "content": "<p>Hello</p>" },
"xY9zQ": { "attributes": { "href": "https://example.com/en", "alt": "Logo" } }
}
}
}Create Saved Section, Synced Section or Folder
- URL:
/{API.SAVED_SECTIONS} - Method:
POST
This endpoint is called when a new saved section, synced section, or folder is created.
Request:
json
{
"entityId": "entity user_id",
"hostname": "origin",
"key": "api key",
"type": "saved_section",
"name": "name of new item",
"definition": { "tagName": "mj-section", "children": ["..."] },
"translation": { "en": { "aB3dE": { "content": "<p>Hello</p>" } } },
"folderId": 1
}Response:
json
{
"success": true,
"data": {
"id": 2,
"name": "name of saved section, synced section, or folder",
"type": "saved_section",
"createdAt": "ISO 8601 time",
"definition": { "tagName": "mj-section", "children": ["..."] },
"folderId": 1
}
}Get Synced Section Detail
- URL:
/{API.SAVED_SECTIONS}/{id} - Method:
GET - Params:
key,hostname,entityId
This endpoint is called only for synced sections: when a synced section is inserted into a template, and when a template containing synced sections is refreshed so the latest content is displayed. Regular saved sections are inserted from the listing data and never hit this endpoint.
Response:
json
{
"success": true,
"data": {
"id": 1,
"name": "name of the synced section",
"type": "synced_section",
"createdAt": "ISO 8601 time",
"definition": { "tagName": "mj-section", "children": ["..."] },
"translation": { "en": { "aB3dE": { "content": "<p>Hello</p>" } } },
"folderId": 2
}
}The response's type must be exactly "synced_section", and success must be true. If either is missing, the editor treats the section as missing and drops it from the page instead of reporting an error, so this is worth checking first when synced sections disappear on load.
Edit Saved Section, Synced Section or Folder
- URL:
/{API.SAVED_SECTIONS}/{id} - Method:
PATCH
This endpoint is called when editing the name, content, or folder location of a saved section, synced section, or folder. The editor sends only the fields that changed. To move an item back to the root level (out of all folders), the editor sends folderId: null — treat null as "no folder" and clear the item's folder assignment. This is consistent with GET responses, where root-level items have folderId: null.
Request:
json
{
"entityId": "entity user_id",
"hostname": "origin",
"key": "api key",
"folderId": 1,
"definition": { "tagName": "mj-section", "children": ["..."] },
"translation": { "en": { "aB3dE": { "content": "<p>Hello</p>" } } },
"name": "edited name"
}Response:
HTTP 200 OK
Delete Saved Sections, Synced Sections or Folders
- URL:
/{API.SAVED_SECTIONS}/delete - Method:
POST
This endpoint is called when the user deletes saved sections, synced sections, or folders. For synced sections, the last loaded version remains in templates where it was used.
Request:
json
{
"entityId": "entity user_id",
"hostname": "origin",
"key": "api key",
"ids": [1, 2, 3]
}Response:
HTTP 200 OK
Refresh Synced Sections
Call refreshSyncedSections on the editor instance to update the synced sections listing and reload the template with the latest changes:
js
const LPE = LandingPageEditor({ config: TOPOL_OPTIONS });
LPE.render("#landing-page-editor");
// later, e.g. when another user changed a synced section:
LPE.refreshSyncedSections();This matters when multiple users work in the editor simultaneously: when someone else creates, edits, or deletes a synced section, calling this function keeps the current view up to date.
Premade Templates API
The premade template library is served by three endpoints, which default to Topol's own collection on app.topol.io and can be repointed at your backend through the api option:
| Endpoint key | Serves |
|---|---|
PREMADE_TEMPLATES | The template listing, and one template's full detail at {PREMADE_TEMPLATES}/{id} |
PREMADE_TEMPLATE_CATEGORIES | The categories offered as filters |
PREMADE_TEMPLATE_KEYWORDS | The keywords offered as filters |
The listing is a GET with perPage and currentPage query parameters, plus search, categories, and keywords when the user filters. Both the listing and the detail must answer with a { "success": true, "data": ... } envelope; a missing or falsy success is reported to the user as a fetch failure.
The listing's data holds the page: data.data is the array of templates (each with id, name, type, imgThumbUrl, categoryId, description, keywords, createdAt, updatedAt) and data.lastPage tells the editor whether to offer Load more. The detail carries html and json (a JSON-encoded string), plus categoryId, imagePath, imgThumbPath, createdAt and updatedAt.
When the URL points at app.topol.io, the editor authenticates with your Public API key:
json
{
"accept": "application/json",
"Authorization": "Bearer <api-key>"
}WARNING
That header is added only for app.topol.io URLs; endpoints on your own domain get no Topol credentials, so secure them with apiAuthorizationHeader instead.
Note that apiAuthorizationHeader also reaches app.topol.io, and its string form sets Authorization, replacing the key the default library expects. If you use the string form and keep Topol's premade templates, host your own template endpoints or use the object form with a custom header name.
