You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md
This how-to describes how to open a modal dialog in Studio Pro from an extension, allowing you to display web content.
9
+
This how-to describes how to open a modal dialog in Studio Pro from an extension. You can use this dialog to display web content.
10
10
11
-
It also describes how to show a progress dialog that follows a sequence of steps and returns a result upon completion.
11
+
It also describes how to show a progress dialog that follows a sequence of steps and returns a result when complete.
12
12
13
13
## Prerequisites
14
14
15
15
{{% alert="info" %}}
16
16
If you are using Studio Pro 11.0–11.5 and your extension includes menus, your existing menu code will not work when you upgrade to Studio Pro 11.6. To restore full functionality and support, upgrade to the Extensibility API 11.6 and follow the steps in the [Migration Guide](/apidocs-mxsdk/apidocs/web-extensibility-api-11/migration-guide/).
17
17
{{% /alert%}}
18
18
19
-
Before starting this how-to, make sure you have completed the following prerequisites:
19
+
Before starting this how-to, complete the following prerequisites:
20
20
21
21
* This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Complete that how-to before starting this one.
22
-
*Make sure you are familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/).
22
+
*Be familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/).
23
23
24
24
## Opening a Modal Dialog
25
25
26
-
Create a menu item to open the dialog. This is done inside the `loaded` event in the main entry point (`src/main/index.ts`). For more information, see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/).
26
+
Create a menu item to open the dialog inside the `loaded` event in the main entry point (`src/main/index.ts`). For more information, see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/).
27
27
28
-
In a listener event called `menuItemActivated`, the `studioPro.ui.dialogs.showModal(<dialogInfo>, <uiSpec>)` call opens a new dialog where:
28
+
In a listener event called `menuItemActivated`, the `studioPro.ui.dialogs.showModal(<dialogInfo>, <uiSpec>)` call opens a new dialog. The parameters are:
29
29
30
-
*`<dialogInfo>`is an object containing the `title` of the dialog, which is shown in the title bar of your dialog in Studio Pro. It also contains the `contentSize` object, where `height` and `width` dimensions for the dialog can be provided.
31
-
*`<uiSpec>`is an object containing two required properties and one optional property:
30
+
*`<dialogInfo>`– An object containing the `title` of the dialog, which is shown in the title bar of your dialog in Studio Pro. It also contains the `contentSize` object, where you can provide `height` and `width` dimensions for the dialog.
31
+
*`<uiSpec>`– An object containing two required properties and one optional property:
32
32
33
-
*`componentName`— the name of the extension prefixed with `extension/`; for example, `extension/myextension`
34
-
*`uiEntryPoint`— the name mapped from the `manifest.json` file
35
-
*`queryParams` (optional) — a key-value pair object for passing data to your web content inside the dialog
33
+
*`componentName`– The name of the extension prefixed with `extension/`. For example, `extension/myextension`.
34
+
*`uiEntryPoint`– The name mapped from the `manifest.json` file.
35
+
*`queryParams` (optional) – A key-value pair object for passing data to your web content inside the dialog.
36
36
37
37
{{% alert color="info" %}}
38
-
When the dialog's API `showModal` method is called, a `Promise` of `unknown` or `null` is returned. This return value represents anything the web content determines should be returned when the dialog is closed. It is currently unknown by the API, since it can be anything.
38
+
When the `showModal` method is called, it returns a `Promise` of `unknown` or `null`. This return value represents anything the web content determines should be returned when the dialog closes. The API cannot determine the type in advance, since it can be anything.
39
39
40
-
In the example below, the dialog will contain a form where an object is modified, then returned at closing time.
40
+
In the example below, the dialog contains a form where an object is modified and then returned when the dialog closes.
41
41
{{% /alert %}}
42
42
43
43
An example of the main entry point (`src/main/index.ts`) to open a modal dialog called *My Extension Dialog* looks similar to the following:
In the previous example, the `uiEntryPoint` property of the `<uispec>` object had the value `dialog`. This value must match the one from the manifest. Below is an example of the dialog under the `ui` property:
79
+
In the previous example, the `uiEntryPoint` property of the `<uispec>` object has the value `dialog`. This value must match the one in the manifest. The following example shows the dialog under the `ui` property:
80
80
81
81
```json
82
82
{
@@ -91,7 +91,7 @@ In the previous example, the `uiEntryPoint` property of the `<uispec>` object ha
91
91
}
92
92
```
93
93
94
-
1. Update `build-extension.mjs` to match the manifest with an entry for the new dialog entry point. Specifically, add the `src/ui/dialog.tsx` endpoint to your build script and make sure the variable `appDir`stays unaltered. For example:
94
+
1. Update `build-extension.mjs` to match the manifest with an entry for the new dialog entry point. Add the `src/ui/dialog.tsx` endpoint to your build script and make sure the variable `appDir`remains unchanged:
95
95
96
96
```typescript{hl_lines=["16-19"]}
97
97
import * as esbuild from 'esbuild'
@@ -195,16 +195,16 @@ In the previous example, the `uiEntryPoint` property of the `<uispec>` object ha
195
195
};
196
196
```
197
197
198
-
Noticethe`dialogId`propertyretrievedfromthequeryparametersofthewebpage. ThisvalueisgeneratedoncethedialogAPIisfirstcalled. Itisthenpassedbacktothewebcontentsothe`close`or`closeWithResult`methodscanbecalledsuccessfully. Thedialog's API needs this Id to close the correct dialog.
YoucanmodifythedimensionsofadialogusingthedialogAPI's `update` method. To do this, add a button to the form contained in `dialog.tsx` file, as follows:
0 commit comments