Skip to content

Commit b0ff6a1

Browse files
committed
Review Dockable pane API
1 parent 2ea46de commit b0ff6a1

File tree

1 file changed

+55
-59
lines changed
  • content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos

1 file changed

+55
-59
lines changed

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dockable-pane-api.md

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/dockable-pane-api/
66

77
## Introduction
88

9-
This guide explains how to create and manage a dockable pane using the web extensions API. A Dockable pane allows you to create a web view that can be docked and moved within the Studio Pro user interface. Examples of dockable panes in Studio Pro are:
9+
This how-to describes how to create and manage a dockable pane using the web extensions API. A dockable pane allows you to create a web view that can be docked and moved within the Studio Pro user interface. Examples of dockable panes in Studio Pro are:
1010

1111
* Marketplace
1212
* Errors
@@ -15,11 +15,13 @@ This guide explains how to create and manage a dockable pane using the web exten
1515

1616
## Prerequisites
1717

18-
This guide uses the app created in [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one.
18+
This how-to uses the app created in [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Make sure to complete that how-to before starting this one.
1919

2020
## Creating a Dockable Pane
2121

22-
To open a dockable pane you must first register the dockable pane handle with the API. To do this, add a call to register the pane to the extension loaded method in the `src/main/index.ts`.
22+
### Register the Dockable Pane
23+
24+
To open a dockable pane, you must first register the dockable pane handle with the API. To do this, add a call to register the pane to the extension loaded method in the `src/main/index.ts`. Use the 'paneHandle' to interact with the pane.
2325

2426
```typescript
2527
const paneHandle = await studioPro.ui.panes.register(
@@ -33,9 +35,7 @@ To open a dockable pane you must first register the dockable pane handle with th
3335
});
3436
```
3537

36-
Use the 'paneHandle' you registered to interact with the dockable pane.
37-
38-
After adding this call the `loaded()` method looks like this:
38+
After adding this call, the `loaded()` method looks like this:
3939

4040
```typescript {hl_lines=["12-20"]}
4141
async loaded(componentContext) {
@@ -79,11 +79,11 @@ After adding this call the `loaded()` method looks like this:
7979
}
8080
```
8181

82-
## Adding a Menu To Open the Dockable Pane
82+
### Adding a Menu To Open the Dockable Pane
8383

84-
You will now add a menu that will open the pane when it is selected.
84+
Add a menu that will open the pane when it is selected.
8585

86-
1. Add a new submenu to the existing `extensionsMenu.add()` method on line 7.
86+
1. Add a new sub-menu to the existing `extensionsMenu.add()` method on line 7.
8787

8888
```typescript {linenos=table linenostart=6}
8989
// Add a menu item to the Extensions menu
@@ -97,7 +97,7 @@ You will now add a menu that will open the pane when it is selected.
9797
});
9898
```
9999

100-
1. Add lines to the `addEventListener()` call to handle opening the dockable pane once the menu has been selected, as follows:
100+
2. Add lines to the `addEventListener()` call that will open the pane when the menu is selected.
101101

102102
```typescript
103103
// Open a tab when the menu item is clicked
@@ -174,17 +174,16 @@ Your `loaded()` method should now look like this:
174174

175175
### Adding New Endpoint Handlers
176176

177-
You must now create a new web view endpoint where the user interface to be rendered within the pane is defined. You can use the existing endpoint and rename it to something more appropriate.
177+
Create a new web view endpoint where you define the user interface that will be rendered within the pane. You can use and rename the existing endpoint. Follow the steps below:
178178

179-
1. Rename `ui/index.tsx` to `ui/tab.tsx`
180-
1. Add the new endpoint file, `ui/dockablepane.tsx` by copying `ui/tab.tsx`.
179+
1. Rename `ui/index.tsx` to `ui/tab.tsx`.
180+
1. Add the new endpoint file, `ui/dockablepane.tsx`, by copying `ui/tab.tsx`.
181181

182-
You must also alter the `build-extension.mjs` and `manifest.json` files to make sure the new endpoint is built and bound to a name referenced in `uiEntrypoint` property in extensibility APIs, as described in the following sections:
182+
You must also alter the `build-extension.mjs` and `manifest.json` files to bind to the correct endpoint, as described in the following sections.
183183

184184
### Altering `build-extension.mjs`
185185

186-
To instruct esbuild to produce JavaScript modules that correspond to `src/ui/tab.tsx` and `src/ui/dockablepane.tsx`,
187-
change the call to `entryPoints.push` in line 16 as follows:
186+
Instruct esbuild to produce JavaScript modules that correspond to `src/ui/tab.tsx` and `src/ui/dockablepane.tsx`. To do this, change the call to `entryPoints.push` in line 16:
188187

189188
```typescript
190189
entryPoints.push({
@@ -197,7 +196,7 @@ entryPoints.push({
197196
});
198197
```
199198

200-
Your `build-extension.mjs` file should be like this (note that the variable `appDir` should retain its previous value):
199+
The variable `appDir` should retain its previous value. Your `build-extension.mjs` file should look like this:
201200

202201
```javascript {hl_lines=["16-23"]}
203202
import * as esbuild from 'esbuild'
@@ -241,14 +240,16 @@ else {
241240
}
242241
```
243242

244-
This makes sure that esbuild will consider these two `.tsx` files as entrypoints and produce JavaScript modules in the
245-
`dist` folder, corresponding to the name in `out`.
243+
This ensures esbuild will consider these two `.tsx` files as entrypoints and produce JavaScript modules in the `dist` folder, corresponding to the name in `out`.
246244

247245
### Altering `src/manifest.json`
248246

249-
You also need to instruct Studio Pro to load the endpoint that you just created. To do this, modify the manifest file `src/manifest.json`.
247+
You also must instruct Studio Pro to load the endpoint that you just created. To do this, modify the manifest file `src/manifest.json`.
248+
249+
Alter the "ui" section by:
250250

251-
Alter the "ui" section by changing the `tab` endpoint and adding the `dockablepane` endpoint.
251+
* Changing the `tab` endpoint
252+
* Adding the `dockablepane` endpoint
252253

253254
```typescript
254255
"ui": {
@@ -275,43 +276,43 @@ The `manifest.json` file should now look like this:
275276

276277
## Closing the Dockable Pane
277278

278-
Now that you have registered a pane and can open it, you can also close it.
279+
Now that you have registered a pane and created a way to open it, it is important to provide a way to close it, too.
279280

280-
You will close your pane using a new menu item.
281+
You will close your pane using a new menu item. Follow the steps below:
281282

282-
First, add a new sub menu item to the menu on line 13.
283+
1. Add a new sub-menu item to the menu on line 13.
283284

284-
```typescript {linenos=table linenostart=13}
285-
{ menuId: "myextension.HideDockMenuItem", caption: "Hide dock pane" },
286-
```
285+
```typescript {linenos=table linenostart=13}
286+
{ menuId: "myextension.HideDockMenuItem", caption: "Hide dock pane" },
287+
```
287288

288-
You must also alter the event handler for the new menu at the end of the loaded method:
289+
2. Alter the event handler for the new menu at the end of the loaded method.
289290

290-
```typescript
291-
// Open a tab when the menu item is clicked
292-
studioPro.ui.extensionsMenu.addEventListener(
293-
"menuItemActivated",
294-
(args) => {
295-
if (args.menuId === "myextension.ShowTabMenuItem") {
296-
studioPro.ui.tabs.open(
297-
{
298-
title: "My Extension Tab",
299-
},
300-
{
301-
componentName: "extension/myextension",
302-
uiEntrypoint: "tab",
303-
}
304-
);
305-
}
306-
else if (args.menuId === "myextension.ShowDockMenuItem") {
307-
studioPro.ui.panes.open(paneHandle);
308-
}
309-
else if (args.menuId === "myextension.HideDockMenuItem") {
310-
studioPro.ui.panes.close(paneHandle);
291+
```typescript
292+
// Open a tab when the menu item is clicked
293+
studioPro.ui.extensionsMenu.addEventListener(
294+
"menuItemActivated",
295+
(args) => {
296+
if (args.menuId === "myextension.ShowTabMenuItem") {
297+
studioPro.ui.tabs.open(
298+
{
299+
title: "My Extension Tab",
300+
},
301+
{
302+
componentName: "extension/myextension",
303+
uiEntrypoint: "tab",
304+
}
305+
);
306+
}
307+
else if (args.menuId === "myextension.ShowDockMenuItem") {
308+
studioPro.ui.panes.open(paneHandle);
309+
}
310+
else if (args.menuId === "myextension.HideDockMenuItem") {
311+
studioPro.ui.panes.close(paneHandle);
312+
}
311313
}
312-
}
313-
);
314-
```
314+
);
315+
```
315316

316317
The `loaded` method should now look like this:
317318

@@ -365,13 +366,8 @@ The `loaded` method should now look like this:
365366
}
366367
```
367368

368-
## Conclusion
369-
370-
You now have a new dockable pane with its own user interface which you can modify as you like.
371-
You can also open and close the dockable pane from a menu.
372-
373369
## Extensibility Feedback
374370

375-
If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback)
371+
If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback)
376372

377-
Any feedback is much appreciated.
373+
Any feedback is appreciated.

0 commit comments

Comments
 (0)