umbraco-property-editor-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUmbraco Property Editor UI
Umbraco 属性编辑器UI
What is it?
什么是属性编辑器UI?
A Property Editor UI is the visual component that users interact with in the Umbraco backoffice to input and manage content data. It's one half of a property editor - the UI (client-side TypeScript) pairs with a Schema (server-side C#) that defines data storage.
属性编辑器UI是用户在Umbraco后台中与之交互的可视化组件,用于输入和管理内容数据。它是属性编辑器的组成部分之一——UI(客户端TypeScript)与定义数据存储的Schema(服务器端C#)配对使用。
Documentation
文档资料
Always fetch the latest docs before implementing:
- Main docs: https://docs.umbraco.com/umbraco-cms/customizing/property-editors
- Tutorial: https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-property-editor
- Configuration: https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-property-editor/adding-configuration-to-a-property-editor
- Foundation: https://docs.umbraco.com/umbraco-cms/customizing/foundation
- Extension Registry: https://docs.umbraco.com/umbraco-cms/customizing/extending-overview/extension-registry
在实现前请务必获取最新文档:
- 主文档:https://docs.umbraco.com/umbraco-cms/customizing/property-editors
- 教程:https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-property-editor
- 配置说明:https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-property-editor/adding-configuration-to-a-property-editor
- 基础框架:https://docs.umbraco.com/umbraco-cms/customizing/foundation
- 扩展注册表:https://docs.umbraco.com/umbraco-cms/customizing/extending-overview/extension-registry
Reference Example
参考示例
The Umbraco source includes a working example:
Location:
/Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/property-editor/This example demonstrates a complete property editor UI implementation with configuration. Study this for production patterns.
Umbraco源码中包含一个可用示例:
位置:
/Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/property-editor/该示例展示了一个完整的带配置的属性编辑器UI实现。可参考此示例学习生产环境中的开发模式。
Related Foundation Skills
相关基础技能
-
Umbraco Element: When implementing the UI element with UmbElementMixin
- Reference skill:
umbraco-umbraco-element
- Reference skill:
-
State Management: When implementing reactive value updates
- Reference skill:
umbraco-state-management
- Reference skill:
-
Localization: When adding multi-language support to labels
- Reference skill:
umbraco-localization
- Reference skill:
-
Umbraco Element:使用UmbElementMixin实现UI元素时
- 参考技能:
umbraco-umbraco-element
- 参考技能:
-
状态管理:实现响应式值更新时
- 参考技能:
umbraco-state-management
- 参考技能:
-
本地化:为标签添加多语言支持时
- 参考技能:
umbraco-localization
- 参考技能:
Workflow
工作流程
- Fetch docs - Use WebFetch on the URLs above
- Ask questions - What data type? What UI components needed? Configuration options?
- Generate files - Create manifest + element based on latest docs
- Explain - Show what was created and how to test
- 获取文档 - 使用WebFetch访问上述URL
- 明确需求 - 确定数据类型?需要哪些UI组件?配置选项有哪些?
- 生成文件 - 根据最新文档创建清单(manifest)和元素文件
- 说明解释 - 展示创建的内容以及测试方法
Minimal Examples
最简示例
Manifest (umbraco-package.json)
清单文件(umbraco-package.json)
WARNING: 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
json
{
"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"
}
}
]
}警告: 下方的使用了内置的SchemapropertyEditorSchemaAlias。 如果使用自定义别名如Umbraco.Plain.String,则必须在服务器端有对应的C#MyPackage.CustomSchema类,否则在创建数据类型时会出现404错误。DataEditor
json
{
"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"
}
}
]
}Element Implementation (editor.ts)
元素实现(editor.ts)
typescript
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;
}
}typescript
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;
}
}With Configuration
带配置的实现
typescript
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>
`;
}
}typescript
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>
`;
}
}Configuration in Manifest
清单中的配置
json
{
"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 }
]
}
}
}json
{
"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 }
]
}
}
}Built-in Schema Aliases (Safe Defaults)
内置Schema别名(安全默认值)
The in your manifest must reference a schema that exists on the server:
propertyEditorSchemaAlias| Part | Location | Language |
|---|---|---|
| Property Editor UI | Client | TypeScript |
| Property Editor Schema | Server | C# |
- Built-in schemas (listed below) are always available - use these for simple storage needs
- Custom schemas require a C# class - only needed for custom validation/conversion
DataEditor
These built-in schemas are always available:
| 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 |
清单中的必须引用服务器端已存在的Schema:
propertyEditorSchemaAlias| 组件 | 位置 | 语言 |
|---|---|---|
| 属性编辑器UI | 客户端 | TypeScript |
| 属性编辑器Schema | 服务器端 | C# |
- 内置Schema(如下所列)始终可用——适用于简单存储需求
- 自定义Schema需要对应的C# 类——仅在需要自定义验证/转换时使用
DataEditor
以下是始终可用的内置Schema:
| Schema别名 | 存储类型 | 使用场景 |
|---|---|---|
| | 简单文本值 |
| | 数字、评分、计数 |
| | 价格、百分比 |
| | 复杂JSON数据 |
| | 日期和时间 |
| | 开关、复选框 |
| | 带验证的文本框 |
| | 多行文本 |
Troubleshooting
故障排除
See TROUBLESHOOTING.md for common issues including:
- 404 errors when creating Data Types
- Values not persisting with
Umbraco.Plain.Json
See UUI-GOTCHAS.md for UUI component issues (combobox, input, etc.).
That's it! Always fetch fresh docs, keep examples minimal, generate complete working code.
请查看TROUBLESHOOTING.md了解常见问题,包括:
- 创建数据类型时出现404错误
- 使用时值无法持久化
Umbraco.Plain.Json
请查看UUI-GOTCHAS.md了解UUI组件相关问题(如下拉框、输入框等)。
以上就是全部内容!请务必获取最新文档,保持示例简洁,生成可运行的完整代码。