js/plugins/drupalentity/plugin.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/js/plugins/drupalentity/plugin.js b/js/plugins/drupalentity/plugin.js index 12032f7..105887c 100644 --- a/js/plugins/drupalentity/plugin.js +++ b/js/plugins/drupalentity/plugin.js @@ -101,9 +101,18 @@ /** @type {CKEDITOR.dom.element} */ var element = this.element; - var buttonId = element.getAttribute('data-embed-button'); - var button = editor.config.DrupalEntity_buttons[buttonId]; - this.wrapper.data('cke-display-name', Drupal.t('Embedded @buttonLabel', { '@buttonLabel': button.label })); + // See https://www.drupal.org/node/2544018. + if (element.hasAttribute('data-embed-button')) { + var buttonId = element.getAttribute('data-embed-button'); + if (editor.config.DrupalEntity_buttons[buttonId]) { + var button = editor.config.DrupalEntity_buttons[buttonId]; + this.wrapper.data('cke-display-name', Drupal.t('Embedded @buttonLabel', {'@buttonLabel': button.label})); + } + } + + if (this.parts.link) { + this.setData('link', CKEDITOR.plugins.image2.getLinkAttributesParser()(editor, this.parts.link)); + } }, data: function (event) { @@ -197,7 +206,9 @@ widget.on('edit', function (event) { event.cancel(); - editor.execCommand('editdrupalentity'); + if (isEditableEntityWidget(editor, event.sender.wrapper)) { + editor.execCommand('editdrupalentity'); + } }); });