Skip to content

Commit 4f61269

Browse files
committed
handling settings data.
1 parent 08032fb commit 4f61269

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockEditorValueConnector.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
5555
if (blockEditorValue == null)
5656
return null;
5757

58+
var allBlocks = blockEditorValue.Content.Concat(blockEditorValue.Settings);
59+
5860
// get all the content types used in block editor items
59-
var allContentTypes = blockEditorValue.Content.Select(x => x.ContentTypeKey)
61+
var allContentTypes = allBlocks.Select(x => x.ContentTypeKey)
6062
.Distinct()
6163
.ToDictionary(a => a, a =>
6264
{
@@ -77,7 +79,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
7779
dependencies.Add(new ArtifactDependency(contentType.GetUdi(), false, ArtifactDependencyMode.Match));
7880
}
7981

80-
foreach (var block in blockEditorValue.Content)
82+
foreach (var block in allBlocks)
8183
{
8284
var contentType = allContentTypes[block.ContentTypeKey];
8385

@@ -126,7 +128,9 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
126128
if (blockEditorValue == null)
127129
return value;
128130

129-
var allContentTypes = blockEditorValue.Content.Select(x => x.ContentTypeKey)
131+
var allBlocks = blockEditorValue.Content.Concat(blockEditorValue.Settings);
132+
133+
var allContentTypes = allBlocks.Select(x => x.ContentTypeKey)
130134
.Distinct()
131135
.ToDictionary(a => a, a =>
132136
{
@@ -141,7 +145,7 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
141145
throw new InvalidOperationException($"Could not resolve these content types for the Block Editor property: {string.Join(",", allContentTypes.Where(x => x.Value == null).Select(x => x.Key))}");
142146
}
143147

144-
foreach (var block in blockEditorValue.Content)
148+
foreach (var block in allBlocks)
145149
{
146150
var contentType = allContentTypes[block.ContentTypeKey];
147151

@@ -206,6 +210,20 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
206210
/// "text": "hero text",
207211
/// "contentpicker": "umb://document/87478d1efa66413698063f8d00fda1d1"
208212
/// }
213+
/// ],
214+
/// "settingsData": [
215+
/// {
216+
/// "contentTypeKey": "2e6094ea-7bca-4b7c-a223-375254a194f4",
217+
/// "udi": "umb://element/499cf69f00c84227a59ca10fb4ae4c9a",
218+
/// "textColor": "",
219+
/// "containerWidth": "standard",
220+
/// "textWidth": [],
221+
/// "height": [],
222+
/// "overlayStrength": [],
223+
/// "textAlignment": "left",
224+
/// "verticalTextAlignment": "top",
225+
/// "animate": "0"
226+
/// }
209227
/// ]
210228
/// }
211229
/// ]]>
@@ -224,6 +242,12 @@ public class BlockEditorValue
224242
/// </summary>
225243
[JsonProperty("contentData")]
226244
public IEnumerable<Block> Content { get; set; }
245+
246+
/// <summary>
247+
/// This contains the settings associated with the block editor.
248+
/// </summary>
249+
[JsonProperty("settingsData")]
250+
public IEnumerable<Block> Settings { get; set; }
227251
}
228252

229253
public class Block

0 commit comments

Comments
 (0)