[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>
This commit is contained in:
Nicolas Lempereur
2019-09-25 12:18:30 +00:00
parent c536b369d3
commit beb80c20bd
@@ -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;
}
}