From beb80c20bdd89f2dc430e7488be381b146ce6492 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 23 Sep 2019 09:15:01 +0000 Subject: [PATCH] [FIX] web_editor: change do not bold nobold after bold If we have a content such as: `aaa bbb 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) --- addons/web_editor/static/src/js/editor/summernote.js | 12 +++--------- 1 file 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; i0 && (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; } }