Merge pull request #6783 from netchampfaris/fix-quill-ol-to-ul

fix(quill): Convert ol to ul before sending the value to server
This commit is contained in:
Suraj Shetty 2019-01-18 13:42:04 +05:30 committed by GitHub
commit d1418781fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;
}
});