Skip to content

Handle existing RichTextEditorValue when parsing from markup or JSON structure #19266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Extensions;
Expand All @@ -18,12 +18,20 @@ public static class RichTextPropertyEditorHelper
/// <returns>True if the parsing succeeds, false otherwise</returns>
/// <remarks>
/// The passed value can be:
/// - a <see cref="RichTextEditorValue"/> instance (which will be the case if the rich text property is hidden from the editor).
/// - a JSON string.
/// - a JSON object.
/// - a raw markup string (for backwards compatability).
/// </remarks>
public static bool TryParseRichTextEditorValue(object? value, IJsonSerializer jsonSerializer, ILogger logger, [NotNullWhen(true)] out RichTextEditorValue? richTextEditorValue)
{
if (value is RichTextEditorValue existingRichTextEditorValue)
{
// already a RichTextEditorValue instance
richTextEditorValue = existingRichTextEditorValue;
return true;
}

var stringValue = value as string ?? value?.ToString();
if (stringValue is null)
{
Expand Down
Loading