Skip to content

Commit 6297669

Browse files
nielslyngsoegitbook-bot
authored andcommitted
GITBOOK-27: Registere Extensions
1 parent 0410c7a commit 6297669

File tree

7 files changed

+110
-105
lines changed

7 files changed

+110
-105
lines changed

16/umbraco-cms/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
* [Vite Package Setup](customizing/development-flow/vite-package-setup.md)
149149
* [Extensions Overview](customizing/extending-overview/README.md)
150150
* [Extension Registry](customizing/extending-overview/extension-registry/README.md)
151-
* [Extension Registration](customizing/extending-overview/extension-registry/extension-registry.md)
151+
* [Register an Extension](customizing/extending-overview/extension-registry/extension-registry.md)
152152
* [Extension Manifest](customizing/extending-overview/extension-registry/extension-manifest.md)
153153
* [Replace, Exclude or Unregister](customizing/extending-overview/extension-registry/replace-exclude-or-unregister.md)
154154
* [Extension Types](customizing/extending-overview/extension-types/README.md)

16/umbraco-cms/customizing/extending-overview/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,3 @@ An overview of the different ways to append functionality.
2424
## [Extension Conditions](extension-conditions.md)
2525

2626
Make your extension appear only when certain conditions are met.
27-
28-
29-
30-
##
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# Extension Registry
1+
---
2+
description: >-
3+
Almost any UI in the Backoffice is an extension. All managed by the Extension
4+
Registry on the Client at Runtime. Giving you enourmes flexibility.
5+
---
26

3-
{% hint style="warning" %}
4-
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
5-
{% endhint %}
7+
# Extension Registry
68

7-
The Extensions Registry is your entry to extend or customize the Backoffice. Therefor it is crucial to understand the abilities of the Extension Registry.
9+
The Extensions Registry is your entry to extend or customize the Backoffice. Therefore, it is crucial to understand the abilities of the Extension Registry.
810

911
## [Extension Registration](extension-registry.md) <a href="#registration" id="registration"></a>
1012

11-
The extension registry is a global registry that can be accessed and changed at anytime while Backoffice is running.
13+
The extension registry is a global registry that can be accessed and changed at any time while Backoffice is running.
1214

1315
## [Extension Manifest](extension-manifest.md)
1416

15-
Each Extension Manifest has to declare its type, this is used to determine where it hooks into the system. It also looks at what data is required to declare within it.
17+
Each Extension Manifest has to declare its type. This is used to determine where it hooks into the system. It also looks at what data is required to declare within it.
1618

1719
## [Replace, Exclude, or Unregister](replace-exclude-or-unregister.md)
1820

19-
Once you understand how to declare your own, you may want to replace or remove existing.
21+
Once you understand how to declare your own, you may want to replace or remove existing ones.

16/umbraco-cms/customizing/extending-overview/extension-registry/extension-manifest.md

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,87 +6,45 @@ description: Learn about the different methods for declaring an Extension Manife
66

77
The Extension Manifest is the first step for any extension. It is the declaration of what you want to register.
88

9-
In this section you will find all the Extension Types provided by the Backoffice. [See all Extension Types here.](../extension-types/)
9+
In this section, you will find all the Extension Types provided by the Backoffice. [See all Extension Types here.](../extension-types/)
1010

1111
## Extension Manifest Format
1212

1313
An Extension Manifest can be written as a JavaScript or JSON Object.
1414

15-
There are a few general properties, the required set of properties consists of the `type`, `alias`, and `name`.
15+
The abilities of the extensions rely on the specific extension type. The Type sets the scene for what the extension can do and what it needs to be utilized. Some extension types can be made purely via the manifest. Other types require files, like a JavaScript file containing a Web Component.
1616

1717
```typescript
18-
const manifest = {
18+
{
1919
type: '...',
2020
alias: 'my.customization',
2121
name: 'My customization'
2222
...
2323
};
2424
```
2525

26-
The `type` defines what it is declaring. The `alias` is a unique identifier for this manifest. It must be globally unique, so make sure to prefix it with something that makes your extension unique. The `name` is a representational name of this manifest, this does not need to be unique but such can be beneficial when debugging extensions.
27-
28-
## Manifest Data
29-
30-
Each Extension Manifest has to declare its type. This is used to determine where it hooks into the system. It also determines what data is required of this manifest.
31-
32-
The abilities of the extensions rely on the specific extension type. The Type sets the scene for what the extension can do and what it needs to be utilized. Some extension types can be made purely via the manifest. Other requires files, like a JavaScript file containing a Web Component.
26+
The required fields of any Extension Manifest are:
3327

34-
The required fields of any extension manifest are:
28+
* `type` — The type defines the purpose of the extension. It is used to determine where the extension will be used.
29+
* `alias` — This is a unique identifier for this manifest. Prefix it with something that makes your extension unique. Example: `mfc.Dashboard.Overview` .
30+
* `name` — This is a representational name of this manifest; It does not need to be unique, but this can be beneficial when debugging extensions. Example: `My Fictive Company Overview Dashboar` .
3531

36-
* `type` - The type defines the type and purpose of the extension. It is used to determine where the extension will be used and defines the data needed for this manifest.
37-
* `alias`- The alias is used to identify the extension. This has to be unique for each extension.
38-
* `name` - The name of the extension. This is used to identify the extension in the UI.
32+
### Additional Manifest features
3933

40-
Additionally, many extensions support the use of the following fields:
34+
Most extension types support the use of the following generic features for their Manifest:
4135

42-
* `weight` - Define a weight, to determine the importance or visual order of this extension. The higher the weight, the higher in the list it will appear.
36+
* `weight` - Define a weight to determine the importance or visual order of this extension. A higher weight gives a more prominent position.
4337
* `overwrites` - Define one or more Extension Aliases that this extension should replace. Notice it only omits the listed Extensions when this is rendered in the same spot. [Read more in Replace, Exclude or Unregister](replace-exclude-or-unregister.md).
4438
* `conditions` - Define one or more conditions that must be permitted for the extension to become available. [Extension Conditions](../extension-conditions.md).
45-
* `kind` - Define a kind-alias of which this manifest should be based upon. Kinds acts like a preset for your manifest. [Extension Kinds](../extension-kind.md).
39+
* `kind` - Define a kind-alias of which this manifest should be based upon. Kind acts like a preset for your manifest. [Extension Kinds](../extension-kind.md).
4640

4741
Many of the Extension Types require additional information declared as part of a `meta` field.
4842

49-
## Registration
50-
51-
An Extension Manifest can be registered in multiple ways.
52-
53-
The primary registration should take part of the Umbraco Package Manifest.
54-
55-
You can choose to declare all Extensions in the Package Manifest, or use one of three Extension Types to registere more extensions.
56-
57-
This enables you to locate your Manifests in files together with the implementation code and the ability to declare Extension Manifests in TypeScript.
58-
59-
A typical structure would be to declare one or more `Bundle` extensions in the Package Manifest. Each of the Bundles points to a `manifests.js` file which declares the Extensions of interest.
60-
61-
### The `bundle` extension type
62-
63-
The Bundle extension type is used to declare multiple Extension Manifests from a single JavaScript file.
64-
65-
The Bundle is loaded at startup. All the Extension Manifests exported of the JavaScript file will be registered.
66-
67-
Read more about the `bundle` extension type in the [Bundle](../extension-types/bundle.md)article.
68-
69-
### The `backofficeEntryPoint` extension type
70-
71-
Run any JavaScript code when Backoffice startups, after the user is logged in. This can be used as an entry point for a package, registering more extensions or configuring your package.
72-
73-
There are many use cases. To name a few, it could be to load external libraries shared by all your extensions or load **global CSS files** for the whole application.
74-
75-
The entry point declares a single JavaScript file that will be loaded and run when the Backoffice starts.
76-
77-
Read more about the `backofficeEntryPoint` extension type in the [Backoffice Entry Point](../extension-types/backoffice-entry-point.md) article.
78-
79-
### The `appEntryPoint` extension type
80-
81-
Similar as `appEntryPoint` this runs as startup, the difference is that this runs before the user is logged in. Use this to initiate things before the user is logged in or to provide things for the Login screen.
82-
83-
Read more about the `appEntryPoint` extension type in the [App Entry Point](../extension-types/app-entry-point.md) article.
84-
8543
## Type intellisense
8644

87-
It is recommend to make use of the Type intellisense that we provide.
45+
It is recommended to make use of the Type IntelliSense that we provide.
8846

89-
When writing your Manifest in TypeScript you should use the Type `UmbExtensionManifest`, see the [TypeScript setup](broken-reference) article to make sure you have Types correctly configured.
47+
When writing your Manifest in TypeScript, you should use the Type `UmbExtensionManifest`. See the article on [Development Setup](../../development-flow/) to ensure you have Types correctly configured.
9048

9149
{% code title="manifests.ts" %}
9250
```typescript
@@ -101,12 +59,12 @@ export const manifests: Array<UmbExtensionManifest> = [
10159
```
10260
{% endcode %}
10361

104-
When writing the Umbraco Package Manifest you can use the JSON Schema located in the root of your Umbraco project called `umbraco-package-schema.json`
62+
When writing the Umbraco Package Manifest, you can use the JSON Schema located in the root of your Umbraco project called `umbraco-package-schema.json` .
10563

10664
```json
10765
{
10866
"$schema": "../../umbraco-package-schema.json",
109-
"name": "Fast Track Customizations",
67+
"name": "My Customizations",
11068
"extensions": [
11169
{
11270
"type": "...",
@@ -119,19 +77,3 @@ When writing the Umbraco Package Manifest you can use the JSON Schema located in
11977
}
12078
```
12179

122-
### Registration via any JavaScript code
123-
124-
Alternatively, an Extension Manifest can be declared in JavaScript at any given point.
125-
126-
The following example shows how to register an extension manifest via JavaScript code:
127-
128-
```typescript
129-
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
130-
131-
const manifest = {
132-
type: '...',
133-
...
134-
};
135-
136-
umbExtensionsRegistry.register(extension);
137-
```
Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,75 @@
1-
# Extension Registration
1+
---
2+
description: >-
3+
Bringing new UI or additional features to the Backoffice is done by
4+
registering an Extension via an Extension Manifest.
5+
---
26

3-
{% hint style="warning" %}
4-
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
5-
{% endhint %}
7+
# Register an Extension
68

7-
The extension registry is the center piece of the Backoffice UI. It holds information about most of the Backoffice UI, as most are extensions. This includes the built-in UI. The registry can be manipulated at any time, meaning you can add or remove extensions at runtime.
9+
Whether you're looking to make a single correction or a package, it is done via a file on the server that we call Umbraco Package JSON. This will be your starting point.
810

9-
To provide new UI to the backoffice, you must register them via an Extension Manifest. This can be initiated via an Umbraco Package JSON file on the server. This will be your starting point.
11+
## Umbraco-package.json
1012

11-
Declaring a new extension is done by declaring an [extension manifest](extension-manifest.md). This can be done in one of two ways:
13+
In this file, you declare a name for the Package and declare one or more [`extension manifests`](extension-manifest.md).
1214

13-
1. Via a manifest JSON file on the server.
14-
2. In a JavaScript/TypeScript file.
15+
```json
16+
{
17+
"name": "My Customizations",
18+
"extensions": [
19+
{
20+
"type": "...",
21+
"alias": "my.customization",
22+
"name": "My customization"
23+
...
24+
},
25+
...
26+
]
27+
}
28+
```
1529

16-
These two options can be combined as you like.
30+
When writing the Umbraco Package Manifest, you can use the JSON Schema located in the root of your Umbraco project. The file is called `umbraco-package-schema.json`
1731

18-
A typical use case of such is achieved by registering a single extension manifest in your Umbraco Package JSON file. This manifest would then load a JS file, that registers the rest of your extensions. Learn more about these abilities in the [bundle](../extension-types/bundle.md) or [backoffice entry point](../extension-types/backoffice-entry-point.md) articles.
32+
```json
33+
{
34+
"$schema": "../../umbraco-package-schema.json",
35+
"name": "My Customizations",
36+
"extensions": [
37+
...
38+
]
39+
}
40+
```
41+
42+
## Declare Extensions in JavaScript/TypeScript
43+
44+
Are you looking for as much help as you can get, or to make a bigger project? Then it's recommended to spend the time setting up a TypeScript Project for your Customizations. [Read more about Development Setups here](../../development-flow/).
45+
46+
TypeScript gives IntelliSense for everything, acting as documentation.
47+
48+
The following example demonstrates how you can configure your `umbraco-package.json` file to point to a single JavaScript/TypeScript file that declares all your Manifests.
49+
50+
There are two approaches for declaring Manifests in JavaScript/TypeScript. Read more about each option:
51+
52+
### [The Bundle approach](../extension-types/bundle.md)
53+
54+
The Bundle is an Extension that declares one or more Extension Manifests.
55+
56+
### [The Entry Point approach](../extension-types/backoffice-entry-point.md)
57+
58+
The Entry Point is an Extension that executes a method on startup. This can be used for different tasks, such as performing initial configuration and registering other Extension Manifests.
59+
60+
### Registration via any JavaScript code
61+
62+
Once you have running code, you can declare an Extension Manifest at any given point.
63+
64+
It's not a recommended approach, but for some cases, you may like to register and unregister Extensions on the fly. The following example shows how to register an extension manifest via JavaScript/TypeScript code:
65+
66+
```typescript
67+
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
68+
69+
const manifest = {
70+
type: '...',
71+
...
72+
};
73+
74+
umbExtensionsRegistry.register(extension);
75+
```
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
---
2-
description: The App Entry Point extension type is used to run some JavaScript code before the user is logged in.
2+
description: >-
3+
The App Entry Point extension type is used to run some JavaScript code before
4+
the user is logged in.
35
---
46

57
# App Entry Point
68

79
This manifest declares a single JavaScript file that will be loaded and run when the Backoffice starts. Additionally, the code will also run on the login screen.
810

11+
{% hint style="info" %}
12+
See [Backoffice Entry Point](backoffice-entry-point.md) if you are looking for an Extension that runs when the user is logged in.
13+
{% endhint %}
14+
915
It performs the same function as the `backofficeEntryPoint` extension type, but the difference is that this runs before the user is logged in. Use this to initiate things before the user is logged in or to provide things for the Login screen.
1016

1117
Read more about `backofficeEntryPoint` to learn how to use it:
1218

13-
{% content-ref url="./backoffice-entry-point.md" %} . {% endcontent-ref %}
19+
{% content-ref url="backoffice-entry-point.md" %}
20+
[backoffice-entry-point.md](backoffice-entry-point.md)
21+
{% endcontent-ref %}

16/umbraco-cms/customizing/extending-overview/extension-types/backoffice-entry-point.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ description: >-
88

99
This manifest declares a single JavaScript file that will be loaded and run when the Backoffice starts. In other words, this can be used as an entry point for a package.
1010

11-
The `backofficeEntryPoint` extension is also the way to go if you want to load in external libraries such as jQuery, Angular, React, etc. You can use the `backofficeEntryPoint` to load in the external libraries to be shared by all your extensions. Additionally, **global CSS files** can also be used in the `backofficeEntryPoint` extension.
12-
1311
{% hint style="info" %}
14-
See also the [App Entry Point](app-entry-point.md) article for a similar extension type that runs before the user is logged in.
12+
See [App Entry Point](app-entry-point.md) if you are looking for an Extension that runs before the user is logged in.
1513
{% endhint %}
1614

15+
The `backofficeEntryPoint` extension is also the way to go if you want to load in external libraries such as jQuery, Angular, React, etc. You can use the `backofficeEntryPoint` to load the external libraries to be shared by all your extensions. Additionally, **global CSS files** can also be used in the `backofficeEntryPoint` extension.
16+
1717
**Register a Backoffice Entry Point in the `umbraco-package.json` manifest**
1818

1919
{% code title="umbraco-package.json" %}
@@ -113,7 +113,7 @@ export const onInit: UmbEntryPointOnInit = (host, extensionsRegistry) => {
113113
```
114114
{% endcode %}
115115

116-
Alternatively, you can import the CSS file directly in your JavaScript file:
116+
Alternatively, you can import the CSS file directly into your JavaScript file:
117117

118118
{% code title="index.ts" %}
119119
```typescript
@@ -125,7 +125,7 @@ import '/App_Plugins/YourFolder/global.css';
125125

126126
It is recommended to make use of the Type intellisense that we provide.
127127

128-
When writing your Manifest in TypeScript you should use the Type `UmbExtensionManifest`, see the [TypeScript setup](broken-reference) article to make sure you have Types correctly configured.
128+
When writing your Manifest in TypeScript, you should use the `UmbExtensionManifest` type. Read the [TypeScript setup](broken-reference/) article to make sure you have Types correctly configured.
129129

130130
{% code title="index.ts" %}
131131
```typescript
@@ -156,7 +156,7 @@ See the Extension Types article for more information about all the different ext
156156
[.](./)
157157
{% endcontent-ref %}
158158

159-
Read about running code before log in using an `appEntryPoint`:
159+
Read about running code before logging in using an `appEntryPoint`:
160160

161161
{% content-ref url="app-entry-point.md" %}
162162
[app-entry-point.md](app-entry-point.md)

0 commit comments

Comments
 (0)