#15568 fixed by adding IRichTextEditorIntermediateValue

This commit is contained in:
Markus Johansson
2024-01-29 10:05:23 +01:00
committed by Michael Latouche
parent 5d0486fddc
commit 2221c4f1c7
2 changed files with 17 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
using Umbraco.Cms.Core.Models.Blocks;
namespace Umbraco.Cms.Core.PropertyEditors;
/// <summary>
/// Models Intermediate Value for Rich Text Editors Property Value Converter.
/// </summary>
public interface IRichTextEditorIntermediateValue
{
public string Markup { get; }
public RichTextBlockModel? RichTextBlockModel { get; }
}

View File

@@ -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; }