[FIX] mass_mailing, web_editor: prevent dropping snippets out of mailing
Prior to this commit, it was possible to drop snippets out of the confines of the mailing's body and into its editable parent instead. This makes that impossible. task-2554899 X-original-commit: e3942e4aa1391ca82a946d4b6b3823d2690733ee Part-of: odoo/odoo#77724
This commit is contained in:
@@ -86,8 +86,8 @@
|
||||
<field name="reply_to_mode">new</field>
|
||||
<field name="reply_to">Info <info@yourcompany.example.com></field>
|
||||
<field name="body_html" type="html">
|
||||
<div class="o_layout o_default_theme">
|
||||
<div class="container o_mail_wrapper" style="border-collapse:collapse;">
|
||||
<div class="o_layout o_default_theme oe_unremovable oe_unmovable" data-name="Mailing">
|
||||
<div class="container o_mail_wrapperoe_unremovable oe_unmovable" style="border-collapse:collapse;">
|
||||
<div class="row">
|
||||
<div class="col o_mail_no_options o_mail_wrapper_td oe_structure" style="text-align:left;width:100%;">
|
||||
<div class="o_mail_block_header_logo" data-snippet="s_mail_block_header_logo">
|
||||
|
||||
@@ -124,6 +124,17 @@ var MassMailingFieldHtml = FieldHtml.extend({
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_createWysiwygIntance: async function () {
|
||||
await this._super(...arguments);
|
||||
// Data is removed on save but we need the mailing and its body to be
|
||||
// named so they are handled properly by the snippets menu.
|
||||
this.$content.find('.o_layout').addBack().data('name', 'Mailing');
|
||||
// We don't want to drop snippets directly within the wysiwyg.
|
||||
this.$content.removeClass('o_editable').addClass('o_not_editable')
|
||||
},
|
||||
/**
|
||||
* Returns true if the editable area is empty.
|
||||
*
|
||||
@@ -269,15 +280,16 @@ var MassMailingFieldHtml = FieldHtml.extend({
|
||||
// This wrapper structure is the only way to have a responsive
|
||||
// and centered fixed-width content column on all mail clients
|
||||
$new_wrapper = $('<div/>', {
|
||||
class: 'container o_mail_wrapper o_mail_regular',
|
||||
class: 'container o_mail_wrapper o_mail_regular oe_unremovable',
|
||||
});
|
||||
$newWrapperContent = $('<div/>', {
|
||||
class: 'col o_mail_no_options o_mail_wrapper_td oe_structure'
|
||||
class: 'col o_mail_no_options o_mail_wrapper_td oe_structure o_editable'
|
||||
});
|
||||
$new_wrapper.append($('<div class="row"/>').append($newWrapperContent));
|
||||
}
|
||||
var $newLayout = $('<div/>', {
|
||||
class: 'o_layout ' + themeParams.className,
|
||||
class: 'o_layout oe_unremovable oe_unmovable ' + themeParams.className,
|
||||
'data-name': 'Mailing',
|
||||
}).append($new_wrapper);
|
||||
|
||||
var $contents;
|
||||
|
||||
@@ -181,8 +181,8 @@ var SnippetEditor = Widget.extend({
|
||||
var $customize = this._customize$Elements[this._customize$Elements.length - 1];
|
||||
|
||||
this.isTargetParentEditable = this.$target.parent().is(':o_editable');
|
||||
this.isTargetMovable = this.isTargetParentEditable && this.isTargetMovable;
|
||||
this.isTargetRemovable = this.isTargetParentEditable && !this.$target.parent().is('[data-oe-type="image"]');
|
||||
this.isTargetMovable = this.isTargetParentEditable && this.isTargetMovable && !this.$target.hasClass('oe_unmovable');
|
||||
this.isTargetRemovable = this.isTargetParentEditable && !this.$target.parent().is('[data-oe-type="image"]') && !this.$target.hasClass('oe_unremovable');
|
||||
this.displayOverlayOptions = this.displayOverlayOptions || this.isTargetMovable || !this.isTargetParentEditable;
|
||||
|
||||
// Initialize move/clone/remove buttons
|
||||
@@ -483,7 +483,7 @@ var SnippetEditor = Widget.extend({
|
||||
// Consider layout-only elements (like bg-shapes) as empty
|
||||
return el.matches(this.layoutElementsSelector);
|
||||
});
|
||||
return isEmpty && !$el.hasClass('oe_structure')
|
||||
return isEmpty && !$el.hasClass('oe_structure') && !$el.hasClass('oe_unremovable')
|
||||
&& (!editor || editor.isTargetParentEditable);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user