Skip to content

Commit e0d1267

Browse files
committed
Loosen the RTEValue datacontract to improve migrations (#18349)
1 parent 649cfca commit e0d1267

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Umbraco.Infrastructure/Models/RichTextEditorValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public class RichTextEditorValue
1010
public required string Markup { get; set; }
1111

1212
[DataMember(Name = "blocks")]
13-
public required RichTextBlockValue? Blocks { get; set; }
13+
public RichTextBlockValue? Blocks { get; set; }
1414
}

tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ public void Can_Parse_JObject()
9494
});
9595
}
9696

97+
[Test]
98+
public void Can_Parse_JObject_With_Missing_Blocks()
99+
{
100+
var input = JsonNode.Parse(""""
101+
{
102+
"markup": "<h2>Vælg et af vores mest populære produkter</h2>"
103+
}
104+
"""");
105+
106+
var result = RichTextPropertyEditorHelper.TryParseRichTextEditorValue(input, JsonSerializer(), Logger(), out RichTextEditorValue? value);
107+
Assert.IsTrue(result);
108+
Assert.IsNotNull(value);
109+
Assert.AreEqual("<h2>Vælg et af vores mest populære produkter</h2>", value.Markup);
110+
Assert.IsNull(value.Blocks);
111+
}
112+
97113
[Test]
98114
public void Can_Parse_Blocks_With_Both_Content_And_Settings()
99115
{

0 commit comments

Comments
 (0)