APIs for custom dialogs
When a dialog is created, a dialog instance API is returned. For example, const instanceApi = editor.windowManager.open(config);
. The dialog API instance is also passed to some of the dialog configuration options.
The instance API is a JavaScript object containing methods attached to the dialog instance. When the dialog is closed, the instance API is destroyed.
Dialog data and state
All dialogs have an internal data store, which is used to track the value and/or state of the dialog’s panel components.
This data store takes the form of a JavaScript object, where the object’s keys are the name
of the configured panel components. For example, if a dialog contains a checkbox component configured with name: myCheckbox
and the checkbox is not checked then the dialog’s data object will contain { myCheckbox: false }
.
The current value of a dialog’s data store can be accessed using the dialog instance API’s getData()
function. It can also be set using setData()
which will automatically update the relevant components. For example, if you call setData({ myCheckbox: true })
with the previous example, the checkbox would be toggled to checked.
To set initial values for components when the dialog is opened, use the initialData
dialog configuration option. For example, you could set the checkbox in the previous example to be checked when the dialog opens by including initialData: { myCheckbox: true }
in the dialog’s configuration.
Dialog API methods
Methods | Description |
---|---|
|
|
|
|
|
Calling |
|
Calling |
|
Calling |
|
Calling |
|
Calling the |
|
Calling |
|
This method only applies to tab panel dialogs. Calling |
Redial
Redial is a concept that allows developers to replace a dialog’s configuration with a new configuration. This can be used for advanced applications such as:
-
Programmatically changing the information displayed in a dialog while it is open.
-
Changing panel components on user action. For example, updating the options in a
selectbox
component based on user input to another interactive component. -
Creating a multipage form where a button leads to the next page.
To redial a dialog, pass a new dialog configuration to the redial()
method from the dialog instance API.
At the moment, Redial does not support partial dialog replacement or the replacement of specific components. Redial must be passed an entire dialog configuration. |
See the redial example for more information on how to use Redial.