This is an extract of my plugin (full version):
CKEDITOR.plugins.add('dndck4', {
lang: 'en',
requires: 'widget',
init: function (editor) {
editor.widgets.add('dndck4', {
dialog: 'atomProperties',
pathName: 'atom',
editables: {
caption: {
selector: '.dnd-caption-wrapper',
pathName: 'caption',
allowedContent: 'a[href]; strong; em'
}
},
...
downcast: function(el) {
var caption = '';
if (this.data.usesCaption) {
caption = this.editables.caption.getHtml();
}
var html = Drupal.dndck4.downcastedHtml(this.data, caption);
return CKEDITOR.htmlParser.fragment.fromHtml(html);
},
It worked well, until another JS does something apparently harmless:
editor.on('change', function() {
// Let CKEditor handle updating the linked text element.
editor.updateElement();
});
It breaks my widget based plugin (this.editables is an empty object). Of course I can just check this.editables to avoid error in the next line caption = this.editables.caption.getHtml();
but I'd like to know what happened and why.