summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2019-08-20 13:39:39 +0000
committerNicolas Lempereur <nle@odoo.com>2019-08-20 13:48:26 +0000
commitb058f7094191364083fbd50b18cafabf5fa82b4a (patch)
treeb29b445af71867fdd918c211996854e9fa86b383 /addons/web_editor/static/src
parente6a1ac6e6462c973f55d12ef4b5543aad7790179 (diff)
[FIX] web_editor: font>a colorize a change font color
If you change the color of a link with the editor without using the link edition menu, this do not work (which might be expected), but if the text outside the font had been colorized, the font will be applied outside of the link only. This is unexpected since if we have: "hello <a>cruel</a> world!", if we select only "cruel" and change color, the change only happen to "hello" and "world!". With this changeset, an anchor in the ancestor prevent to use an ancestor font tag to change color (which prevent the issue). opw-2044551 closes #35862 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/summernote.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js
index e52ea66614d..0f6c7cddd03 100644
--- a/addons/web_editor/static/src/js/summernote.js
+++ b/addons/web_editor/static/src/js/summernote.js
@@ -2121,13 +2121,15 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
}
// apply font: foreColor, backColor, size (the color can be use a class text-... or bg-...)
- var node, font, $font, fonts = [], className;
+ var node, ancestors, font, $font, fonts = [], className;
if (color || bgcolor || size) {
for (var i=0; i<nodes.length; i++) {
node = nodes[i];
- font = dom.ancestor(node, dom.isFont);
- if (!font) {
+ ancestors = dom.listAncestor(node, dom.isFont);
+ font = ancestors.slice(-1)[0];
+ // add font if node is not inside a font or inside an anchor firstly
+ if (!dom.isFont(font) || ancestors.filter(dom.isAnchor).length) {
if (node.textContent.match(/^[ ]|[ ]$/)) {
node.textContent = node.textContent.replace(/^[ ]|[ ]$/g, '\u00A0');
}