Loading...
Loading...
Implement property actions in Umbraco backoffice using official docs
npx skill4agent add umbraco/umbraco-cms-backoffice-skills umbraco-property-actionumbraco-context-apiumbraco-modalsimport type { ManifestPropertyAction } from '@umbraco-cms/backoffice/extension-registry';
const manifest: ManifestPropertyAction = {
type: 'propertyAction',
alias: 'My.PropertyAction.Clear',
name: 'Clear Value',
api: () => import('./clear-action.js'),
forPropertyEditorUis: ['Umb.PropertyEditorUi.TextBox', 'Umb.PropertyEditorUi.TextArea'],
meta: {
icon: 'icon-trash',
label: 'Clear',
},
weight: 100,
};
export const manifests = [manifest];import { UmbPropertyActionBase } from '@umbraco-cms/backoffice/property-action';
import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
export class ClearPropertyAction extends UmbPropertyActionBase {
constructor(host: UmbControllerHost, args: any) {
super(host, args);
}
async execute() {
const propertyContext = await this.getContext(UMB_PROPERTY_CONTEXT);
propertyContext?.setValue('');
}
}
export default ClearPropertyAction;import { UmbPropertyActionBase } from '@umbraco-cms/backoffice/property-action';
import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property';
export class UppercasePropertyAction extends UmbPropertyActionBase {
async execute() {
const propertyContext = await this.getContext(UMB_PROPERTY_CONTEXT);
const currentValue = propertyContext?.getValue() as string;
if (currentValue) {
propertyContext?.setValue(currentValue.toUpperCase());
}
}
}
export default UppercasePropertyAction;import { UmbPropertyActionBase } from '@umbraco-cms/backoffice/property-action';
import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property';
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
export class PickerPropertyAction extends UmbPropertyActionBase {
async execute() {
const propertyContext = await this.getContext(UMB_PROPERTY_CONTEXT);
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
const modal = modalManager.open(this, MY_PICKER_MODAL, {
data: {
currentValue: propertyContext?.getValue(),
},
});
const result = await modal.onSubmit();
if (result?.value) {
propertyContext?.setValue(result.value);
}
}
}
export default PickerPropertyAction;const manifest: ManifestPropertyAction = {
type: 'propertyAction',
alias: 'My.PropertyAction.Copy',
name: 'Copy to Clipboard',
api: () => import('./copy-action.js'),
// Omit forPropertyEditorUis to target all editors
meta: {
icon: 'icon-documents',
label: 'Copy',
},
};Umb.PropertyEditorUi.TextBoxUmb.PropertyEditorUi.TextAreaUmb.PropertyEditorUi.RichTextUmb.PropertyEditorUi.IntegerUmb.PropertyEditorUi.DecimalUmb.PropertyEditorUi.ContentPickerUmb.PropertyEditorUi.MediaPicker