fix(quill): Convert ol to ul before sending the value to server

This commit is contained in:
Faris Ansari 2019-01-18 13:00:20 +05:30
parent a9b782b861
commit 0dfd3ae0ae

View file

@ -181,6 +181,19 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
},
get_input_value() {
return this.quill ? this.quill.root.innerHTML : '';
let value = this.quill ? this.quill.root.innerHTML : '';
// quill keeps ol as a common container for both type of lists
// and uses css for appearances, this is not semantic
// so we convert ol to ul if it is unordered
const $value = $(`<div>${value}</div>`);
$value.find('ol li[data-list=bullet]:first-child').each((i, li) => {
let $li = $(li);
let $parent = $li.parent();
let $children = $parent.children();
let $ul = $('<ul>').append($children);
$parent.replaceWith($ul);
});
value = $value.html();
return value;
}
});