rickbutterfield / Umbraco.Community.BlockPreview

Easy to use rich HTML backoffice previews for the Umbraco Block List and Block Grid editors.
MIT License
15 stars 10 forks source link

Preview of Umbraco.MultipleTextstring #46

Open kows opened 7 months ago

kows commented 7 months ago

Not sure if this is related to package or Umbraco's internal BlockEditorConverter.

Value is passed as [{value: "A"}, {value: "B"}, {value: "C"}] to PreviewMarkup call. Same value for the GetById call in the backoffice. Also previewed as that value, so the conversion located in MultipleTextStringPropertyValueEditor is not happening.

kows commented 7 months ago

fyi working around this with specific code for preview:

   @if (Context.Request.IsBlockPreviewRequest())
   {
       var headers = string.Join("", Model.Tableheaders);
       var array = JArray.Parse(headers);
       Model.Tableheaders = array.OfType<JObject>()
                                 .Where(x => x["value"] != null)
                                 .Select(x => x["value"]!.Value<string>())
                                 .ToList();
   }
rickbutterfield commented 5 months ago

@kows I've tried running the latest version of BlockPreview against Umbraco source, and it appears to be a problem with the MultipleTextStringValueConverter. The converter is expecting either a string with NewLine or XML, but the rendered front end value is a JSON array.