Custom plugins API
There are several options for creating your own custom plugin. On this page, explore relevant APIs .
Builder.register() method signature
The Builder.register() method accepts two arguments:
- A string, representing the types of custom plugin.
- A configuration value, which can be of any type.
The config data type is dependent on the key. Some custom plugins require a callback function, while others require an object or a different data type.
The method does not have a return value.
Custom plugin type options
Listed below are several different options for custom plugin types. Each of these types can be passed as a string to the first argument of Builder.register().
insertMenu
Adds a new section of Components of your choice that are registered and grouped into the newly described menu. Selected components can be custom or built in.
The code above results in a new section within the Visual Editor, as shown below.
For more details, visit Register custom components.
app.onLoad
The app.onLoad plugin type runs code when the Builder application is opened by a user.
For this plugin type, a callback function is passed as the second argument. This callback function provides an AppActions object:
The triggerSettingsDialog() function is typically called on first load to prompt the user to configure the plugin if it hasn't been connected yet.
The code below provides an example of prompting users to configure the plugin on load.
editor.onLoad
The editor.onLoad type runs code when the Visual Editor is opened.
For this plugin type, a callback function is passed as the second argument. This callback function provides a ContentEditorActions object:
This object contains two keys:
updatePreviewUrl(url): programmatically sets the preview URL shown in the editor iframe.safeReaction(watchFn, reactionFn, options?): a MobX-style reactive subscription.watchFn()is tracked for observable changes; whenever its return value changes,reactionFn()is called with the new value. The optional{ fireImmediately: true }runsreactionFn()once immediately on registration.
The code below demonstrates forcing previewUrl changes when the locale is updated.
editor.settings
The editor.settings option accepts a configuration object to control the visibility and behavior of Builder's visual editor UI.
All properties are optional booleans.
editor.header
The editor.header type a custom React component to replace or augment the header bar rendered at the top of the content editor. It accepts a single property.
This option can be used to include an important banner or notification for users.
editor.toolbarButton
The editor.toolarButton type registers a custom React component to be rendered inside the content editor's top toolbar.
This is well-suited for controls that need to interact with the editor's live state, such as dropdowns, toggles, or icon buttons that modify the preview.
For more details, visit Build a custom plugin.
editor.editTab
Registers a custom React component as an additional tab in the left panel of the content editor. It accepts two properties:
- name: a string
- component: a React component
For example, the code below adds a new tab to the Visual Editor, with the name My Tab.
This type of plugin is good for complex components that interact with the Visual Editor and other integrations.
editor.mainTab
Registers a custom React component as an additional tab in the content editor's center panel. It accepts two properties:
- name: a string
- component: a React component
For example, the code below adds a new tab to the Visual Editor, with the name My Tab.
This type of plugin is good for complex components that interact with the Visual Editor and other integrations.
The video below shows an example of where this tab appears.
editor.previewToolbar
Registers a custom React component to replace the toolbar rendered directly above the preview iframe in the content editor. It accepts a single property:
- component: a React component
This can be used to simply remove the preview toolbar, however a new toolbar can be added in its place.
In the example below, a new toolbar is used, leveraging mobx-react. This replaces some of the existing functionality of the preview toolbar.
The video below shows an example of the new toolbar.
content.action
Registers a custom action that appears in the content list's per-item action menu. The action menu is the three-dot menu next to each content entry.
The content.action type has the following method signature:
Each key-value pair is required and can be described as follows:
| Property | Type | Description |
|
| The display text for the action in the menu. |
|
| Controls visibility. Receives the current content entry and its model; return true to show the action. |
|
| Called when the user selects the action. Receives the full content entry object. |
The example below demonstrates how you could make a request to your own internal server with content entry details.
The video below shows an example of this action in use.
content.action
Registers a custom action that appears in the content list's per-item action menu. The action menu is the three-dot menu next to each content entry.
The content.action type has the following method signature:
Each key-value pair is required and can be described as follows:
| Property | Type | Description |
|
| The display text for the action in the menu. |
|
| Controls visibility. Receives the current content entry and its model; return true to show the action. |
|
| Called when the user selects the action. Receives the full content entry object. |
The example below demonstrates how you could make a request to your own internal server with content entry details.
The video below shows an example of this action in use.
content.bulkAction
Registers a custom action that appears when one or more content entries are selected in the content list, enabling operations across multiple items at once.
The content.bulkAction type has the following method signature:
Each key-value pair is required and can be described as follows:
label
The label is a string. It is the display text for the action in the bulk actions menu.
showIf
The return value of this method controls the visibility of the action based on the current selection and model.
The method has access to the following parameters:
selectedContentIds: array of IDs of the currently selected content entries.content: array of all content entry objects currently loaded in the list.model: the model for the current content list view.
onClick
When the bulk action is clicked, this function is called.
The method has access to the following parameters:
actions: this object contains a single key,refreshList, which is a function that can be called upon completing the operation to reload the content list and reflect any changes.selectedContentIds: array of IDs of the currently selected content entries.content: array of all content entry objects currently loaded in the list.model: the model for the current content list view.
Example
The example below demonstrates how you might trigger a bulk call to your own internal server.
The video below shows an example of this action in use.
model.action
Registers a custom action that appears in the model settings menu, operating on a Builder model rather than content entries or canvas elements.
The model.action type has the following method signature:
Each key-value pair is required and can be described as follows:
| Property | Type | Required | Description |
|
| Yes | The display label for the action. |
|
| No | Controls visibility of the action. |
|
| Yes | Called when the user selects the action. Receives the full model object. |
The example below demonstrates how you could make a request to your own internal server with details of the Model. This example makes use of appState.
The video below shows an example of this action in use.
appSettings
Configures global appearance and navigation settings for the Builder app. Please note that this action requires both an Enterprise subscription and white labeling. Contact Builder support for more details.
The appSettings action has the following method signature:
An example is included below: