block context

This commit is contained in:
Niels Lyngsø
2024-01-03 09:57:11 +01:00
parent 4dc1e7a5f0
commit 391404149b
2 changed files with 32 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ export class UmbBlockManagerContext<
}
constructor(host: UmbControllerHost) {
super(host, UMB_BLOCK_MANAGER_CONTEXT_TOKEN);
super(host, UMB_BLOCK_MANAGER_CONTEXT);
}
blockTypeOf(contentElementTypeKey: string) {
@@ -57,6 +57,6 @@ export class UmbBlockManagerContext<
}
}
export const UMB_BLOCK_MANAGER_CONTEXT_TOKEN = new UmbContextToken<UmbBlockManagerContext, UmbBlockManagerContext>(
export const UMB_BLOCK_MANAGER_CONTEXT = new UmbContextToken<UmbBlockManagerContext, UmbBlockManagerContext>(
'UmbBlockManagerContext',
);

View File

@@ -0,0 +1,30 @@
import type { UmbBlockTypeBase } from '../block-type/types.js';
import type { UmbBlockLayoutBaseModel, UmbBlockDataType } from './types.js';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
export class UmbBlockContext<
BlockType extends UmbBlockTypeBase = UmbBlockTypeBase,
BlockLayoutType extends UmbBlockLayoutBaseModel = UmbBlockLayoutBaseModel,
> extends UmbContextBase<UmbBlockContext> {
//
#config = new UmbObjectState<BlockType | undefined>(undefined);
public readonly config = this.#config.asObservable();
#layout = new UmbObjectState<BlockLayoutType | undefined>(undefined);
public readonly layout = this.#layout.asObservable();
#content = new UmbObjectState<UmbBlockDataType | undefined>(undefined);
public readonly content = this.#content.asObservable();
#setting = new UmbObjectState<UmbBlockDataType | undefined>(undefined);
public readonly setting = this.#setting.asObservable();
constructor(host: UmbControllerHost) {
super(host, UMB_BLOCK_CONTEXT);
}
}
export const UMB_BLOCK_CONTEXT = new UmbContextToken<UmbBlockContext, UmbBlockContext>('UmbBlockContext');