Skip to content

Commit 43ab906

Browse files
authored
Merge pull request #2249 from umbraco/v14/feature/POC-dynamic-global-manifest-types
POC: feature dynamic global manifest types
2 parents a218258 + 7c62d8a commit 43ab906

File tree

44 files changed

+147
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+147
-98
lines changed

examples/block-custom-view/block-custom-view.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
22
import { html, customElement, LitElement, property, css } from '@umbraco-cms/backoffice/external/lit';
33
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
4-
import type { UmbBlockDataType, UmbBlockEditorCustomViewElement } from '@umbraco-cms/backoffice/extension-registry';
4+
import type { UmbBlockDataType } from '@umbraco-cms/backoffice/block';
5+
import type { UmbBlockEditorCustomViewElement } from '@umbraco-cms/backoffice/block-custom-view';
56

67
// eslint-disable-next-line local-rules/enforce-umb-prefix-on-element-name
78
@customElement('example-block-custom-view')

examples/block-custom-view/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { ManifestBlockEditorCustomView } from '@umbraco-cms/backoffice/extension-registry';
2-
3-
export const manifests: Array<ManifestBlockEditorCustomView> = [
1+
export const manifests: Array<UmbExtensionManifest> = [
42
{
53
type: 'blockEditorCustomView',
64
alias: 'Umb.blockEditorCustomView.TestView',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"./action": "./dist-cms/packages/core/action/index.js",
1818
"./audit-log": "./dist-cms/packages/core/audit-log/index.js",
1919
"./auth": "./dist-cms/packages/core/auth/index.js",
20+
"./block-custom-view": "./dist-cms/packages/block/block-custom-view/index.js",
2021
"./block-grid": "./dist-cms/packages/block/block-grid/index.js",
2122
"./block-list": "./dist-cms/packages/block/block-list/index.js",
2223
"./block-rte": "./dist-cms/packages/block/block-rte/index.js",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { ManifestBase } from '../types/index.js';
2+
import type { UmbApi } from './api.interface.js';
3+
4+
/**
5+
* Interface for APIs of a Extension.
6+
*/
7+
export interface UmbExtensionApi<ManifestType extends ManifestBase = ManifestBase> extends UmbApi {
8+
manifest?: ManifestType;
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './entry-point.interface.js';
22
export * from './api.interface.js';
3+
export * from './extension-api.interface.js';

src/libs/extension-api/registry/extension.registry.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { map, distinctUntilChanged, combineLatest, of, switchMap } from '@umbrac
1111

1212
/**
1313
*
14-
* @param previousValue
15-
* @param currentValue
14+
* @param previousValue {Array<ManifestBase>} - previous value
15+
* @param currentValue {Array<ManifestBase>} - current value
16+
* @returns {boolean} - true if value is assumed to be the same as previous value.
1617
*/
1718
function extensionArrayMemoization<T extends Pick<ManifestBase, 'alias'>>(
1819
previousValue: Array<T>,
@@ -31,8 +32,9 @@ function extensionArrayMemoization<T extends Pick<ManifestBase, 'alias'>>(
3132

3233
/**
3334
*
34-
* @param previousValue
35-
* @param currentValue
35+
* @param previousValue {Array<ManifestBase>} - previous value
36+
* @param currentValue {Array<ManifestBase>} - current value
37+
* @returns {boolean} - true if value is assumed to be the same as previous value.
3638
*/
3739
function extensionAndKindMatchArrayMemoization<
3840
T extends Pick<ManifestBase, 'alias'> & { __isMatchedWithKind?: boolean },
@@ -62,8 +64,9 @@ function extensionAndKindMatchArrayMemoization<
6264

6365
/**
6466
*
65-
* @param previousValue
66-
* @param currentValue
67+
* @param previousValue {Array<ManifestBase>} - previous value
68+
* @param currentValue {Array<ManifestBase>} - current value
69+
* @returns {boolean} - true if value is assumed to be the same as previous value.
6770
*/
6871
function extensionSingleMemoization<T extends Pick<ManifestBase, 'alias'>>(
6972
previousValue: T | undefined,
@@ -77,8 +80,9 @@ function extensionSingleMemoization<T extends Pick<ManifestBase, 'alias'>>(
7780

7881
/**
7982
*
80-
* @param previousValue
81-
* @param currentValue
83+
* @param previousValue {Array<ManifestBase>} - previous value
84+
* @param currentValue {Array<ManifestBase>} - current value
85+
* @returns {boolean} - true if value is assumed to be the same as previous value.
8286
*/
8387
function extensionAndKindMatchSingleMemoization<
8488
T extends Pick<ManifestBase, 'alias'> & { __isMatchedWithKind?: boolean },

src/libs/extension-api/types/manifest-bundle.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ManifestBase } from './manifest-base.interface.js';
44
/**
55
* This type of extension takes a JS module and registers all exported manifests from the pointed JS file.
66
*/
7-
export interface ManifestBundle<UmbManifestTypes extends ManifestBase = ManifestBase>
8-
extends ManifestPlainJs<{ [key: string]: Array<UmbManifestTypes> }> {
7+
export interface ManifestBundle<ManifestTypes extends ManifestBase = ManifestBase>
8+
extends ManifestPlainJs<{ [key: string]: Array<ManifestTypes> }> {
99
type: 'bundle';
1010
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
import type { UmbBlockEditorCustomViewElement } from '../interfaces/index.js';
1+
import type { UmbBlockEditorCustomViewElement } from './types.js';
22
import type { ManifestElement } from '@umbraco-cms/backoffice/extension-api';
33

44
export interface ManifestBlockEditorCustomView extends ManifestElement<UmbBlockEditorCustomViewElement> {
55
type: 'blockEditorCustomView';
66
/**
7-
* @property {string | Array<string> } - Declare if this Custom View only must appear at specific Content Types by Alias.
7+
* @property {string | Array<string> } forContentTypeAlias - Declare if this Custom View only must appear at specific Content Types by Alias.
88
* @description Optional condition if you like this custom view to only appear at for one or more specific Content Types.
99
* @example 'my-element-type-alias'
1010
* @example ['my-element-type-alias-A', 'my-element-type-alias-B']
1111
*/
1212
forContentTypeAlias?: string | Array<string>;
1313
/**
14-
* @property {string | Array<string> } - Declare if this Custom View only must appear at specific Block Editors.
14+
* @property {string | Array<string> } forBlockEditor - Declare if this Custom View only must appear at specific Block Editors.
1515
* @description Optional condition if you like this custom view to only appear at a specific type of Block Editor.
1616
* @example 'block-list'
1717
* @example ['block-list', 'block-grid']
1818
*/
1919
forBlockEditor?: string | Array<string>;
2020
}
21+
22+
declare global {
23+
interface UmbExtensionManifestMap {
24+
blockEditorCustomView: ManifestBlockEditorCustomView;
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type * from './types.js';
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
import type { ManifestBlockEditorCustomView } from '../index.js';
2-
import type { UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';
3-
// Shared with the Property Editor
4-
export interface UmbBlockTypeBaseModel {
5-
contentElementTypeKey: string;
6-
settingsElementTypeKey?: string;
7-
label?: string;
8-
thumbnail?: string;
9-
iconColor?: string;
10-
backgroundColor?: string;
11-
editorSize?: UUIModalSidebarSize;
12-
forceHideContentEditorInOverlay: boolean;
13-
}
1+
import type { ManifestBlockEditorCustomView } from './block-editor-custom-view.extension.js';
2+
import type { UmbBlockLayoutBaseModel, UmbBlockDataType } from '@umbraco-cms/backoffice/block';
3+
import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type';
144

15-
// Shared with the Property Editor
16-
export interface UmbBlockLayoutBaseModel {
17-
contentUdi: string;
18-
settingsUdi?: string | null;
19-
}
20-
21-
// Shared with the Property Editor
22-
export interface UmbBlockDataType {
23-
udi: string;
24-
contentTypeKey: string;
25-
[key: string]: unknown;
26-
}
5+
export type * from './block-editor-custom-view.extension.js';
276

287
export interface UmbBlockEditorCustomViewConfiguration {
298
editContentPath?: string;

0 commit comments

Comments
 (0)