Class RteBlockRenderingValueConverter
A value converter for TinyMCE that will ensure any blocks content are rendered properly even when used dynamically.
Namespace: Umbraco.Cms.Core.PropertyEditors.ValueConverters
Assembly: Umbraco.Infrastructure.dll
Syntax
[DefaultPropertyValueConverter]
public class RteBlockRenderingValueConverter : SimpleRichTextValueConverter, IDeliveryApiPropertyValueConverter, IPropertyValueConverter, IDiscoverable
Constructors
View SourceRteBlockRenderingValueConverter(HtmlLocalLinkParser, HtmlUrlParser, HtmlImageSourceParser, IApiRichTextElementParser, IApiRichTextMarkupParser, IPartialViewBlockEngine, BlockEditorConverter, IJsonSerializer, IApiElementBuilder, RichTextBlockPropertyValueConstructorCache, ILogger<RteBlockRenderingValueConverter>, IVariationContextAccessor, BlockEditorVarianceHandler, IOptionsMonitor<DeliveryApiSettings>)
Initializes a new instance of the RteBlockRenderingValueConverter class.
Declaration
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 19.")]
public RteBlockRenderingValueConverter(HtmlLocalLinkParser linkParser, HtmlUrlParser urlParser, HtmlImageSourceParser imageSourceParser, IApiRichTextElementParser apiRichTextElementParser, IApiRichTextMarkupParser apiRichTextMarkupParser, IPartialViewBlockEngine partialViewBlockEngine, BlockEditorConverter blockEditorConverter, IJsonSerializer jsonSerializer, IApiElementBuilder apiElementBuilder, RichTextBlockPropertyValueConstructorCache constructorCache, ILogger<RteBlockRenderingValueConverter> logger, IVariationContextAccessor variationContextAccessor, BlockEditorVarianceHandler blockEditorVarianceHandler, IOptionsMonitor<DeliveryApiSettings> deliveryApiSettingsMonitor)
Parameters
| Type | Name | Description |
|---|---|---|
| HtmlLocalLinkParser | linkParser | Parses local links within HTML content. |
| HtmlUrlParser | urlParser | Parses URLs within HTML content. |
| HtmlImageSourceParser | imageSourceParser | Parses image sources within HTML content. |
| IApiRichTextElementParser | apiRichTextElementParser | Parses rich text elements for the Delivery API. |
| IApiRichTextMarkupParser | apiRichTextMarkupParser | Parses rich text markup for the Delivery API. |
| IPartialViewBlockEngine | partialViewBlockEngine | Renders partial view blocks within rich text content. |
| BlockEditorConverter | blockEditorConverter | Converts block editor values. |
| IJsonSerializer | jsonSerializer | Serializes and deserializes JSON data. |
| IApiElementBuilder | apiElementBuilder | Builds API elements for rich text content. |
| RichTextBlockPropertyValueConstructorCache | constructorCache | Caches constructors for rich text block property values. |
| ILogger<RteBlockRenderingValueConverter> | logger | The logger used for diagnostic and error messages. |
| IVariationContextAccessor | variationContextAccessor | Provides access to the current variation context. |
| BlockEditorVarianceHandler | blockEditorVarianceHandler | Handles variance for block editors. |
| IOptionsMonitor<DeliveryApiSettings> | deliveryApiSettingsMonitor | Monitors settings for the Delivery API. |
RteBlockRenderingValueConverter(HtmlLocalLinkParser, HtmlUrlParser, HtmlImageSourceParser, IApiRichTextElementParser, IApiRichTextMarkupParser, IPartialViewBlockEngine, BlockEditorConverter, IJsonSerializer, IApiElementBuilder, RichTextBlockPropertyValueConstructorCache, ILogger<RteBlockRenderingValueConverter>, IVariationContextAccessor, BlockEditorVarianceHandler, IOptionsMonitor<DeliveryApiSettings>, ILanguageService, IPropertyRenderingContextAccessor)
Initializes a new instance of the RteBlockRenderingValueConverter class.
Declaration
public RteBlockRenderingValueConverter(HtmlLocalLinkParser linkParser, HtmlUrlParser urlParser, HtmlImageSourceParser imageSourceParser, IApiRichTextElementParser apiRichTextElementParser, IApiRichTextMarkupParser apiRichTextMarkupParser, IPartialViewBlockEngine partialViewBlockEngine, BlockEditorConverter blockEditorConverter, IJsonSerializer jsonSerializer, IApiElementBuilder apiElementBuilder, RichTextBlockPropertyValueConstructorCache constructorCache, ILogger<RteBlockRenderingValueConverter> logger, IVariationContextAccessor variationContextAccessor, BlockEditorVarianceHandler blockEditorVarianceHandler, IOptionsMonitor<DeliveryApiSettings> deliveryApiSettingsMonitor, ILanguageService languageService, IPropertyRenderingContextAccessor propertyRenderingContextAccessor)
Parameters
| Type | Name | Description |
|---|---|---|
| HtmlLocalLinkParser | linkParser | Parses local links within HTML content. |
| HtmlUrlParser | urlParser | Parses URLs within HTML content. |
| HtmlImageSourceParser | imageSourceParser | Parses image sources within HTML content. |
| IApiRichTextElementParser | apiRichTextElementParser | Parses rich text elements for the Delivery API. |
| IApiRichTextMarkupParser | apiRichTextMarkupParser | Parses rich text markup for the Delivery API. |
| IPartialViewBlockEngine | partialViewBlockEngine | Renders partial view blocks within rich text content. |
| BlockEditorConverter | blockEditorConverter | Converts block editor values. |
| IJsonSerializer | jsonSerializer | Serializes and deserializes JSON data. |
| IApiElementBuilder | apiElementBuilder | Builds API elements for rich text content. |
| RichTextBlockPropertyValueConstructorCache | constructorCache | Caches constructors for rich text block property values. |
| ILogger<RteBlockRenderingValueConverter> | logger | The logger used for diagnostic and error messages. |
| IVariationContextAccessor | variationContextAccessor | Provides access to the current variation context. |
| BlockEditorVarianceHandler | blockEditorVarianceHandler | Handles variance for block editors. |
| IOptionsMonitor<DeliveryApiSettings> | deliveryApiSettingsMonitor | Monitors settings for the Delivery API. |
| ILanguageService | languageService | Service used to retrieve language information for fallback resolution. |
| IPropertyRenderingContextAccessor | propertyRenderingContextAccessor | Accessor for the current property rendering context. |
Methods
View SourceConvertIntermediateToDeliveryApiObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool, bool)
Converts the intermediate value of a rich text editor property to an object suitable for the Delivery API.
Declaration
public object? ConvertIntermediateToDeliveryApiObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview, bool expanding)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | owner | The published element that owns the property being converted. |
| IPublishedPropertyType | propertyType | The type information for the published property. |
| PropertyCacheLevel | referenceCacheLevel | The cache level to use for property value references during conversion. |
| object | inter | The intermediate value to convert, typically an IRichTextEditorIntermediateValue. |
| bool | preview | True if the conversion is for preview mode; otherwise, false. |
| bool | expanding | True to expand nested values during conversion; otherwise, false. |
Returns
| Type | Description |
|---|---|
| object | An object representing the converted value for the Delivery API, or |
ConvertIntermediateToObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool)
Converts the intermediate value produced by the property editor into the final object representation for use in templates.
Declaration
public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | owner | The IPublishedElement that owns the property being converted. |
| IPublishedPropertyType | propertyType | The IPublishedPropertyType describing the property. |
| PropertyCacheLevel | referenceCacheLevel | The PropertyCacheLevel indicating the cache level for the property value. |
| object | inter | The intermediate value to convert, typically a string or null. |
| bool | preview | True if the conversion is for preview mode; otherwise, false. |
Returns
| Type | Description |
|---|---|
| object | An HtmlEncodedString containing the converted value, or an empty encoded string if the intermediate value is null. |
ConvertSourceToIntermediate(IPublishedElement, IPublishedPropertyType, object?, bool)
Converts the source value of a rich text editor property to an intermediate RteBlockRenderingValueConverter.RichTextEditorIntermediateValue for further processing and caching.
Declaration
public override object? ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object? source, bool preview)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | owner | The IPublishedElement that owns the property being converted. |
| IPublishedPropertyType | propertyType | The IPublishedPropertyType metadata describing the property. |
| object | source | The source value to convert, typically a JSON string or object representing the rich text editor value. |
| bool | preview | A value indicating whether the conversion is being performed in preview mode. |
Returns
| Type | Description |
|---|---|
| object | A RteBlockRenderingValueConverter.RichTextEditorIntermediateValue representing the parsed and processed rich text content, or |
Remarks
to counterweigh the cache level, we're going to do as much of the heavy lifting as we can while converting source to intermediate
Dispose()
Releases the managed resources used by the RteBlockRenderingValueConverter, including disposing the settings change subscription.
Declaration
public void Dispose()
GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType)
Gets the cache level for the delivery API for the specified property type.
Declaration
public PropertyCacheLevel GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The published property type. |
Returns
| Type | Description |
|---|---|
| PropertyCacheLevel | The property cache level. |
GetDeliveryApiPropertyCacheLevelForExpansion(IPublishedPropertyType)
Determines the PropertyCacheLevel to use when expanding the property for the Delivery API.
Declaration
public PropertyCacheLevel GetDeliveryApiPropertyCacheLevelForExpansion(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The IPublishedPropertyType representing the property being expanded. |
Returns
| Type | Description |
|---|---|
| PropertyCacheLevel | The appropriate PropertyCacheLevel for Delivery API expansion. |
GetDeliveryApiPropertyValueType(IPublishedPropertyType)
Returns the .NET System.Type that represents the value type delivered by the Delivery API for a given property type.
Declaration
public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The published property type to evaluate. |
Returns
| Type | Description |
|---|---|
| Type | The System.Type of the value returned by the Delivery API. |
GetPropertyCacheLevel(IPublishedPropertyType)
Gets the cache level for the property.
Declaration
public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The property type. |
Returns
| Type | Description |
|---|---|
| PropertyCacheLevel | The cache level for the property, which is None because the value must be re-rendered at request time.
This is necessary as the RTE converter parses |
IsValue(object?, PropertyValueLevel)
Determines whether a value is an actual value, or not a value.
Declaration
public override bool? IsValue(object? value, PropertyValueLevel level)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | |
| PropertyValueLevel | level |
Returns
| Type | Description |
|---|---|
| bool? |
Remarks
Called for Source, Inter and Object levels, until one does not return null.
Can return true (is a value), false (is not a value), or null to indicate that it cannot be determined at the specified level. For instance, if source is a string that could contain JSON, the decision could be made on the intermediate value. Or, if it is a picker, it could be made on the object value (the actual picked object).