Skip to content
Closed
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
18 changes: 4 additions & 14 deletions src/Umbraco.Community.BlockPreview/Services/BlockDataConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public IPublishedElement ConvertToElement(BlockItemData data, IPublishedElement
{
var property = data.Values.ElementAt(i);
var value = property.Value;
string? propertyAsString = value?.ToString();

if (property.EditorAlias == PropertyEditors.Aliases.RichText)
{
Expand All @@ -116,7 +115,7 @@ public IPublishedElement ConvertToElement(BlockItemData data, IPublishedElement
}
if (property.EditorAlias == PropertyEditors.Aliases.BlockGrid)
{
var blockValue = _blockGridEditorValues.DeserializeAndClean(propertyAsString);
var blockValue = _blockGridEditorValues.DeserializeAndClean(value);
if (blockValue != null)
{
FormatBlockData(blockValue.BlockValue.ContentData);
Expand All @@ -126,7 +125,7 @@ public IPublishedElement ConvertToElement(BlockItemData data, IPublishedElement
}
if (property.EditorAlias == PropertyEditors.Aliases.BlockList)
{
var blockValue = _blockListEditorValues.DeserializeAndClean(propertyAsString);
var blockValue = _blockListEditorValues.DeserializeAndClean(value);
if (blockValue != null)
{
FormatBlockData(blockValue.BlockValue.ContentData);
Expand Down Expand Up @@ -172,31 +171,22 @@ public void FormatBlockData(List<BlockItemData>? blockData)
}
}
}

else if (propertyData.EditorAlias == PropertyEditors.Aliases.BlockGrid)
{
string? propertyAsString = propertyData.Value?.ToString();
var blockValue = _blockGridEditorValues.DeserializeAndClean(propertyAsString);
var blockValue = _blockGridEditorValues.DeserializeAndClean(propertyData.Value);
if (blockValue != null)
{
FormatBlockData(blockValue.BlockValue.ContentData);
FormatBlockData(blockValue.BlockValue.SettingsData);
propertyData.Value = JsonSerializer.Serialize(blockValue.BlockValue, _jsonSerializerOptions);
}
}

else if (propertyData.EditorAlias == PropertyEditors.Aliases.BlockList)
{
string? propertyAsString = propertyData.Value?.ToString();
var blockValue = _blockListEditorValues.DeserializeAndClean(propertyAsString);
var blockValue = _blockListEditorValues.DeserializeAndClean(propertyData.Value);
if (blockValue != null)
{
FormatBlockData(blockValue.BlockValue.ContentData);
FormatBlockData(blockValue.BlockValue.SettingsData);
propertyData.Value = JsonSerializer.Serialize(blockValue.BlockValue, _jsonSerializerOptions);
}
}

else ConvertPropertyValue(propertyData);
}
}
Expand Down