summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor/rte.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-09-20 17:33:22 +0200
committerChristophe Simonis <chs@odoo.com>2019-09-20 17:34:45 +0200
commit64e43808b79badb5869a8d73cc1cc3f3b3aa8e12 (patch)
tree9a22d5f6c03073a4d10faedea8df23a5211e8b8f /addons/web_editor/static/src/js/editor/rte.js
parent944891ced081cda3b8b3db5faf3b7ac23b6b4ce8 (diff)
parent58a83d12228fbbd4e9dde542e133d264204ee0f3 (diff)
[MERGE] forward port branch saas-12.5 up to 58a83d12228
Diffstat (limited to 'addons/web_editor/static/src/js/editor/rte.js')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index bfd7994b161..529bf68887e 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -323,11 +323,20 @@ var RTEWidget = Widget.extend({
});
// start element observation
- $(document).on('content_changed', '.o_editable', function (ev) {
+ $(document).on('content_changed', function (ev) {
self.trigger_up('rte_change', {target: ev.target});
+
+ // Add the dirty flag to the element that changed by either adding
+ // it on the highest editable ancestor or, if there is no editable
+ // ancestor, on the element itself (that element may not be editable
+ // but if it received a content_changed event, it should be marked
+ // as dirty to allow for custom savings).
if (!ev.__isDirtyHandled) {
- $(this).addClass('o_dirty');
ev.__isDirtyHandled = true;
+
+ var el = ev.target;
+ var dirty = el.closest('.o_editable') || el;
+ dirty.classList.add('o_dirty');
}
});
@@ -586,11 +595,16 @@ var RTEWidget = Widget.extend({
* page element)
*/
_saveElement: function ($el, context, withLang) {
+ var viewID = $el.data('oe-id');
+ if (!viewID) {
+ return Promise.resolve();
+ }
+
return this._rpc({
model: 'ir.ui.view',
method: 'save',
args: [
- $el.data('oe-id'),
+ viewID,
this._getEscapedElement($el).prop('outerHTML'),
$el.data('oe-xpath') || null,
],
@@ -720,7 +734,7 @@ var RTEWidget = Widget.extend({
// selected too)
//
// The triple click behavior is reimplemented for all browsers here
- if (ev.originalEvent.detail === 3) {
+ if (ev.originalEvent && ev.originalEvent.detail === 3) {
// Select the whole content inside the deepest DOM element that was
// triple-clicked
range.create(ev.target, 0, ev.target, ev.target.childNodes.length).select();