diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-01-07 10:53:41 +0100 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-01-08 11:01:42 +0100 |
| commit | 0bfafde80dda63495c31cc1bdf2b6c6b62d1b89e (patch) | |
| tree | eb5a82a8d91ac48acbe31d3fa5a3ba8c7de73928 /addons/website/static/src | |
| parent | ae385c15ce0948d55a86ecbe0e8f389ecf0fb49a (diff) | |
[FIX] website editor: outdent ul and ol list
Diffstat (limited to 'addons/website/static/src')
| -rw-r--r-- | addons/website/static/src/js/summernote.js | 33 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.snippets.editor.js | 7 |
2 files changed, 23 insertions, 17 deletions
diff --git a/addons/website/static/src/js/summernote.js b/addons/website/static/src/js/summernote.js index 2260da97e09..c2d2b8de09a 100644 --- a/addons/website/static/src/js/summernote.js +++ b/addons/website/static/src/js/summernote.js @@ -50,18 +50,18 @@ define(['summernote/editing/Editor', 'summernote/summernote'], function (Editor) return node; }; dom.nextElementSibling = function (node) { - while (node && node.nextSibling) { + while (node) { node = node.nextSibling; - if (node.tagName) { + if (node && node.tagName) { break; } } return node; }; dom.previousElementSibling = function (node) { - while (node && node.previousSibling) { + while (node) { node = node.previousSibling; - if (node.tagName) { + if (node && node.tagName) { break; } } @@ -1571,6 +1571,8 @@ define(['summernote/editing/Editor', 'summernote/summernote'], function (Editor) var parent = UL.parentNode; var li = UL.parentNode.tagName === "LI" ? UL.parentNode : UL; var ul = UL.parentNode.tagName === "LI" ? UL.parentNode.parentNode : UL.parentNode; + start = dom.ancestor(start, dom.isLi); + end = dom.ancestor(end, dom.isLi); if (ul.tagName !== "UL" && ul.tagName !== "OL") return; @@ -1578,14 +1580,22 @@ define(['summernote/editing/Editor', 'summernote/summernote'], function (Editor) while (node) { if (node === start || $.contains(node, start)) { flag = true; - if (dom.firstElementChild(UL) !== start && dom.lastElementChild(UL) !== end && li.tagName === "LI") { - li = dom.splitTree(li, {'node': node, 'offset': 0}); + if (dom.previousElementSibling(node) && li.tagName === "LI") { + li = dom.splitTree(li, dom.prevPoint({'node': node, 'offset': 0})); } } next = dom.nextElementSibling(node); if (flag) { - ul.insertBefore(node, li); + ul = node.parentNode; + li.parentNode.insertBefore(node, li); + if (!ul.children.length) { + if (ul.parentNode.tagName === "LI") { + ul = ul.parentNode; + } + ul.parentNode.removeChild(ul); + } } + if (node === end || $.contains(node, end)) { flag = false; break; @@ -1593,15 +1603,6 @@ define(['summernote/editing/Editor', 'summernote/summernote'], function (Editor) node = next; } - if (dom.firstElementChild(li).tagName === tagName && !dom.firstElementChild(dom.firstElementChild(li))) { - li.parentNode.removeChild( li ); - } - - if (!dom.firstElementChild(UL)) { - li = UL.parentNode.tagName === "LI" ? UL.parentNode : UL; - li.parentNode.removeChild( li ); - } - dom.merge(parent, start, 0, end, 1, null, true); } function indentOther (p, start, end) { diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 5a689155392..fe54c4e9236 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -1754,7 +1754,12 @@ this.$target.find("li").removeClass('o_open').css('list-style', ''); this.$target.find("li:has(.o_ul_toggle_self, .o_ul_toggle_next), li:has(>ul,>ol):not(:has(>li))").css('list-style', 'none'); - + }, + clean_for_save: function () { + this._super(); + if (!this.$target.hasClass('o_ul_folded')) { + this.$target.find(".o_close").removeClass("o_close"); + } }, toggle_class: function (type, value, $li) { this._super(type, value, $li); |
