@@ -274,6 +274,70 @@ public override IEnumerable<Guid> ConfiguredElementTypeKeys()
274274 return configuration ? . Blocks ? . SelectMany ( ConfiguredElementTypeKeys ) ?? Enumerable . Empty < Guid > ( ) ;
275275 }
276276
277+ internal override object ? MergeVariantInvariantPropertyValue (
278+ object ? sourceValue ,
279+ object ? targetValue ,
280+ bool canUpdateInvariantData ,
281+ HashSet < string > allowedCultures )
282+ {
283+ TryParseEditorValue ( sourceValue , out RichTextEditorValue ? sourceRichTextEditorValue ) ;
284+ TryParseEditorValue ( targetValue , out RichTextEditorValue ? targetRichTextEditorValue ) ;
285+
286+ var mergedBlockValue = MergeBlockVariantInvariantData (
287+ sourceRichTextEditorValue ? . Blocks ,
288+ targetRichTextEditorValue ? . Blocks ,
289+ canUpdateInvariantData ,
290+ allowedCultures ) ;
291+
292+ var mergedMarkupValue = MergeMarkupValue (
293+ sourceRichTextEditorValue ? . Markup ?? string . Empty ,
294+ targetRichTextEditorValue ? . Markup ?? string . Empty ,
295+ mergedBlockValue ,
296+ canUpdateInvariantData ) ;
297+
298+ var mergedEditorValue = new RichTextEditorValue { Markup = mergedMarkupValue , Blocks = mergedBlockValue } ;
299+ return RichTextPropertyEditorHelper . SerializeRichTextEditorValue ( mergedEditorValue , _jsonSerializer ) ;
300+ }
301+
302+ private string MergeMarkupValue (
303+ string source ,
304+ string target ,
305+ RichTextBlockValue ? mergedBlockValue ,
306+ bool canUpdateInvariantData )
307+ {
308+ // pick source or target based on culture permissions
309+ var mergedMarkup = canUpdateInvariantData ? target : source ;
310+
311+ // todo? strip all invalid block links from markup, those tat are no longer in the layout
312+ return mergedMarkup ;
313+ }
314+
315+ private RichTextBlockValue ? MergeBlockVariantInvariantData (
316+ RichTextBlockValue ? sourceRichTextBlockValue ,
317+ RichTextBlockValue ? targetRichTextBlockValue ,
318+ bool canUpdateInvariantData ,
319+ HashSet < string > allowedCultures )
320+ {
321+ if ( sourceRichTextBlockValue is null && targetRichTextBlockValue is null )
322+ {
323+ return null ;
324+ }
325+
326+ BlockEditorData < RichTextBlockValue , RichTextBlockLayoutItem > sourceBlockEditorData =
327+ ( sourceRichTextBlockValue is not null ? ConvertAndClean ( sourceRichTextBlockValue ) : null )
328+ ?? new BlockEditorData < RichTextBlockValue , RichTextBlockLayoutItem > ( [ ] , new RichTextBlockValue ( ) ) ;
329+
330+ BlockEditorData < RichTextBlockValue , RichTextBlockLayoutItem > targetBlockEditorData =
331+ ( targetRichTextBlockValue is not null ? ConvertAndClean ( targetRichTextBlockValue ) : null )
332+ ?? new BlockEditorData < RichTextBlockValue , RichTextBlockLayoutItem > ( [ ] , new RichTextBlockValue ( ) ) ;
333+
334+ return MergeVariantInvariantPropertyValueTyped (
335+ sourceBlockEditorData ,
336+ targetBlockEditorData ,
337+ canUpdateInvariantData ,
338+ allowedCultures ) ;
339+ }
340+
277341 internal override object ? MergePartialPropertyValueForCulture ( object ? sourceValue , object ? targetValue , string ? culture )
278342 {
279343 if ( sourceValue is null || TryParseEditorValue ( sourceValue , out RichTextEditorValue ? sourceRichTextEditorValue ) is false )
0 commit comments