In Umbraco 13 we create a custom property editor, which re-used configuration from MNTP, but a different property editor to implement a different reference via GetReferences() instead of default reference.
In Umbraco 17 it looks something like this:
[DataEditor(
//name: "Alternative Page Relation Picker",
alias: Constants.PropertyEditors.Aliases.AlternativePageRelationPicker,
//view: "contentpicker",
//Icon = "icon-mindmap",
ValueType = ValueTypes.Text)
//Group = Umbraco.Cms.Core.Constants.PropertyEditors.Groups.Pickers)
]
public class AlternativePageRelationPickerPropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
public AlternativePageRelationPickerPropertyEditor(
IDataValueEditorFactory dataValueEditorFactory,
IIOHelper ioHelper)
: base(dataValueEditorFactory)
{
_ioHelper = ioHelper;
SupportsReadOnly = true;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() =>
new MultiNodePickerConfigurationEditor(_ioHelper); // Just reuse the MNTP configuration.
protected override IDataValueEditor CreateValueEditor() =>
DataValueEditorFactory.Create<AlternativePageRelationPickerPropertyValueEditor>(Attribute!);
public class AlternativePageRelationPickerPropertyValueEditor : DataValueEditor, IDataValueReferenceFactory, IDataValueReference
{
public AlternativePageRelationPickerPropertyValueEditor(
IShortStringHelper shortStringHelper,
IJsonSerializer jsonSerializer,
IIOHelper ioHelper,
DataEditorAttribute attribute)
: base(shortStringHelper, jsonSerializer, ioHelper, attribute)
{
}
public IDataValueReference GetDataValueReference() => this;
public IEnumerable<string> GetAutomaticRelationTypesAliases() => [Constants.RelationTypes.RelatedAlternativePageAlias];
public bool IsForEditor(IDataEditor? dataEditor) => dataEditor?.Alias == Constants.PropertyEditors.Aliases.AlternativePageRelationPicker;
public IEnumerable<UmbracoEntityReference> GetReferences(object? value)
{
var asString = value == null ? string.Empty : value is string str ? str : value.ToString();
if (string.IsNullOrEmpty(asString))
{
yield break;
}
var udiPaths = asString!.Split(',');
foreach (var udiPath in udiPaths)
{
if (UdiParser.TryParse(udiPath, out Udi? udi))
{
yield return new UmbracoEntityReference(udi, Constants.RelationTypes.RelatedAlternativePageAlias);
}
}
}
}
}
However view is moved to client side, so we have something like this:
import { MCB_ALTERNATIVE_PAGE_RELATION_PICKER_PROPERTY_EDITOR_UI_ALIAS } from './constants.js';
import { manifest as schemaManifest } from './property-editor-schema.js';
export const manifests: Array<UmbExtensionManifest> = [
{
type: 'propertyEditorUi',
alias: MCB_ALTERNATIVE_PAGE_RELATION_PICKER_PROPERTY_EDITOR_UI_ALIAS,
name: 'Alternative Page Relation Picker Property Editor UI',
element: () => import('./alternative-page-relation-picker.element.js'),
meta: {
label: 'Alternative Page Relation Picker',
propertyEditorSchemaAlias: 'MCB.AlternativePageRelationPicker',
icon: 'icon-mindmap',
group: 'pickers',
supportsReadOnly: true,
settings: {
properties: [
{
alias: 'filter',
label: 'Allow items of type',
description: 'Select the applicable types',
propertyEditorUiAlias: 'Umb.PropertyEditorUi.ContentPicker.SourceType',
},
],
},
},
},
schemaManifest,
];
Is there any way to re-use umb-property-editor-ui-document-picker?
I tried elementName: "umb-property-editor-ui-document-picker", but it seems requiring to import this component, which I think isn’t exported in modules - or if we could create a custom property editor UI extending UmbPropertyEditorUIDocumentPickerElement, but I think this isn’t available in modules either.
We can implement <umb-input-document> as suggested in linked post below and used inside the core property editor UI, but it probably requires to implement much of the same logic.
Is there a better/simpler approach to reuse property editor UI, when one just want a slightly different change backend wise, in this case different implementation of GetReferences() and GetAutomaticRelationTypesAliases() in data value editor?
@warren asked a similar question here:


