diff --git a/src/Umbraco.Core/PropertyEditors/IRichTextEditorIntermediateValue.cs b/src/Umbraco.Core/PropertyEditors/IRichTextEditorIntermediateValue.cs new file mode 100644 index 0000000000..24bdb25fb6 --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/IRichTextEditorIntermediateValue.cs @@ -0,0 +1,13 @@ +using Umbraco.Cms.Core.Models.Blocks; + +namespace Umbraco.Cms.Core.PropertyEditors; + +/// +/// Models Intermediate Value for Rich Text Editors Property Value Converter. +/// +public interface IRichTextEditorIntermediateValue +{ + public string Markup { get; } + + public RichTextBlockModel? RichTextBlockModel { get; } +} diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs index 06ec417c4c..c8785d2053 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs @@ -156,7 +156,7 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel public object? ConvertIntermediateToDeliveryApiObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview, bool expanding) { - if (inter is not RichTextEditorIntermediateValue richTextEditorIntermediateValue + if (inter is not IRichTextEditorIntermediateValue richTextEditorIntermediateValue || richTextEditorIntermediateValue.Markup.IsNullOrWhiteSpace()) { // different return types for the JSON configuration forces us to have different return values for empty properties @@ -201,7 +201,7 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel private string? Convert(object? source, bool preview) { - if (source is not RichTextEditorIntermediateValue intermediateValue) + if (source is not IRichTextEditorIntermediateValue intermediateValue) { return null; } @@ -291,7 +291,7 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel return RichTextParsingRegexes.BlockRegex().Replace(source, RenderBlock); } - private RichTextModel CreateRichTextModel(RichTextEditorIntermediateValue richTextEditorIntermediateValue) + private RichTextModel CreateRichTextModel(IRichTextEditorIntermediateValue richTextEditorIntermediateValue) { var markup = _apiRichTextMarkupParser.Parse(richTextEditorIntermediateValue.Markup); @@ -308,7 +308,7 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel }; } - private class RichTextEditorIntermediateValue + private class RichTextEditorIntermediateValue : IRichTextEditorIntermediateValue { public required string Markup { get; set; }