summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor/rte.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-11-29 14:47:42 +0000
committerqsm-odoo <qsm@odoo.com>2018-11-29 16:41:33 +0000
commita153ed42a09f8b7f5e0865112eb7d5affc22a353 (patch)
tree36da68c896ade6909f3225670430b0f018da8b28 /addons/web_editor/static/src/js/editor/rte.js
parent962298c9205e8dbf6eab3f8d3a24c99ad2cea38b (diff)
[FIX] website, *: properly clean website widgets
* web_editor When an user saves its website, all the animations are destroyed so that a clean DOM is saved. This is particularly important for snippets like the latest post one that would crash the page if not cleaned before saving. Two cases were found where animations were not cleaned before saving and this is what this commit fixes: - When an user used the undo/redo system, all animations were lost as the DOM is recreated. - When an user duplicated a snippet, animations were not restarted on the cloned element. closes odoo/odoo#29159
Diffstat (limited to 'addons/web_editor/static/src/js/editor/rte.js')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index 90062a02b02..911a29cef5e 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -42,7 +42,10 @@ var History = function History($editable) {
$editable.removeAttr('contentEditable').removeProp('contentEditable');
}
+ $editable.trigger('content_will_be_destroyed');
$editable.html(oSnap.contents).scrollTop(oSnap.scrollTop);
+ $editable.trigger('content_was_recreated');
+
$('.oe_overlay').remove();
$('.note-control-selection').hide();
@@ -276,6 +279,20 @@ var RTEWidget = Widget.extend({
var $editable = this.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)
+ // TODO should be better handled
+ $editable.on('content_will_be_destroyed', function (ev) {
+ self.trigger_up('content_will_be_destroyed', {
+ $target: $(ev.currentTarget),
+ });
+ });
+ $editable.on('content_was_recreated', function (ev) {
+ self.trigger_up('content_was_recreated', {
+ $target: $(ev.currentTarget),
+ });
+ });
+
$editable.addClass('o_editable')
.data('rte', this)
.each(function () {