From f8be70f6703b4934f11bc8f0e2212196b682d87b Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Thu, 11 Jan 2024 13:20:19 +0000 Subject: [PATCH] [FIX] create the font element inside the selected link element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, when we color a list of links with more than three items in the list, only the first and last links are colored. Now when the li element is colored in a list, the font element is created inside the link. We also make sure when the font size is defined the font element is created inside so that the background color is aligned with the font size task-3677214 closes odoo/odoo#157280 X-original-commit: 4ffb15ab9d9bc7fe6d358264c1ee1ed4e48e5956 Signed-off-by: Geelen Sébastien (sge) Signed-off-by: Jinjiu Liu (jili) --- .../odoo-editor/src/commands/commands.js | 4 +- .../odoo-editor/test/spec/editor.test.js | 90 +++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) 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 3e750c6d194..17e5574eedb 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 @@ -642,7 +642,9 @@ export const editorCommands = { ['inline', 'inline-block'].includes(getComputedStyle(node).display) && !isWhitespace(node.textContent) && !node.classList.contains('btn') && - !node.querySelector('font'))) { + !node.querySelector('font')) && + node.nodeName !== 'A' && + !(node.nodeName === 'SPAN' && node.style['fontSize'])) { // Node is a visible text or inline node without font nor a button: // wrap it in a . const previous = node.previousSibling; diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js index 3f26718ddb7..d2f0c72898b 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js @@ -6709,6 +6709,96 @@ X[] contentAfter: '

a[bcd]e

', }); }); + it('should apply background color to a list of 3 items with font size', async () => { + await testEditor(BasicEditor, { + contentBefore: '
    ' + + '
  • ' + + '' + + '[abc' + + '' + + '
  • ' + + '
  • ' + + '' + + 'bcd' + + '' + + '
  • ' + + '
  • ' + + '' + + 'cde]' + + '' + + '
  • ' + + '
', + stepFunction: editor => editor.execCommand('applyColor', 'rgb(255, 0, 0)', 'backgroundColor'), + contentAfter: '
    ' + + '
  • ' + + '' + + '' + + '[abc' + + '' + + '' + + '
  • ' + + '
  • ' + + '' + + '' + + 'bcd' + + '' + + '' + + '
  • ' + + '
  • ' + + '' + + '' + + 'cde]' + + '' + + '' + + '
  • ' + + '
', + }); + }); + it('should apply background color to a list of 3 links', async () => { + await testEditor(BasicEditor, { + contentBefore: '', + stepFunction: editor => editor.execCommand('applyColor', 'rgb(255, 0, 0)', 'backgroundColor'), + contentAfter: '', + }); + }); it('should distribute color to texts and to button separately', async () => { await testEditor(BasicEditor, { contentBefore: '

a[bcd]e

',