From 072c038df5fa7be3cf52d27adea342b2e97531ad Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Mon, 26 Jul 2021 15:56:07 +0000 Subject: [PATCH] [FIX] web_editor: prevent Odoo editor hints on technical elements Some templates contain empty
  • elements for styling purposes only and should be blacklisted in the context of Odoo editor hints as these elements are not editable. task-2550858 closes odoo/odoo#74944 Signed-off-by: Antoine Guenet --- addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 5 ++++- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index 4e5b32abb67..77e8ff0c6b6 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -153,6 +153,7 @@ export class OdooEditor extends EventTarget { return closestElement(selection.anchorNode, 'P, DIV'); } }, + isHintBlacklisted: () => false, _t: string => string, }, options, @@ -1825,7 +1826,9 @@ export class OdooEditor extends EventTarget { for (const [selector, text] of Object.entries(selectors)) { for (const el of this.editable.querySelectorAll(selector)) { - this._makeHint(el, text); + if (!this.options.isHintBlacklisted(el)) { + this._makeHint(el, text); + } } } diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 8cb0caee5fb..2cd791d00d7 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -88,6 +88,10 @@ const Wysiwyg = Widget.extend({ return !(node.hasAttribute && node.hasAttribute('data-oe-model')) && node; } }, + isHintBlacklisted: node => { + return node.hasAttribute && + (node.hasAttribute('data-target') || node.hasAttribute('data-oe-model')); + }, noScrollSelector: 'body, .note-editable, .o_content, #wrapwrap', commands: commands, });