Skip to content

Commit b56c611

Browse files
author
Claus
authored
Merge pull request #43 from umbraco/v3/feature/blockeditor-updated-schema
Update to use new JSON content schema from CMS core 8.7
2 parents b61856b + 4f61269 commit b56c611

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

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

Lines changed: 33 additions & 8 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.Data.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.Data)
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.Data.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.Data)
148+
foreach (var block in allBlocks)
145149
{
146150
var contentType = allContentTypes[block.ContentTypeKey];
147151

@@ -194,18 +198,32 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
194198
/// "layout": {
195199
/// "Umbraco.BlockList": [
196200
/// {
197-
/// "udi": "umb://element/b401bb800a4a48f79786d5079bc47718"
201+
/// "contentUdi": "umb://element/b401bb800a4a48f79786d5079bc47718"
198202
/// }
199203
/// ]
200204
/// },
201-
/// "data": [
205+
/// "contentData": [
202206
/// {
203207
/// "contentTypeKey": "5fe26fff-7163-4805-9eca-960b1f106bb9",
204208
/// "udi": "umb://element/b401bb800a4a48f79786d5079bc47718",
205209
/// "image": "umb://media/e28a0070890848079d5781774c3c5ffb",
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
/// ]]>
@@ -222,14 +240,21 @@ public class BlockEditorValue
222240
/// <summary>
223241
/// This contains all the blocks created in the block editor.
224242
/// </summary>
225-
[JsonProperty("data")]
226-
public IEnumerable<Block> Data { get; set; }
243+
[JsonProperty("contentData")]
244+
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
230254
{
231255
[JsonProperty("contentTypeKey")]
232256
public string ContentTypeKey { get; set; }
257+
233258
[JsonProperty("udi")]
234259
public string Udi { get; set; }
235260

0 commit comments

Comments
 (0)