@@ -123,52 +123,58 @@ public override object ToEditor(Property property, IDataTypeService dataTypeServ
123
123
if ( blockEditorData == null )
124
124
return string . Empty ;
125
125
126
- foreach ( var row in blockEditorData . BlockValue . ContentData )
126
+ void MapBlockItemData ( List < BlockItemData > items )
127
127
{
128
- foreach ( var prop in row . PropertyValues )
128
+ foreach ( var row in items )
129
129
{
130
- // create a temp property with the value
131
- // - force it to be culture invariant as the block editor can't handle culture variant element properties
132
- prop . Value . PropertyType . Variations = ContentVariation . Nothing ;
133
- var tempProp = new Property ( prop . Value . PropertyType ) ;
134
- tempProp . SetValue ( prop . Value . Value ) ;
135
-
136
- var propEditor = _propertyEditors [ prop . Value . PropertyType . PropertyEditorAlias ] ;
137
- if ( propEditor == null )
130
+ foreach ( var prop in row . PropertyValues )
138
131
{
139
- // NOTE: This logic was borrowed from Nested Content and I'm unsure why it exists.
140
- // if the property editor doesn't exist I think everything will break anyways?
141
- // update the raw value since this is what will get serialized out
142
- row . RawPropertyValues [ prop . Key ] = tempProp . GetValue ( ) ? . ToString ( ) ;
143
- continue ;
144
- }
132
+ // create a temp property with the value
133
+ // - force it to be culture invariant as the block editor can't handle culture variant element properties
134
+ prop . Value . PropertyType . Variations = ContentVariation . Nothing ;
135
+ var tempProp = new Property ( prop . Value . PropertyType ) ;
136
+ tempProp . SetValue ( prop . Value . Value ) ;
137
+
138
+ var propEditor = _propertyEditors [ prop . Value . PropertyType . PropertyEditorAlias ] ;
139
+ if ( propEditor == null )
140
+ {
141
+ // NOTE: This logic was borrowed from Nested Content and I'm unsure why it exists.
142
+ // if the property editor doesn't exist I think everything will break anyways?
143
+ // update the raw value since this is what will get serialized out
144
+ row . RawPropertyValues [ prop . Key ] = tempProp . GetValue ( ) ? . ToString ( ) ;
145
+ continue ;
146
+ }
145
147
146
- var dataType = dataTypeService . GetDataType ( prop . Value . PropertyType . DataTypeId ) ;
147
- if ( dataType == null )
148
- {
149
- // deal with weird situations by ignoring them (no comment)
150
- row . PropertyValues . Remove ( prop . Key ) ;
151
- _logger . Warn < BlockEditorPropertyValueEditor , string , Guid , string > (
152
- "ToEditor removed property value {PropertyKey} in row {RowId} for property type {PropertyTypeAlias}" ,
153
- prop . Key , row . Key , property . PropertyType . Alias ) ;
154
- continue ;
155
- }
148
+ var dataType = dataTypeService . GetDataType ( prop . Value . PropertyType . DataTypeId ) ;
149
+ if ( dataType == null )
150
+ {
151
+ // deal with weird situations by ignoring them (no comment)
152
+ row . PropertyValues . Remove ( prop . Key ) ;
153
+ _logger . Warn < BlockEditorPropertyValueEditor , string , Guid , string > (
154
+ "ToEditor removed property value {PropertyKey} in row {RowId} for property type {PropertyTypeAlias}" ,
155
+ prop . Key , row . Key , property . PropertyType . Alias ) ;
156
+ continue ;
157
+ }
156
158
157
- if ( ! valEditors . TryGetValue ( dataType . Id , out var valEditor ) )
158
- {
159
- var tempConfig = dataType . Configuration ;
160
- valEditor = propEditor . GetValueEditor ( tempConfig ) ;
159
+ if ( ! valEditors . TryGetValue ( dataType . Id , out var valEditor ) )
160
+ {
161
+ var tempConfig = dataType . Configuration ;
162
+ valEditor = propEditor . GetValueEditor ( tempConfig ) ;
161
163
162
- valEditors . Add ( dataType . Id , valEditor ) ;
163
- }
164
+ valEditors . Add ( dataType . Id , valEditor ) ;
165
+ }
164
166
165
- var convValue = valEditor . ToEditor ( tempProp , dataTypeService ) ;
167
+ var convValue = valEditor . ToEditor ( tempProp , dataTypeService ) ;
166
168
167
- // update the raw value since this is what will get serialized out
168
- row . RawPropertyValues [ prop . Key ] = convValue ;
169
+ // update the raw value since this is what will get serialized out
170
+ row . RawPropertyValues [ prop . Key ] = convValue ;
171
+ }
169
172
}
170
173
}
171
174
175
+ MapBlockItemData ( blockEditorData . BlockValue . ContentData ) ;
176
+ MapBlockItemData ( blockEditorData . BlockValue . SettingsData ) ;
177
+
172
178
// return json convertable object
173
179
return blockEditorData . BlockValue ;
174
180
}
@@ -198,28 +204,35 @@ public override object FromEditor(ContentPropertyData editorValue, object curren
198
204
if ( blockEditorData == null || blockEditorData . BlockValue . ContentData . Count == 0 )
199
205
return string . Empty ;
200
206
201
- foreach ( var row in blockEditorData . BlockValue . ContentData )
207
+ void MapBlockItemData ( List < BlockItemData > items )
202
208
{
203
- foreach ( var prop in row . PropertyValues )
209
+ foreach ( var row in items )
204
210
{
205
- // Fetch the property types prevalue
206
- var propConfiguration = _dataTypeService . GetDataType ( prop . Value . PropertyType . DataTypeId ) . Configuration ;
211
+ foreach ( var prop in row . PropertyValues )
212
+ {
213
+ // Fetch the property types prevalue
214
+ var propConfiguration = _dataTypeService . GetDataType ( prop . Value . PropertyType . DataTypeId )
215
+ . Configuration ;
207
216
208
- // Lookup the property editor
209
- var propEditor = _propertyEditors [ prop . Value . PropertyType . PropertyEditorAlias ] ;
210
- if ( propEditor == null ) continue ;
217
+ // Lookup the property editor
218
+ var propEditor = _propertyEditors [ prop . Value . PropertyType . PropertyEditorAlias ] ;
219
+ if ( propEditor == null ) continue ;
211
220
212
- // Create a fake content property data object
213
- var contentPropData = new ContentPropertyData ( prop . Value . Value , propConfiguration ) ;
221
+ // Create a fake content property data object
222
+ var contentPropData = new ContentPropertyData ( prop . Value . Value , propConfiguration ) ;
214
223
215
- // Get the property editor to do it's conversion
216
- var newValue = propEditor . GetValueEditor ( ) . FromEditor ( contentPropData , prop . Value . Value ) ;
224
+ // Get the property editor to do it's conversion
225
+ var newValue = propEditor . GetValueEditor ( ) . FromEditor ( contentPropData , prop . Value . Value ) ;
217
226
218
- // update the raw value since this is what will get serialized out
219
- row . RawPropertyValues [ prop . Key ] = newValue ;
227
+ // update the raw value since this is what will get serialized out
228
+ row . RawPropertyValues [ prop . Key ] = newValue ;
229
+ }
220
230
}
221
231
}
222
232
233
+ MapBlockItemData ( blockEditorData . BlockValue . ContentData ) ;
234
+ MapBlockItemData ( blockEditorData . BlockValue . SettingsData ) ;
235
+
223
236
// return json
224
237
return JsonConvert . SerializeObject ( blockEditorData . BlockValue ) ;
225
238
}
0 commit comments