Skip to content

Commit 8b34ae7

Browse files
mrgear111nemesifier
authored andcommitted
[fix] Ensured input fields preserve new lines #19
Fixes #19
1 parent 0d66c4c commit 8b34ae7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

flat_json_widget/static/flat-json-widget/js/flat-json-widget.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ var initJsonKeyValueWidget = function (fieldName, inlinePrefix) {
100100
var inputs = $(this).find("input"),
101101
key = inputs.eq(0).val(),
102102
value = inputs.eq(1).val();
103+
// normalize UI representation of \\n fo \n
104+
if (value) {
105+
value = value.replace(/\\n/g, "\n");
106+
}
103107
newValue[key] = value;
104108
});
105109

flat_json_widget/templates/flat_json_widget/flat_json_widget.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h2><%= label %></h2>
3636
</div>
3737
<% } %>
3838
<% for(key in data){ %>
39-
<%= _.template(django.jQuery('.flat-json-row-template-inline').eq(0).html())({ 'key': key, 'value': data[key] }) %>
39+
<%= _.template(django.jQuery(".flat-json-row-template-inline").eq(0).html())({ "key": key, "value": data[key].replace(/\n/g , "\\n") }) %>
4040
<% } %>
4141
</div>
4242

0 commit comments

Comments
 (0)