From 6f83fcb9711e84d10556f8a42ee8fcb98fb52953 Mon Sep 17 00:00:00 2001 From: Dhaval Baraiya Date: Wed, 13 Jul 2022 05:53:26 +0000 Subject: [PATCH] [FIX] web_editor: allow to reset background color Before this commit: When copy-pasting from Discord into Notes, get a text with color and background color. But when clicking on the trash icon inside the toolbar to remove the background color, it doesn't remove the background color. After this commit: Allowed to remove background color from text using trash icon. Task-2889682 closes odoo/odoo#114146 X-original-commit: 711ddaf97a5f16b3fe0d5d30dba52e4c9eab8d21 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/odoo-editor/src/commands/commands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js index 6b6734e6005..40cf1a700ad 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js @@ -535,9 +535,9 @@ export const editorCommands = { // Get the nodes to color const selectedNodes = getSelectedNodes(editor.editable).filter(node => !closestElement(node, 'table.o_selected_table')); const fonts = selectedNodes.flatMap(node => { - let font = closestElement(node, 'font'); + let font = closestElement(node, 'font') || closestElement(node, 'span'); const children = font && descendants(font); - if (font && font.nodeName === 'FONT') { + if (font && (font.nodeName === 'FONT' || (font.nodeName === 'SPAN' && font.style[mode]))) { // Partially selected : split it. const selectedChildren = children.filter(child => selectedNodes.includes(child)); if (selectedChildren.length) {