Save using consistent newline and support parsing different newlines (#13569)
This commit is contained in:
@@ -68,6 +68,9 @@ public class MultipleTextStringPropertyEditor : DataEditor
|
||||
/// </summary>
|
||||
internal class MultipleTextStringPropertyValueEditor : DataValueEditor
|
||||
{
|
||||
private static readonly string NewLine = "\n";
|
||||
private static readonly string[] NewLineDelimiters = { "\r\n", "\r", "\n" };
|
||||
|
||||
private readonly ILocalizedTextService _localizedTextService;
|
||||
|
||||
public MultipleTextStringPropertyValueEditor(
|
||||
@@ -119,10 +122,10 @@ public class MultipleTextStringPropertyEditor : DataEditor
|
||||
// only allow the max if over 0
|
||||
if (max > 0)
|
||||
{
|
||||
return string.Join(Environment.NewLine, array.Take(max));
|
||||
return string.Join(NewLine, array.Take(max));
|
||||
}
|
||||
|
||||
return string.Join(Environment.NewLine, array);
|
||||
return string.Join(NewLine, array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -131,7 +134,6 @@ public class MultipleTextStringPropertyEditor : DataEditor
|
||||
/// cannot have 2 way binding, so to get around that each item in the array needs to be an object with a string.
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="segment"></param>
|
||||
/// <returns></returns>
|
||||
@@ -141,8 +143,9 @@ public class MultipleTextStringPropertyEditor : DataEditor
|
||||
public override object ToEditor(IProperty property, string? culture = null, string? segment = null)
|
||||
{
|
||||
var val = property.GetValue(culture, segment);
|
||||
return val?.ToString()?.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => JObject.FromObject(new { value = x })) ?? new JObject[] { };
|
||||
|
||||
return val?.ToString()?.Split(NewLineDelimiters, StringSplitOptions.None).Select(x => JObject.FromObject(new { value = x }))
|
||||
?? Array.Empty<JObject>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user