Automatically detect the presence of popper library

Created on 21 January 2025, 1 day ago

Following on Configure script to load from CDN Active I think we can improve the module usability by simply detecting if the library is present in the system locally, and use it instead of CDN.


 /**
   * Implements hook_library_info_alter().
   */
function ckeditor_tippy_library_info_alter(&$libraries, $extension) {
  if ($extension == 'ckeditor_tippy'  && file_exists(DRUPAL_ROOT . '/libraries/popper/popper.js')) {
    if (isset($libraries['plugin.scroll_effects.build']['dependencies'])
      && ($dependency_key = array_search('ckeditor_tippy/popper.remote', $libraries['plugin.scroll_effects.build']['dependencies'])) !== FALSE) {
        unset($libraries['plugin.ckeditor_tippy.build']['dependencies'][$dependency_key]);
        $libraries['plugin.ckeditor_tippy.build']['dependencies'][] = 'ckeditor_tippy/popper.local';
    }
  }
}
Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇷🇴Romania cristiroma

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024