Comments

dylanf created an issue. See original summary.

dylanf’s picture

nod_’s picture

Status: Active » Needs review
Issue tags: +JavaScript
droplet’s picture

Issue tags: +Needs JS testing
tmarshall@acromediainc.com’s picture

Status: Needs review » Reviewed & tested by the community
Wim Leers’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests
  1. No tests yet!
  2. +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
    @@ -285,12 +285,15 @@
       // Override image2's integration with the official CKEditor link plugin:
       // integrate with the drupallink plugin instead.
    -  CKEDITOR.plugins.image2.getLinkAttributesParser = function () {
    -    return CKEDITOR.plugins.drupallink.parseLinkAttributes;
    -  };
    -  CKEDITOR.plugins.image2.getLinkAttributesGetter = function () {
    -    return CKEDITOR.plugins.drupallink.getLinkAttributes;
    -  };
    +  if (CKEDITOR.plugins.drupallink) {
    +    CKEDITOR.plugins.image2.getLinkAttributesParser = function () {
    +      return CKEDITOR.plugins.drupallink.parseLinkAttributes;
    +    };
    +    CKEDITOR.plugins.image2.getLinkAttributesGetter = function () {
    +      return CKEDITOR.plugins.drupallink.getLinkAttributes;
    +    };
    +  }
    

    AFAICT this will cause it to integrate with the official CKEditor link plugin instead.

    What are the consequences of that?

  3. +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
    @@ -285,12 +285,15 @@
    +
     
       /**
    

    Unwanted newline addition.

anthorn305’s picture

I was getting the following error when trying to link an image using the anchor_link module for linking in ckeditor.

Uncaught TypeError: Cannot read property 'getLinkAttributes' of undefined
    at Object.CKEDITOR.plugins.image2.getLinkAttributesGetter 

I ran the patch and it seems to have fixed the issue.

People are reporting this as an anchor_link issue, but it looks like it's really a Drupalimage issue.
#2848535: Unable to create link when wrapping img

Shawn DeArmond’s picture

Version: 8.2.x-dev » 8.3.x-dev

This needs to be 8.3.x now.

Dinesh18’s picture

Status: Needs work » Needs review
FileSize
1.07 KB

Re-rolled the patch #2 and fixed the unwanted new line addition.

Wim Leers’s picture

Status: Needs review » Needs work

Still needs work for #6.1 & #6.2.

Also, the anchor_link module is doing things that are absolutely not allowed. Opened #2888087: Unfortunately this module violates d.o guidelines and D8 guidelines — stop copy/pasting CKEditor plugin, roll our own for that.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Shawn DeArmond’s picture

Patch #9 does not apply to 8.4-rc2

Shawn DeArmond’s picture

Re-rolled patch for 8.4.x

segovia94’s picture

Here is the patch from #13 with the source es6 file and compiled plugin file. It also contains a javascript test to ensure that this doesn't break the regular interaction between DrupalImage and DrupalLink plugins.

segovia94’s picture

This is why tests are awesome. Looks like it found a bug in the original patch. Here is an adjustment to look for CKEDITOR.plugins.externals.drupallink instead.

segovia94’s picture

Status: Needs work » Needs review

Concerning #6.1 & #6.2.

6.1 Test added and passing.

6.2 Yes, the integration back to CkEditor's original Link plugin is the desired result. If the DrupalLink plugin is being used (majority case) then it works with the DrupalLink plugin. However, if that plugin is disabled then it should revert to default CkEditor functionality with the original Link plugin. We've been using the default Link plugin (instead of DrupalLink) for 6 months on multiple sites with this patch and everything works great. We have dozens of Behat tests for ckeditor and had no issues or side effects.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

drpal’s picture

  1. +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.es6.js
    @@ -282,12 +282,14 @@
    +    CKEDITOR.plugins.image2.getLinkAttributesParser = function () {
    

    Unexpected unnamed function, or just use an arrow function.

    CKEDITOR.plugins.image2.getLinkAttributesParser = () => (
      CKEDITOR.plugins.drupallink.parseLinkAttributes
    );
    
  2. +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.es6.js
    @@ -282,12 +282,14 @@
    +    CKEDITOR.plugins.image2.getLinkAttributesGetter = function () {
    

    Unexpected unnamed function, or just use an arrow function.

drpal’s picture

Status: Needs review » Needs work