From 9499f9d304783df3c130c1e8a4aba9647a81a152 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 24 Feb 2022 10:14:39 +0000 Subject: [PATCH] [FIX] mass_mailing: prevent selection change into zone outside snippets When starting with an empty mailing, it was possible to click in the document and start typing, while this should not be allowed since that zone is not really editable. We want to only allow writing into snippets. task-2778412 closes odoo/odoo#85328 X-original-commit: c9ebe6996f61c24c2a67212beba5dcc95e9a7ed9 Signed-off-by: David Monjoie (dmo) --- addons/mass_mailing/static/src/js/wysiwyg.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/addons/mass_mailing/static/src/js/wysiwyg.js b/addons/mass_mailing/static/src/js/wysiwyg.js index fdaad692501..b856d5af9cd 100644 --- a/addons/mass_mailing/static/src/js/wysiwyg.js +++ b/addons/mass_mailing/static/src/js/wysiwyg.js @@ -5,6 +5,25 @@ var Wysiwyg = require('web_editor.wysiwyg'); var MassMailingSnippetsMenu = require('mass_mailing.snippets.editor'); const MassMailingWysiwyg = Wysiwyg.extend({ + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + start: async function () { + const res = await this._super(...arguments); + // Prevent selection change outside of snippets. + this.$editable.on('mousedown', e => { + if ($(e.target).is('.o_editable:empty') || e.target.querySelector('.o_editable')) { + e.preventDefault(); + } + }); + return res; + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + /** * @override */