Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ export const manifests: Array<UmbExtensionManifest> = [
group: 'common',
propertyEditorSchemaAlias: 'Umbraco.Label',
supportsReadOnly: true,
settings: {
properties: [
{
alias: 'labelTemplate',
label: 'Label template',
description: 'Enter a template for the label.',
propertyEditorUiAlias: 'Umb.PropertyEditorUi.TextBox',
},
],
},
},
},
labelSchemaManifest,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import { html, customElement, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { customElement, html, property, state, when } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';

/**
* @element umb-property-editor-ui-label
*/
@customElement('umb-property-editor-ui-label')
export class UmbPropertyEditorUILabelElement extends UmbLitElement implements UmbPropertyEditorUiElement {
@property()
value = '';
@state()
private _labelTemplate?: string;

@property()
description = '';
value = '';

@property({ attribute: false })
public config?: UmbPropertyEditorConfigCollection;
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
this._labelTemplate = config?.getValueByAlias('labelTemplate');
}

override render() {
return html`${this.value ?? ''}`;
return when(
this._labelTemplate?.length,
() => html`<umb-ufm-render inline .markdown=${this._labelTemplate} .value=${this.value}></umb-ufm-render>`,
() => html`${this.value ?? ''}`,
);
}

static override styles = [UmbTextStyles];
}

export default UmbPropertyEditorUILabelElement;
Expand Down
11 changes: 11 additions & 0 deletions src/Umbraco.Web.UI.Client/src/packages/ufm/filters/bytes.filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { UmbUfmFilterBase } from './base.filter.js';
import { formatBytes } from '@umbraco-cms/backoffice/utils';

class UmbUfmBytesFilterApi extends UmbUfmFilterBase {
filter(str?: string, decimals?: number, kilo?: number, culture?: string): string {
if (!str?.length) return '';
return formatBytes(Number(str), { decimals, kilo, culture });
}
}

export { UmbUfmBytesFilterApi as api };
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export const manifests: Array<ManifestUfmFilter> = [
api: () => import('./fallback.filter.js'),
meta: { alias: 'fallback' },
},
{
type: 'ufmFilter',
alias: 'Umb.Filter.Bytes',
name: 'Bytes UFM Filter',
api: () => import('./bytes.filter.js'),
meta: { alias: 'bytes' },
},
{
type: 'ufmFilter',
alias: 'Umb.Filter.Lowercase',
Expand Down
Loading