ICanCSharp
09/25/2024, 11:40 AMleekelleher
09/25/2024, 4:35 PMUmbUfmComponentBase
base class doesn't have access to the consumeContext()
method, as it's used to make the mapping between the UFM syntax and a web component, (UmbUfmComponentBase
is not a web component in itself).
The way to do this would be to create a class that extends the UmbUfmElementBase
base class, as that does have access to Umbraco's context API.
For an example, see how it's done for the built-in `UmbUfmLabelValueElement`:
https://github.com/umbraco/Umbraco.CMS.Backoffice/blob/v14.3.0-rc/src/packages/ufm/components/label-value/label-value.element.ts
As for a code snippet, here's something that may help. First import the Block context.
import { UMB_BLOCK_ENTRY_CONTEXT } from '@umbraco-cms/backoffice/block';
Then in the constructor, consume the Block context.
constructor() {
super();
this.consumeContext(UMB_BLOCK_ENTRY_CONTEXT, (context) => {
this.observe(
context.content,
(content) => {
console.log('UMB_BLOCK_ENTRY_CONTEXT.content', content);
},
'_observeBlockContent',
);
});
}
Hope this helps.ICanCSharp
09/26/2024, 5:14 AMICanCSharp
09/26/2024, 6:56 AMICanCSharp
09/26/2024, 6:56 AMICanCSharp
10/08/2024, 5:32 AM