Merge pull request #11230 from scmmishra/fix-quill-formatter

refactor: catch exceptions in formatters for text editor
This commit is contained in:
mergify[bot] 2020-08-12 11:33:24 +00:00 committed by GitHub
commit 1beaaa5875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -201,9 +201,14 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
// hack to retain space sequence.
value = value.replace(/(\s)(\s)/g, '  ');
if (!$(value).find('.ql-editor').length) {
try {
if (!$(value).find('.ql-editor').length) {
value = `<div class="ql-editor read-mode">${value}</div>`;
}
} catch(e) {
value = `<div class="ql-editor read-mode">${value}</div>`;
}
return value;
},

View file

@ -230,9 +230,14 @@ frappe.form.formatters = {
TextEditor: function(value) {
let formatted_value = frappe.form.formatters.Text(value);
// to use ql-editor styles
if (!$(formatted_value).find('.ql-editor').length) {
try {
if (!$(formatted_value).find('.ql-editor').length) {
formatted_value = `<div class="ql-editor read-mode">${formatted_value}</div>`;
}
} catch(e) {
formatted_value = `<div class="ql-editor read-mode">${formatted_value}</div>`;
}
return formatted_value;
},
Code: function(value) {