[FIX] website: prevent editing the record cover
Steps to reproduce [1]: - Go to website (blog post page) > Change the layout of the cover (Customize > 'Regular' Cover). - Click on the cover (in edit mode) > You can type anything inside and use the text tools (E.g. if you add an image from the toolbar, it will be added on all blog posts). Steps to reproduce [2]: - Go to website (`/calendar` page) > Unpublish an appointment page. - Go back to the `/calendar` page > Switch to edit mode > You still can edit the "unpublished" tag on the items cover (add text, images,... using text tools). The editor uses some methods (`getContentEditableAreas()`, `getReadOnlyAreas()`,...) to check if an area should be marked as editable on load, there is already a cover selector used to define a record cover as an editable zone, but this selector is targeting the whole element, leading to the behaviour described in [1] and [2]. We actually just need to set the savable content (usually the record `name` and `subtitle` fields) as editable and not the whole element. The goal of this commit is to fix this behaviour by removing the cover along with its descendants from the initial editable zones (especially to prevent the scenario in [2], see: $editableSavableZones) and only setting the savable fields as editable areas. opw-3561659 closes odoo/odoo#146407 X-original-commit: 333e437d6acb227f092f1d152fe68d49076cff94 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
This commit is contained in:
@@ -80,7 +80,8 @@ export class WysiwygAdapterComponent extends Wysiwyg {
|
||||
|
||||
this.oeStructureSelector = '#wrapwrap .oe_structure[data-oe-xpath][data-oe-id]';
|
||||
this.oeFieldSelector = '#wrapwrap [data-oe-field]:not([data-oe-sanitize-prevent-edition])';
|
||||
this.oeCoverSelector = '#wrapwrap .s_cover[data-res-model], #wrapwrap .o_record_cover_container[data-res-model]';
|
||||
this.oeRecordCoverSelector = "#wrapwrap .o_record_cover_container[data-res-model]";
|
||||
this.oeCoverSelector = `#wrapwrap .s_cover[data-res-model], ${this.oeRecordCoverSelector}`;
|
||||
if (this.props.savableSelector) {
|
||||
this.savableSelector = this.props.savableSelector;
|
||||
} else {
|
||||
@@ -473,7 +474,13 @@ export class WysiwygAdapterComponent extends Wysiwyg {
|
||||
.not('input, [data-oe-readonly], ' +
|
||||
'[data-oe-type="monetary"], [data-oe-many2one-id], [data-oe-field="arch"]:empty')
|
||||
.filter((_, el) => {
|
||||
return !$(el).closest('.o_not_editable').length;
|
||||
// The whole record cover is considered editable by the editor,
|
||||
// which makes it possible to add content (text, images,...)
|
||||
// from the text tools. To fix this issue, we need to reduce the
|
||||
// editable area to its editable fields only, but first, we need
|
||||
// to remove the cover along with its descendants from the
|
||||
// initial editable zones.
|
||||
return !$(el).closest('.o_not_editable').length && !el.closest(this.oeRecordCoverSelector);
|
||||
});
|
||||
|
||||
// TODO migrate in master. This stable fix restores the possibility to
|
||||
@@ -499,7 +506,8 @@ export class WysiwygAdapterComponent extends Wysiwyg {
|
||||
// oe_structure editable. This avoids having a selection range span
|
||||
// over all further inactive tabs when using Chrome.
|
||||
// grep: .s_tabs
|
||||
$extraEditableZones = $extraEditableZones.add($editableSavableZones.find('.tab-pane > .oe_structure'));
|
||||
$extraEditableZones = $extraEditableZones.add($editableSavableZones.find('.tab-pane > .oe_structure'))
|
||||
.add(this.websiteService.pageDocument.querySelectorAll(`${this.oeRecordCoverSelector} [data-oe-field]:not([data-oe-field="arch"])`));
|
||||
|
||||
return $editableSavableZones.add($extraEditableZones).toArray();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user