summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2019-09-23 09:15:01 +0000
committerNicolas Lempereur <nle@odoo.com>2019-09-25 12:18:30 +0000
commitbeb80c20bdd89f2dc430e7488be381b146ce6492 (patch)
treeaa7a6cd12146392114cb8c3dd61412eab5e3433d /addons/web_editor/static/src/js/editor
parentc536b369d362e41f36b133f2b3646ba4ee4d8f4d (diff)
[FIX] web_editor: change do not bold nobold after bold
If we have a content such as: `aaa <B>bbb</B> ccc` and you eg. change size of `a bbb c`, the c gets bold because of an issue in the merging after style is applied. reason: we check that the style was same as previous nodes, but because walkpoints text[a]->B->text[bbb]->B->text[c] is expurged of duplicates it becomes text[a]->B->text[bbb]->text[c] so we erroneoulsy think that the node before text[c] is text[bbb] (instead of B tag) note: 12.5 forward-port (skipping [12.3,12.4]) of 11.0 #37254 (also contain #37345) opw-2071930 closes #37295 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js/editor')
-rw-r--r--addons/web_editor/static/src/js/editor/summernote.js12
1 files changed, 3 insertions, 9 deletions
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js
index c2cf0d68d6c..3d2c4c205d4 100644
--- a/addons/web_editor/static/src/js/editor/summernote.js
+++ b/addons/web_editor/static/src/js/editor/summernote.js
@@ -2237,7 +2237,7 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
// select nodes to clean (to remove empty font and merge same nodes)
nodes = [];
dom.walkPoint(startPoint, endPoint, function (point) {
- nodes.push(point.node);
+ nodes.push(point.node.childNodes[point.offset] || point.node);
});
nodes = list.unique(nodes);
@@ -2256,10 +2256,8 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
for (i=0; i<nodes.length; i++) {
node = nodes[i];
- if ((dom.isText(node) || dom.isBR(node)) && !dom.isVisibleText(node)) {
+ if (dom.isText(node) && !node.nodeValue) {
remove(node);
- nodes.splice(i,1);
- i--;
continue;
}
@@ -2276,18 +2274,14 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
if (!className && !style) {
remove(node, node.parentNode);
- nodes.splice(i,1);
- i--;
continue;
}
- if (i>0 && (font = dom.ancestor(nodes[i-1], dom.isFont))) {
+ if (font = dom.ancestor(node.previousSibling, dom.isFont)) {
className2 = font.getAttribute('class');
style2 = font.getAttribute('style');
if (node !== font && className === className2 && style === style2) {
remove(node, font);
- nodes.splice(i,1);
- i--;
continue;
}
}