ui: util: add helpers for (un)escaping notes-template

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-04-27 17:41:11 +02:00 committed by Thomas Lamprecht
parent e01438a744
commit 7c8ff459a8

View File

@ -1784,6 +1784,22 @@ Ext.define('PVE.Utils', {
return undefined;
},
escapeNotesTemplate: function(value) {
let replace = {
'\\': '\\\\',
'\n': '\\n',
};
return value.replace(/(\\|[\n])/g, match => replace[match]);
},
unEscapeNotesTemplate: function(value) {
let replace = {
'\\\\': '\\',
'\\n': '\n',
};
return value.replace(/(\\\\|\\n)/g, match => replace[match]);
},
},
singleton: true,