Similar to registering custom components, the CE.SDK web editor allows you to render custom panels. Built-in UI elements ensure that your custom panel blends seamlessly with the editor’s look and feel, while still enabling you to adapt the editor to your unique workflows.
registerPanel(panelId: string, renderFunction: ({ builder, engine, state }) => void)
Registers a panel whose content can be rendered with a panel builder, similar to how custom components are registered.
The builder’s render function is called with three arguments: the builder, the engine, and the state. The builder object is used to define which base components (such as buttons) should be rendered. The engine is used to retrieve any state from the engine. The render function will be called again if any engine-related state changes occur due to engine calls or the local state was updated.
panelId
: The unique ID of the new registered panel.renderFunction
: The render function of the panel.
When is a Panel Rendered?
It is important concept to understand when a panel re-renders after its initial rendering. The component assumes that all its state is stored in the engine
or the local state. Whenever we detect a change that is relevant for this panel it will re-render.
Using the Engine
Inside the render function, any calls that retrieve values from the engine will be tracked. If a change is detected, the render function will be automatically re-called.
For example, in a panel, we could query for all selected blocks and decide whether to render a button based on the result. The engine detects the call to findAllSelected and knows that if the selection changes, it needs to re-render the panel. This behavior applies to all methods provided by the engine.
Using Local State
Besides the engine
, the render function also receives a state
argument to manage local state. This can be used to control input components or store state in general. When the state changes, the panel will be re-rendered as well.
The state
argument is a function that is called with a unique ID for the state. Any subsequent call to the state within this panel will return the same state. The second optional argument is the default value for this state. If the state has not been set yet, it will return this value. Without this argument, you’ll need to handle undefined
values manually.
The return value of the state call is an object with value
and setValue
properties, which can be used to get and set the state. Since these property names match those used by input components, the object can be directly spread into the component options.
cesdk.ui.registerPanel('counter', ({ builder, state }) => { const urlState = state('url', ''); const { value, setValue } = state('counter', 0);
builder.Section('counter', { children: () => { builder.TextInput('text-input-1', { inputLabel: 'TextInput 1', ...urlState });
builder.Button('submit-button', { label: 'Submit', onClick: () => { const pressed = value + 1; setValue(pressed); console.log( `Pressed ${pressed} times with the current URL ${urlState.value}` ); } }); } });});
Integrate the Panel into the Editor
After registering a component, it is not automatically opened or integrated in any other way. The CE.SDK editor is just aware that there is a panel with this id.
Opening a Panel
Once a panel is registered, it can be controlled using the Panel API, just like any other panel. For instance, you can open a custom panel with cesdk.ui.openPanel(registeredPanelId)
. Other settings, such as position and floating, can also be adjusted accordingly. The payload passed by openPanel
is also accessible within the panel’s render function.
In most cases, you will want to open it using a custom button, .e.g in a button inside the Dock or Inspector Bar.
Setting the Title of a Custom Panel
The title of a panel is determined by a translation based on the panel’s ID. For example, if the panel ID is myCustomPanel
, the corresponding translation key would be panel.myCustomPanel
.
cesdk.setTranslations({ en: { 'panel.myCustomPanel': 'My Custom Panel', }, de: { 'panel.myCustomPanel': 'Mein eigenes Panel', }});
Using the Builder
The builder
object passed to the render function provides a set of methods to create UI elements. Calling this method will add a builder component to the user interface. This includes buttons, dropdowns, text, etc.
Builder Components
The following builder components can be used inside a registered panel.
Button
A simple button to react on a user click.
Property | Description |
---|---|
label | The label inside the button. If it is a i18n key, it will be used for translation. |
labelAlignment | How the label inside the button is aligned. Either left or center . |
inputLabel | An optional label next to/above the button. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the button - either 'top' or 'left' . |
tooltip | A tooltip displayed upon hover. If it is a i18n key, it will be used for translation. |
onClick | Executed when the button is clicked. |
variant | The variant of the button. regular is the default variant, plain is a variant without any background or border. |
color | The color of the button. accent is the accent color to stand out, danger is a red color. |
icon | The icon of the button. See Icon API for more information about how to add new icons. |
trailingIcon | The trailing icon of the button. See Icon API for more information about how to add new icons. |
size | The size of the button. Either 'normal' or 'large' . |
isActive | A boolean to indicate that the button is active. |
isSelected | A boolean to indicate that the button is selected. |
isDisabled | A boolean to indicate that the button is disabled. |
isLoading | A boolean to indicate that the button is in a loading state. |
loadingProgress | A number between 0 and 1 to indicate the progress of a loading button. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
ButtonGroup
Grouping of multiple buttons in a single segmented control.
Property | Description |
---|---|
inputLabel | An optional label next to/above the button group. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the button group - either 'top' or 'left' . |
children | A function executed to render grouped buttons. Only the Button , Dropdown and Select builder components are allowed to be rendered inside this function. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
Checkbox
A labeled checkbox.
Property | Description |
---|---|
inputLabel | An optional label next to the checkbox. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the checkbox - either 'left' (default) or 'right' . |
icon | The icon of the checkbox. See Icon API for more information about how to add new icons. |
isDisabled | A boolean to indicate that the checkbox is disabled. |
ColorInput
A big color swatch that opens a color picker when clicked.
Property | Description |
---|---|
inputLabel | An optional label next to the color input. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the color input - either 'left' (default) or 'top' . |
icon | The icon of the checkbox. See Icon API for more information about how to add new icons. |
isDisabled | A boolean to indicate that the color input is disabled. |
value | The color value that the input is showing. |
setValue | A callback that receives the new color value when the user picks one. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
Dropdown
A button that opens a dropdown with additional content when the user clicks on it.
Property | Description |
---|---|
label | The label inside the button. If it is a i18n key, it will be used for translation. |
tooltip | A tooltip displayed upon hover. If it is a i18n key, it will be used for translation. |
variant | The variant of the button. regular is the default variant, plain is a variant without any background or border. |
color | The color of the button. accent is the accent color to stand out, danger is a red color. |
icon | The icon of the button. See Icon API for more information about how to add new icons. |
isActive | A boolean to indicate that the button is active. |
isSelected | A boolean to indicate that the button is selected. |
isDisabled | A boolean to indicate that the button is disabled. |
isLoading | A boolean to indicate that the button is in a loading state. |
loadingProgress | A number between 0 and 1 to indicate the progress of a loading button. |
children | A function executed to render the content of the dropdown. Every builder component called in this children function, will be rendered in the dropdown. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
Heading
Renders its content as heading to the panel.
Property | Description |
---|---|
content | The content of the header as a string. |
Library
A complete asset library with a search option.
Property | Description |
---|---|
entries | An array of Asset Library entry IDs that determines which assets are shown in which way. See Asset Library Entry for reference. |
onSelect | A callback receiving the selected asset when the user picks one. |
searchable | When set, makes the Library searchable. |
MediaPreview
A large preview area showing an image or color. Optionally contains a button in the bottom right corner, offering contextual action.
Property | Description |
---|---|
size | Size of the preview, either 'small' or 'medium' (default). |
preview | Determines the kind of preview. Can be either an image, or a color. Use an object with the following shape: { type: 'image', uri: string } or { type: 'color', color: string } |
action | Button option object that is passed along to the overlayed button. See Button for reference. |
NumberInput
A number input field.
Property | Description |
---|---|
inputLabel | An optional label next to/above the number input. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the input - either 'top' or 'left' . |
value | The number contained in the input. |
setValue | A callback that receives the new number when it is changed by the user. |
min | Minimum value of the input. |
max | Maximum value of the input. |
step | Interval of changes when using the arrow keys to change the number. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
Select
A dropdown to select one of multiple choices.
Property | Description |
---|---|
inputLabel | An optional label next to/above the control. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the control - either 'top' or 'left' . |
tooltip | A tooltip displayed upon hover. If it is a i18n key, it will be used for translation. |
value | The currently selected value. |
setValue | A callback that receives the new selection when it is changed by the user. |
values | The set of values from which the user can select. |
isDisabled | A boolean to indicate that the control is disabled. |
isLoading | A boolean to indicate that the control is in a loading state. |
loadingProgress | A number between 0 and 1 to indicate the progress of loading. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
Separator
Adds a separator (<hr>
element) in the panel to help the visual separation of entries. This builder component has no properties.
Slider
A slider for intuitively adjusting a number.
Property | Description |
---|---|
inputLabel | An optional label next to/above the text field. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the input - either 'top' or 'left' . |
value | The text contained in the field. |
setValue | A callback that receives the new text when it is changed by the user. |
min | Minimum value of the slider. |
max | Maximum value of the slider. |
step | Interval of the slider movement. |
centered | Adds a snapping point in the middle of the slider. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |
Text
A piece of non-interactive text.
Property | Description |
---|---|
content | The content of the text as a string. |
TextArea
A large text field accepting user input.
Property | Description |
---|---|
inputLabel | An optional label above the text field. If it is a i18n key, it will be used for translation. |
value | The text contained in the field. |
setValue | A callback that receives the new text when it is changed by the user. |
isDisabled | A boolean to indicate that the text area is disabled. |
placeholder | Hint text shown when the field is empty. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the input label. Please note that the suffix is not rendered if there is no input label. If the object includes only an icon (with a tooltip), only the icon will be displayed. |
TextInput
A small text field accepting user input.
Property | Description |
---|---|
inputLabel | An optional label next to/above the text field. If it is a i18n key, it will be used for translation. |
inputLabelPosition | Input label position relative to the input - either 'top' or 'left' . |
value | The text contained in the field. |
setValue | A callback that receives the new text when it is changed by the user. |
isDisabled | A boolean to indicate that the text field is disabled. |
suffix | An object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components. |