Skip to content

Commit 841e4b0

Browse files
Petar VukmirovicPetar Vukmirovic
authored andcommitted
Fix the grammar and spelling
1 parent 5afacfe commit 841e4b0

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/custom-blob-document-api.md

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/custom-blob-document-api/
66

77
## Introduction
88

9-
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.
1010

1111
## Prerequisites
1212

@@ -16,15 +16,12 @@ Before starting this how-to, make sure you have completed the following prerequi
1616

1717
## Custom Document Model
1818

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.
2320

2421
## Registering a New Document Type
2522

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.
2825

2926
First, replace the contents of `src/main/index.ts` with:
3027

@@ -58,7 +55,7 @@ export const component: IComponent = {
5855
}
5956
```
6057

61-
Then add a new file `src/model/contants.ts` with contents:
58+
Then add a new file `src/model/constants.ts` with the following contents:
6259

6360
```typescript
6461
export const personDocumentType = 'myextension.Person';
@@ -77,7 +74,7 @@ export type PersonInfo = {
7774
}
7875
```
7976
80-
Then rename the file `src/ui/index.tsx` to `src/ui/editor.tsx` and paste the following contents into it:
77+
Rename the file `src/ui/index.tsx` to `src/ui/editor.tsx` and paste the following contents into it:
8178
8279
```typescript {hl_lines=["16-22", "24-35", "37-43"]}
8380
import React, { StrictMode, useCallback, useEffect, useState } from "react";
@@ -101,7 +98,7 @@ function PersonEditor(input : { studioPro: StudioProApi, documentId: string }) {
10198
setDocumentVersion(v => v + 1); // Trigger re-fetch of the document
10299
}
103100
});
104-
}, [studioPro]);
101+
}, [studioPro, documentId]);
105102

106103
useEffect(() => {
107104
studioPro.app.model.customBlobDocuments
@@ -188,7 +185,7 @@ export const component: IComponent = {
188185
};
189186
```
190187

191-
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
192189

193190
```javascript {hl_lines=["16-19"]}
194191
import * as esbuild from 'esbuild'
@@ -228,7 +225,7 @@ else {
228225
}
229226
```
230227

231-
and the contents of `manifest.json` with
228+
and replace the contents of `manifest.json` with
232229

233230
```json {hl_lines=["6"]}
234231
{
@@ -245,26 +242,16 @@ and the contents of `manifest.json` with
245242

246243
### Walking through the example code
247244

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.
257246

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.
262248

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.
265252

266253
## Extensibility Feedback
267254

268255
If you would like to provide us with additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback).
269256

270-
Any feedback is appreciated.
257+
Any feedback is appreciated.

0 commit comments

Comments
 (0)