Commit 2c3a76dd authored by Romain Courteaud's avatar Romain Courteaud

[erp5_xhtml_style] Do not trigger notifyChange when rendering the editor

parent 9779203f
CACHE MANIFEST CACHE MANIFEST
# generated on Mon, 05 Feb 2018 15:00:00 GMT+0100 # generated on Mon, 31 May 2018 12:00:00 GMT+0100
CACHE: CACHE:
renderjs.js renderjs.js
rsvp.js rsvp.js
......
...@@ -196,6 +196,7 @@ ...@@ -196,6 +196,7 @@
} else { } else {
configuration = gadget.state.configuration; configuration = gadget.state.configuration;
} }
gadget.on_change_listener = gadget.deferNotifyChange.bind(gadget);
gadget.ckeditor = CKEDITOR.replace( gadget.ckeditor = CKEDITOR.replace(
this.element.querySelector('textarea'), this.element.querySelector('textarea'),
configuration configuration
...@@ -212,7 +213,7 @@ ...@@ -212,7 +213,7 @@
gadget.ckeditor.on('instanceReady', function (event) { gadget.ckeditor.on('instanceReady', function (event) {
event.editor.execCommand('maximize'); event.editor.execCommand('maximize');
}); });
gadget.ckeditor.on('change', gadget.deferNotifyChange.bind(gadget));
// Let CKEDITOR open inner links when in read-only mode // Let CKEDITOR open inner links when in read-only mode
gadget.ckeditor.on('contentDom', function () { gadget.ckeditor.on('contentDom', function () {
var editable = gadget.ckeditor.editable(); var editable = gadget.ckeditor.editable();
...@@ -231,7 +232,12 @@ ...@@ -231,7 +232,12 @@
}); });
} }
if (modification_dict.hasOwnProperty('value')) { if (modification_dict.hasOwnProperty('value')) {
this.ckeditor.setData(this.state.value); // Prevent triggering notifyChange method when render is called
// remove the change listener before calling setData and restore it after
this.ckeditor.removeListener('change', this.on_change_listener);
this.ckeditor.setData(this.state.value, {callback: function () {
gadget.ckeditor.on('change', gadget.on_change_listener);
}});
} }
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment