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/custom-blob-document-api.md
This how-to describes how to introduce a new document type and provide a custom editor to allow users to edit new documents of the introduced type.
9
+
This how-to describes how to introduce a new document type and provide a custom editor so users can edit documents of that type.
10
10
11
11
## Prerequisites
12
12
@@ -16,15 +16,12 @@ Before starting this how-to, make sure you have completed the following prerequi
16
16
17
17
## Custom Document Model
18
18
19
-
Studio Pro provides you with possibility to extend its metamodel by introducing your own document types. These new documents are allowed to store arbitrary data,
20
-
which must be serializable as strings. If an editor, which is a user-defined UI component, is registered for a document, new document will appear in UI as any other
21
-
built-in document type (e.g., constants, Java Actions or pages). In particular, it will appear in New Document and Find Advanced dialogs, context menus for adding
22
-
new documents, App explorer and other UI elements that show Studio Pro documents. Custom editors can be registered as either tabs or modal dialogs.
19
+
Studio Pro lets you extend its metamodel by introducing custom document types. These documents can store arbitrary data that must be serializable as strings. If an editor (a user-defined UI component) is registered for a document type, documents of that type will appear in the UI like any other built-in document type (for example, constants, Java Actions, or pages). In particular, they will appear in the New Document and Find Advanced dialogs, context menus for adding documents, the App Explorer, and other UI elements that show Studio Pro documents. Custom editors can be registered to appear either as tabs or as modal dialogs.
23
20
24
21
## Registering a New Document Type
25
22
26
-
To start with registering a new document type, generate a new extension called `myextension`, as described in [getting started guide](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/).
27
-
We will explain which files of the generated extension to edit and then explain what the edits achieve.
23
+
To register a new document type, generate a new extension called `myextension` as described in the [Getting started guide](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/).
24
+
Below we explain which files of the generated extension to edit and what those edits achieve.
28
25
29
26
First, replace the contents of `src/main/index.ts` with:
Lastly, we need to update the build instructions and manifest. To do so, replace the contents of `build-extension.mjs` with
188
+
Lastly, update the build instructions and manifest. To do so, replace the contents of `build-extension.mjs` with
192
189
193
190
```javascript {hl_lines=["16-19"]}
194
191
import*asesbuildfrom'esbuild'
@@ -228,7 +225,7 @@ else {
228
225
}
229
226
```
230
227
231
-
and the contents of `manifest.json` with
228
+
and replace the contents of `manifest.json` with
232
229
233
230
```json {hl_lines=["6"]}
234
231
{
@@ -245,26 +242,16 @@ and the contents of `manifest.json` with
245
242
246
243
### Walking through the example code
247
244
248
-
In `src/main/index.ts`, we are first registering a new document type. When a new document type is registered, you can perform all
249
-
CRUD operations on this document type, but it will not yet be shown in the UI since no editor for it has yet been registered. Note
250
-
that you can optionally provide `readableTypeName` which will be shown instead of full type name in every user-facing context such
251
-
as in logs and in the Studio Pro UI. You can optionally customize the (de)serialization of the document contents to string, which
252
-
defaults to `JSON.stringify` and `JSON.parse`. The next call to `studioPro` API registers editor for our document type. It registers
253
-
`editor` entry point of our extension as the editor that will be shown when user interacts with the document in StudioPro (for example
254
-
through App Explorer or Find Results). This editor will be shown as a tab, but you can also register editors to be shown as
255
-
modal dialogs. Lastly, icons for both light and dark theme are registered. Those icons will be shown in all UI elements where
256
-
document icon is needed.
245
+
In `src/main/index.ts`, we first register a document type. When a document type is registered, you can perform all CRUD operations on it, but it won't appear in the UI until an editor is registered for it. Note that you can optionally provide `readableTypeName`, which will be shown instead of the full type name in user-facing contexts such as logs and the Studio Pro UI. You can also customize serialization of the document contents to a string; by default the API uses `JSON.stringify` for serialization and `JSON.parse` for deserialization.
257
246
258
-
The first highlighted block of code in `src/ui/editor.tsx` listens for changes in documents to make sure that the last version of currently
259
-
active document is shown. Note that the document can be changed outside currently open editor by calls to custom blob document API,
260
-
as well as by some Studio Pro operations such as undoing changes. In the next highlighted block, we fetch the document contents
261
-
whenever new document is open or updated. Lastly, we make sure that the current changes can be saved.
247
+
The next call to the Studio Pro API registers an editor for our document type. It registers the `editor` entry point of our extension as the editor that will be shown when a user interacts with the document in Studio Pro (for example, through the App Explorer or Find Results). This editor will be shown as a tab, but you can also register editors to be shown as modal dialogs. Finally, icons for both the light and dark themes are registered; those icons appear wherever a document icon is needed.
262
248
263
-
We also highlighted changes that need to be made to `build-extension.mjs` and `manifest.json` to make sure that `editor` entry point
264
-
is properly built and loaded.
249
+
The first highlighted block of code in `src/ui/editor.tsx` listens for changes to documents to ensure that the most recent version of the currently active document is shown. Note that the document can be changed outside the currently open editor by calls to the custom blob document API, or by some Studio Pro operations such as undo. In the next highlighted block, we fetch the document contents whenever a new document is opened or an existing document is updated. Finally, we provide a way to save changes.
250
+
251
+
We also highlighted the changes needed in `build-extension.mjs` and `manifest.json` to ensure that the `editor` entry point is built and loaded properly.
265
252
266
253
## Extensibility Feedback
267
254
268
255
If you would like to provide us with additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback).
0 commit comments