DynamicPanel API
The dynamicPanel module of the @codebolt/plugin-sdk.
import plugin from '@codebolt/plugin-sdk';
Quick Reference
| Method | Description |
|---|---|
close | Closes a DynamicPanel and removes it from the UI. |
list | Lists all currently active DynamicPanels. |
offMessage | Removes the message handler for a specific panel. |
onMessage | Registers a handler for messages coming from a specific panel's iframe. |
open | Opens a new DynamicPanel with the given HTML content. |
send | Pushes arbitrary data into the panel's iframe via postMessage. |
update | Replaces the HTML content of an existing DynamicPanel. |
Methods
close
plugin.dynamicPanel.close(panelId: string): Promise<DynamicPanelResponse>
Closes a DynamicPanel and removes it from the UI.
| Parameter | Type | Required | Description |
|---|---|---|---|
panelId | string | Yes | The panel to close |
Returns: Promise<DynamicPanelResponse>
list
plugin.dynamicPanel.list(): Promise<DynamicPanelListResponse>
Lists all currently active DynamicPanels.
No parameters.
Returns: Promise<DynamicPanelListResponse>
offMessage
plugin.dynamicPanel.offMessage(panelId: string): void
Removes the message handler for a specific panel.
| Parameter | Type | Required | Description |
|---|---|---|---|
panelId | string | Yes | The panel to stop listening to |
Returns: void
onMessage
plugin.dynamicPanel.onMessage(panelId: string, handler: Function): void
Registers a handler for messages coming from a specific panel's iframe.
The iframe sends messages via window.parent.postMessage({ type: '...', data: {...} }, '*').
Only one handler per panelId is supported. Calling this again for the same panelId replaces the previous handler.
| Parameter | Type | Required | Description |
|---|---|---|---|
panelId | string | Yes | The panel to listen to |
handler | Function | Yes | Callback receiving the message data |
Returns: void
open
plugin.dynamicPanel.open(panelId: string, title: string, html: string, opts?: DynamicPanelOpenOptions): Promise<DynamicPanelOpenResponse>
Opens a new DynamicPanel with the given HTML content.
When opts.waitForResponse is true the call blocks until the panel
iframe sends a { type: 'submit', data: {...} } message via
window.parent.postMessage(). The resolved value then contains the
submitted data.
| Parameter | Type | Required | Description |
|---|---|---|---|
panelId | string | Yes | Unique identifier for the panel |
title | string | Yes | Human-readable panel title shown in the tab |
html | string | Yes | Full HTML document rendered inside the panel iframe |
opts | DynamicPanelOpenOptions | No | Optional: waitForResponse, timeout |
Returns: Promise<DynamicPanelOpenResponse>
send
plugin.dynamicPanel.send(panelId: string, data: any): Promise<DynamicPanelResponse>
Pushes arbitrary data into the panel's iframe via postMessage.
The iframe receives this in its window.addEventListener('message', ...) handler.
| Parameter | Type | Required | Description |
|---|---|---|---|
panelId | string | Yes | The target panel |
data | any | Yes | Any JSON-serializable payload |
Returns: Promise<DynamicPanelResponse>
update
plugin.dynamicPanel.update(panelId: string, html: string): Promise<DynamicPanelResponse>
Replaces the HTML content of an existing DynamicPanel.
| Parameter | Type | Required | Description |
|---|---|---|---|
panelId | string | Yes | The panel to update |
html | string | Yes | New HTML content |
Returns: Promise<DynamicPanelResponse>