Boye
09/04/2023, 9:53 AMSebastiaan
09/06/2023, 9:16 AMIDeliveryApiPropertyValueConverter
in your value converter and create the POCO there
// cc: @CornΓ© Hoskam as I saw him in the discussion tooBoye
09/06/2023, 9:48 AMBoye
09/06/2023, 9:49 AMSebastiaan
09/06/2023, 9:49 AMSebastiaan
09/06/2023, 10:02 AMSebastiaan
09/06/2023, 10:03 AMBoye
09/06/2023, 10:10 AM{
"message": "Hello World!"
}
But the actual output is:
{
"message": []
}
Sebastiaan
09/06/2023, 10:11 AMBoye
09/06/2023, 10:13 AM{
"name": "Generated",
"breakpoints": [
1280
],
"elements": [
{
"index": 0,
"id": "item-hrraxv3h3",
"content": {
"en": "Hello World"
},
"style": {
"_1280": {}
},
"selected": false,
"editing": false,
"transitions": [
{
"key": ""
}
]
}
],
"version": 5,
"style": {
"width": "128rem",
"height": "96rem",
"_1280": {
"height": {
"en": "6rem"
}
}
}
}
Sebastiaan
09/06/2023, 10:13 AMSebastiaan
09/06/2023, 10:15 AMjson
"style": {
"_1280": {}
},
Boye
09/06/2023, 10:15 AMBoye
09/06/2023, 10:16 AMBoye
09/06/2023, 10:17 AMtype Style = Record<string, string | Record<string, string | Record<string, string>>>
in typescriptSebastiaan
09/06/2023, 2:29 PMSebastiaan
09/06/2023, 2:45 PMSebastiaan
09/06/2023, 2:57 PMcsharp
using System.Text.Json.Nodes;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors;
public class SampleEditorValueConverter : IPropertyValueConverter
{
public bool IsConverter(IPublishedPropertyType propertyType)
{
return propertyType.EditorAlias.Equals("SampleEditor");
}
public bool? IsValue(object? value, PropertyValueLevel level)
{
return true;
}
public Type GetPropertyValueType(IPublishedPropertyType propertyType)
{
return typeof(IPublishedContent);
}
public PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
{
return PropertyCacheLevel.Element;
}
public object? ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType,
object? source, bool preview)
{
if (source == null) return null;
var jsonValue = JsonNode.Parse(source.ToString() ?? string.Empty);
return jsonValue;
}
public object? ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType,
PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
{
return inter ?? null;
}
public object? ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType,
PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
{
return inter?.ToString();
}
}
Sebastiaan
09/06/2023, 2:59 PMreturn propertyType.EditorAlias.Equals("SampleEditor");
to your custom editor's alias though. The highlighted one in the screenshot.Boye
09/07/2023, 6:25 AMSebastiaan
09/07/2023, 7:16 AM