summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2018-03-22 13:12:40 +0100
committerNicolas Lempereur <nle@odoo.com>2018-04-12 10:10:05 +0200
commit2b380e4e39703f549360cce9b486dafddc76c365 (patch)
treede19a2ee15713d9834ff3eaa77cc21ff17099ba6 /addons/web_editor/static/src/js
parenteb84a309992cb6545180294ab51f51d7eefbafc3 (diff)
[FIX] web_editor: indent just a line inside table
Inside the cell of a table, indenting had several behaviors: - if the selection is contained in several nodes elements: indent the element child nodes of common ancestor - if the selection is contained in one or more list items: indent these list items - if the selection is contained in one 'content block': indent the whole cell content The two first behaviors are expected, but the third one is a little odd and unexpected next to other existing editors behaviors. With this commit, the third behavior becomes: - if the selection is contained in one `content block`: indent this content block note: 'content block' is defined as p, pre, h1, h2, ..., blockquote, td opw-1824647 closes #24182
Diffstat (limited to 'addons/web_editor/static/src/js')
-rw-r--r--addons/web_editor/static/src/js/summernote.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js
index 2678ba955af..435c5d7fa78 100644
--- a/addons/web_editor/static/src/js/summernote.js
+++ b/addons/web_editor/static/src/js/summernote.js
@@ -1856,12 +1856,17 @@ $.summernote.pluginEvents.indent = function (event, editor, layoutInfo, outdent)
var $dom = $(ancestor);
if (!dom.isList(ancestor)) {
+ // to indent a selection, we indent the child nodes of the common
+ // ancestor that contains this selection
$dom = $(dom.node(ancestor)).children();
}
- if (!$dom.length) {
- $dom = $(dom.ancestor(r.sc, dom.isList) || dom.ancestor(r.sc, dom.isCell));
+ if (!$dom.not('br').length) {
+ // if selection is inside a list, we indent its list items
+ $dom = $(dom.ancestor(r.sc, dom.isList));
if (!$dom.length) {
- $dom = $(r.sc).closest(options.styleTags.join(','));
+ // if the selection is contained in a single HTML node, we indent
+ // the first ancestor 'content block' (P, H1, PRE, ...) or TD
+ $dom = $(r.sc).closest(options.styleTags.join(',')+',td');
}
}