From 7ccfeb964695ac4e99ead75bf358a1b3322f4e84 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 20 Nov 2023 09:37:07 +0100 Subject: [PATCH] [FIX] web_editor: prevent link zws around blocks Link zws should not be applied on links that contain blocks so as to avoid unfortunate side effects of zws on the dimensions of the link. task-3596919 X-original-commit: 656fc7ca4d19311c679f6f3d3df6a4ea7e57c15c Part-of: odoo/odoo#142803 --- .../static/src/js/editor/odoo-editor/src/OdooEditor.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index bf6f6843808..1e6d1acc0e0 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -2023,13 +2023,9 @@ export class OdooEditor extends EventTarget { for (const link of links) { if ( link && - !isBlock(link) && - link.textContent !== '' && - !( - // Ignore links wrapped around a single image. - link.children.length === 1 && - link.firstElementChild.nodeName === 'IMG' - ) + link.textContent.trim() !== '' && + // Only add the ZWS for simple (possibly styled) text links. + ![link, ...link.querySelectorAll('*')].some(isBlock) ) { this._insertLinkZws('start', link); // Only add the ZWS at the end if the link is in selection.