Skip to content

Commit

Permalink
[FIX] website, *: allow to re-edit company team snippet images
Browse files Browse the repository at this point in the history
*: web_editor

Since [1], it was not possible to edit a company team snippet image
anymore as soon as the page was saved once. Indeed that commit added
o_not_editable/contenteditable="false" on the parent column to make sure
no text can be added in that column and contenteditable="true" on the
images so that they are still editable (even though HTML-specs-wise
adding contenteditable="true" on images probably does not mean much as
images are self-closing tags, our editor understand that as the ability
to edit the image anyway). That contenteditable="true" part is however
removed when leaving edit mode... and was not restored upon entering
edit mode again.

This fixes the problems with an ugly patch. We'll review what to do in
master.

Funny enough, that bug was actually gone in 15.0... by mistake. A recent
bug fix actually reintroduced that isolated bug at [2] (by reintroducing
the fact that images in a non-editable environment are not possible to
edit). The 3 opened tickets this commit mentions were actually reported
for 15.0 immediately after that, while the 14.0 being broken about this
since the beginning apparently did not bother anyone.

[1]: odoo@656cac1
[2]: odoo@e113bae

opw-3031217
opw-3032482
opw-3035289

closes odoo#104156

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
  • Loading branch information
qsm-odoo committed Oct 26, 2022
1 parent 2a84366 commit e7c8fed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/web_editor/static/src/js/editor/rte.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ var RTEWidget = Widget.extend({
$('.o_not_editable').attr('contentEditable', false);

var $editable = this.editable();
this.__$editable = $editable;

// When a undo/redo is performed, the whole DOM is changed so we have
// to prepare for it (website will restart animations for example)
Expand Down
19 changes: 19 additions & 0 deletions addons/website/static/src/js/editor/rte.summernote.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ odoo.define('website.rte.summernote', function (require) {
'use strict';

var core = require('web.core');
const rte = require('web_editor.rte');
require('web_editor.rte.summernote');

var eventHandler = $.summernote.eventHandler;
Expand Down Expand Up @@ -56,4 +57,22 @@ eventHandler.modules.popover.button.update = function ($container, oStyle) {
.toggleClass('active', $(oStyle.image).is('[style*="transform"]'))
.toggleClass('d-none', !$(oStyle.image).is('img'));
};

rte.Class.include({
/**
* @override
*/
async start() {
const res = await this._super(...arguments);

// TODO review in master. This stable fix restores the possibility to
// edit the company team snippet images on subsequent editions. Indeed
// this badly relies on the contenteditable="true" attribute being on
// those images but it is rightfully lost after the first save.
// grep: COMPANY_TEAM_CONTENTEDITABLE
this.__$editable.find('.s_company_team .o_not_editable img').prop('contenteditable', true);

return res;
},
});
});
7 changes: 7 additions & 0 deletions addons/website/views/snippets/s_company_team.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!--
TODO review in master: this snippet's images use contenteditable="true" to be
editable, their parent being o_not_editable/contenteditable="false" to prevent
adding text by mistake. After the first save, contenteditable="true" are lost,
so this is a bad practice / requires a better system to do this in the future.
Meanwhile, this is fixed in JS (see COMPANY_TEAM_CONTENTEDITABLE).
-->
<template id="s_company_team" name="Team">
<section class="s_company_team pt48 pb48">
<div class="container">
Expand Down

0 comments on commit e7c8fed

Please sign in to comment.