Loading...
Loading...
Implement property editor UIs in Umbraco backoffice using official docs
npx skill4agent add umbraco/umbraco-cms-backoffice-skills umbraco-property-editor-ui/Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/property-editor/umbraco-umbraco-elementumbraco-state-managementumbraco-localizationWARNING: Thebelow usespropertyEditorSchemaAlias, a built-in schema. If you use a custom alias likeUmbraco.Plain.String, you MUST have a corresponding C#MyPackage.CustomSchemaon the server or you'll get a 404 error when creating a Data Type.DataEditor
{
"name": "My Property Editor",
"extensions": [
{
"type": "propertyEditorUi",
"alias": "My.PropertyEditorUi.Custom",
"name": "My Custom Editor",
"element": "/App_Plugins/MyEditor/editor.js",
"elementName": "my-editor-ui",
"meta": {
"label": "My Custom Editor",
"icon": "icon-edit",
"group": "common",
"propertyEditorSchemaAlias": "Umbraco.Plain.String"
}
}
]
}import { LitElement, html, css, customElement, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
@customElement('my-editor-ui')
export default class MyEditorElement extends UmbElementMixin(LitElement) implements UmbPropertyEditorUiElement {
@property({ type: String })
public value = '';
#onChange(e: Event) {
const input = e.target as HTMLInputElement;
this.value = input.value;
this.dispatchEvent(new UmbChangeEvent());
}
render() {
return html`
<uui-input
.value=${this.value || ''}
@change=${this.#onChange}
></uui-input>
`;
}
static styles = css`
:host {
display: block;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
'my-editor-ui': MyEditorElement;
}
}import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
@customElement('my-editor-ui')
export default class MyEditorElement extends UmbElementMixin(LitElement) implements UmbPropertyEditorUiElement {
@property({ type: String })
public value = '';
@state()
private _maxChars?: number;
@state()
private _placeholder?: string;
@property({ attribute: false })
public set config(config: UmbPropertyEditorConfigCollection) {
this._maxChars = config.getValueByAlias('maxChars');
this._placeholder = config.getValueByAlias('placeholder');
}
render() {
return html`
<uui-input
.value=${this.value || ''}
.placeholder=${this._placeholder || ''}
.maxlength=${this._maxChars}
@change=${this.#onChange}
></uui-input>
`;
}
}{
"type": "propertyEditorUi",
"alias": "My.PropertyEditorUi.Custom",
"name": "My Custom Editor",
"element": "/App_Plugins/MyEditor/editor.js",
"elementName": "my-editor-ui",
"meta": {
"label": "My Custom Editor",
"propertyEditorSchemaAlias": "Umbraco.Plain.String",
"settings": {
"properties": [
{
"alias": "maxChars",
"label": "Maximum Characters",
"propertyEditorUiAlias": "Umb.PropertyEditorUi.Integer"
},
{
"alias": "placeholder",
"label": "Placeholder Text",
"propertyEditorUiAlias": "Umb.PropertyEditorUi.TextBox"
}
],
"defaultData": [
{ "alias": "maxChars", "value": 100 }
]
}
}
}propertyEditorSchemaAlias| Part | Location | Language |
|---|---|---|
| Property Editor UI | Client | TypeScript |
| Property Editor Schema | Server | C# |
DataEditor| Schema Alias | Stores | Use Case |
|---|---|---|
| | Simple text values |
| | Numbers, ratings, counts |
| | Prices, percentages |
| | Complex JSON data |
| | Dates and times |
| | Toggles, checkboxes |
| | Textbox with validation |
| | Multi-line text |
Umbraco.Plain.Json