Currently the module assumes the plugin path is `libraries/ckeditor/plugins/pastefromword/plugin.js` - this makes it hard to install the library in a composer project via e.g. drupal-libraries-installer, which installs to `libraries/pastefromword/plugin.js`.

Patch attached checks for the Libraries module and if enabled, gets the library path from libraries_get_path().

Comments

bgilhome created an issue. See original summary.

julien’s picture

Hi there,

  if (\Drupal::moduleHandler()->moduleExists('libraries')) {
    $plugin_detected = libraries_get_path('link') . '/plugin.js';
  }

I don't know if 'link' is the right parameter for the library name here. Can you confirm ? Shouldn't it be 'pastefromword' instead ?
Also try to change :

  $plugin_detected = libraries_get_path('link') . '/plugin.js';

by

  $plugin_detected = file_exists(libraries_get_path('link') . '/plugin.js');

because libraries_get_path return the path if the library is found.

Webbeh’s picture

StatusFileSize
new656 bytes
new1.51 KB

Work from #2 into a patch and interdiff. For review.

julien’s picture

Thanks for the work on the patch @Webbeh

One more little thing to fix and it should be ok. file_exists is used in the wrong function.
file_exists should be use in ckeditor_pastefromword_requirements() function instead of getFile(), getFile have to return the path to the library.

julien’s picture

Status: Needs review » Needs work
Webbeh’s picture

Status: Needs work » Needs review
StatusFileSize
new1.51 KB
new1.3 KB

Feedback from #4 into patch and interdiff from #3.

  • julien committed 78dcc7e on 8.x-1.x authored by Webbeh
    Issue #3116522 by Webbeh: Support libraries module
    
julien’s picture

Commited. Thanks Webbeh

julien’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

zwerg’s picture

The patch does not work for me (core 8.9.2)

zwerg’s picture

I just added the library and the patch to my composer.json file but Drupal doesn't detect the library folder.

composer.json:

        "pastefromword": {
            "type": "package",
            "package": {
               "name": "ckeditor/pastefromword",
               "version": "4.14.1",
               "type": "drupal-library",
               "dist": {
                 "url": "https://download.ckeditor.com/pastefromword/releases/pastefromword_4.14.1.zip",
                 "type": "zip",
                 "reference": "v4.14.1"
                       }
                       }
                         }
                    }