Problem/Motivation

Currently CKEditor plugin have to be placed in a root libraries folder (/libraries).
This can be quite inconvenient in case of profile developing, when the access to docroot is restricted.

Proposed resolution

Use Libraries to locate the plugin.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

l0ke created an issue. See original summary.

l0ke’s picture

Status: Active » Needs review
StatusFileSize
new2.79 KB
l0ke’s picture

Nitpick fixed: The PHP open tag must be followed with exactly one blank line.

gavin.hughes’s picture

Tested this using Drupal 8.5.3 picks the plugin up nicely

mrP’s picture

Status: Needs review » Reviewed & tested by the community

+1 RTBC with Drupal 8.8.1

bkosborne’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/fakeobjects.install
    @@ -12,7 +12,21 @@ function fakeobjects_requirements($phase) {
    +    $path = DRUPAL_ROOT . '/libraries/fakeobjects/plugin.js';
    +    if (\Drupal::moduleHandler()->moduleExists('libraries')) {
    +      $path = libraries_get_path('fakeobjects') . '/plugin.js';
    +    }
    

    What happens if libraries module is enabled but there is no library "registered" for 'fakeobjects'? what does this return? Maybe I misunderstand libraries module.

  2. +++ b/fakeobjects.libraries.yml
    @@ -0,0 +1,10 @@
    +fakeobjects:
    +  title: 'Ckeditor Fake Objects'
    +  website: http://ckeditor.com/addon/fakeobjects
    +  version: VERSION
    +  license:
    +    name: 'CKSource CDL'
    +    url: https://cksource.com/license/ckeditor
    +    gpl-compatible: true
    +  js:
    +    libraries/iframe/plugin.js: {}
    

    The default path here for the JS file is incorrect

bkosborne’s picture

+++ b/src/Plugin/CKEditorPlugin/FakeObjects.php
@@ -14,11 +14,12 @@ use Drupal\editor\Entity\Editor;
   public function getFile() {
-    return 'libraries/fakeobjects/plugin.js';
+    return libraries_get_path('fakeobjects') . '/plugin.js';
   }

Needs to check if libraries API is available. Module may not be enabled.

Webbeh’s picture

CKEditor Font Size & Family attempted a solution similar to #6, but it ended up doing exactly what you think it might: it crashes if Libraries can't locate the library (see #3122403: The library definition for the library 'font' could not be found. in Drupal\libraries\ExternalLibrary\Definition\FileDefinitionDiscoveryBase->getDefinition() and its eventual removal).

The linked issue has a bit of research into possible solutions, although I couldn't find a best-practice for wrestling Libraries + checking to see if the library exists.

spheresh’s picture

rebasing the patch #3 to apply to the latest dev

anybody’s picture

Thanks, please proceed with MR's here!

zaryab_drupal made their first commit to this issue’s fork.

zaryab_drupal’s picture

Status: Needs work » Needs review

Created MR for patch in #9

xmacinfo’s picture

I think we can add the dependencies through Composer.