1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add backslash handling to library

This commit is contained in:
Kazuhito Yokoi 2020-03-16 21:58:28 +09:00
parent 6675fdf3c2
commit 08ef9ee682

View File

@ -69,7 +69,7 @@ RED.library = (function() {
if (field === "name") { if (field === "name") {
data.name = name; data.name = name;
} else if (field === "info") { } else if (field === "info") {
data.info = activeLibrary.nodeInfoEditor.getValue().replace(/\n/g, "\\n"); data.info = activeLibrary.nodeInfoEditor.getValue().replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
} else { } else {
data[field] = $("#" + elementPrefix + field).val(); data[field] = $("#" + elementPrefix + field).val();
} }
@ -526,7 +526,7 @@ RED.library = (function() {
for (var i = 0; i < activeLibrary.fields.length; i++) { for (var i = 0; i < activeLibrary.fields.length; i++) {
var field = activeLibrary.fields[i]; var field = activeLibrary.fields[i];
if (field === "info") { if (field === "info") {
var nodeInfo = selectedLibraryItem[field].replace(/\\n/g, "\n"); var nodeInfo = selectedLibraryItem[field].split("\\\\").map(function (v) { return v.replace(/\\n/g, "\n"); }).join("\\");
activeLibrary.nodeInfoEditor.setValue(nodeInfo, -1); activeLibrary.nodeInfoEditor.setValue(nodeInfo, -1);
} else { } else {
$("#" + elementPrefix + field).val(selectedLibraryItem[field]); $("#" + elementPrefix + field).val(selectedLibraryItem[field]);