Does webform need to look for ckeditor.fakeobjects? We already have a module that uses fakeobjects but the library is called fakeobjects and not ckeditor.fakeobjects. Also based on the name of the zip file looks like it should just be named that. Thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smustgrave created an issue. See original summary.

smustgrave’s picture

jrockowitz’s picture

Drupal does not have central mechanism to download external libraries. I wanted to namespace most of the libraries to prevent conflicts. We might be able to add some directory detection code.

What module are you using?

jrockowitz’s picture

I found the fakeobjects.module which is a dependency of the anchor_link.module.

Looking at the other ckeditor plugins like image and link I think it makes sense why I prefixed them with 'ckeditor.*'

I think the safer solution, it to have fakeobjects.module and anchor_link.module account for the ckeditor.* prefix. This would be a very minor patch.

smustgrave’s picture

Fakeobjects was the the module I was thinking of.

jrockowitz’s picture

For example, removing the 'ckeditor.*' prefix would cause problems with the 'ckeditor.codemirror' plugin because there is already a 'codemirror' directory.

The best compromise might be to add support ckeditor plugins without the ckeditor.* prefix. Meanwhile the webform library related drush command, composer.libraries.json, and zip archive would still use the prefix.

smustgrave’s picture

"merge-plugin": {
"include": [
"wwwroot/modules/contrib/webform/composer.libraries.json"
]
}

I added this to my composer and it grabs all the libraries but the ckeditor.fakeobjects. So does it do some check for the fakeobjects library?

jrockowitz’s picture

I think we are not going to be updating composer.libraries.json. If a website has the fakeobjects.module installed they would have build their own composer.libraries.json file.

jrockowitz’s picture

The CKEditor CodeMirror module addressed this challenge by support multiple directories via #2901069: Slight re-architecture without library dependency

My suggestion from #6 is getting a little ugly and does not solve the fact the the webform module would still generate composer.json files using the ckeditor.* prefix.

We might want to approach the maintainers of these ckeditor plugin modules and see if they are open to supporting the ckeditor.* namespace.

BTW, I don't love having the webform module's choice of library directory names having an impact other modules external libraries.

smustgrave’s picture

Fully understand. My question from #7 was though I pulled in webform's composer.libraries.json and it added all the libraries to my repo which was desired. I already had a fakeobjects library but since webform is pulling in ckeditor.fakeobjects I would expect that folder to have appeared also but it didnt'. Any idea? Curious if the same thing would of happened to say ckeditor.link if I already had the link folder.

jrockowitz’s picture

Yes the webform modules composer.libraries.json should always create a /libraries/ckeditor.fakeobjects and /libraries/ckeditor.link directory.

smustgrave’s picture

But it didn’t create the ckeditor.fakeobjects folder. I’m assuming since I already had just a fakeobjects folder.

jrockowitz’s picture

I can't reproduce the issue from #12.

My steps are…

  • Configure my local composer.json to merge webform's composer.libraries.json
  • Run composer update
  • Rename /libraries/ckeditor.fakeobjects to /libraries/fakeobjects
  • Run composer update
  • This will recreate /libraries/ckeditor.fakeobjects and keep /libraries/fakeobjects
jrockowitz’s picture

Status: Active » Needs review

I am not comfortable changing the destination of all CKEditor related plugins, mainly because of the ckedior.codemirror plugin, which shows that there would be some immediate conflicts with this change.

For sites, that do not want to use the ckeditor.* prefix, they can implement the below hook, which will removes the ckeditor.* prefix when CKEditor plugins are placed in /libraries (i.e: /libraries/fakeobjects). These site would have generate update their composer.json using webform:composer:update.

I think this is a fair compromise.

/**
 * Implements hook_webform_libraries_info_alter()
 */
function CUSTOM_MODULE_webform_libraries_info_alter(&$libraries) {
  // Support CKEditor plugins without the ckeditor.* prefix.
  foreach ($libraries as $library_name => &$library) {
    if (strpos($library_name, 'ckeditor.') === 0
      && !file_exists($library['plugin_path'])
      && file_exists(str_replace('ckeditor.', '', $library['plugin_path']))) {
      $library['plugin_path'] = str_replace('ckeditor.', '', $library['plugin_path']);
    }
  }
}



smustgrave’s picture

Seems very fair to me. I’ll post a patch to the fake objects module with this. Thanks!

jrockowitz’s picture

Instead of having multiple modules add this hook, we should just add this code snippet to the Webform module.

jrockowitz’s picture

Version: 6.0.0-alpha15 » 8.x-5.x-dev
jrockowitz’s picture

  • jrockowitz authored cea7598 on 8.x-5.x
    Issue #3171426 by jrockowitz, smustgrave: Ckeditor FakeObjects
    
jrockowitz’s picture

I am very comfortable with the patch from #18 (the 1 test failure can be ignored), so I committed it. Please download the latest dev release to review.

jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz authored cea7598 on 6.x
    Issue #3171426 by jrockowitz, smustgrave: Ckeditor FakeObjects
    

Status: Fixed » Closed (fixed)

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