summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/summernote.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-01-07 10:53:41 +0100
committerChristophe Matthieu <chm@odoo.com>2015-01-08 11:01:42 +0100
commit0bfafde80dda63495c31cc1bdf2b6c6b62d1b89e (patch)
treeeb5a82a8d91ac48acbe31d3fa5a3ba8c7de73928 /addons/website/static/src/js/summernote.js
parentae385c15ce0948d55a86ecbe0e8f389ecf0fb49a (diff)
[FIX] website editor: outdent ul and ol list
Diffstat (limited to 'addons/website/static/src/js/summernote.js')
-rw-r--r--addons/website/static/src/js/summernote.js33
1 files changed, 17 insertions, 16 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) {