Commit 9e67456b authored by Israel Shmueli's avatar Israel Shmueli
Browse files

Issue #2881923 by israelshmueli, RajabNatshah: Include the BiDi JavaScript...

Issue #2881923 by israelshmueli, RajabNatshah: Include the BiDi JavaScript plugin directly in the module as an asset
parent 1b9ebac1
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -18,15 +18,8 @@ INSTALLATION
   inside /modules directory. See
   https://www.drupal.org/docs/8/extending-drupal-8/installing-modules
   for details of other optional locations.
3. Download version 4.6.2 of the JavaScript BiDi plugin from http://ckeditor.com/addon/bidi.
4. By default, place the downloaded JavaScript plugin directory (bidi) inside
   your installation /libraries directory. This directory does not exist initially
   so you might need to create it yourself. After placing the plugin directory
   in the default location its path will be something like /libraries/bidi/plugin.js
   ** Optionally: to be able to place the JS plugin in other location then /libraries,
   install the "Libraries API" module: https://www.drupal.org/project/libraries
   this will allow you, for example, to place the js plugin inside custom install
   profile or single site in multisite installation.
3. From version 8.x-2.x there is no need to manually download the JavaScript BiDi
   it is included with the module, inside its js directory.
5. Enable "CKEditor BiDi Buttons" module in Admin "Extend" page (/admin/modules).
6. Configure/Activate: Go to admin section of Drupal site /admin/config/content/formats
   select text format to configure and activate BiDi buttons by dragging them into

ckeditor_bidi.install

deleted100644 → 0
+0 −33
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Install, update and uninstall functions for the CKEditor BiDi Buttons module.
 */

/**
 * Implements hook_requirements().
 */
function ckeditor_bidi_requirements($phase) {

  $requirements = [];

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

  if (!file_exists($path)) {
    $requirements['bidi_library'] = [
      'title' => t('CKEditor\'s BiDi (Text Direction) plugin library is missing'),
      'description' => t('"CKEditor BiDi Buttons" requires the plugin "BiDi (Text Direction)". <br> 
                                Please go and download version 4.6.2 of the BiDi plugin at: <br>
                                 http://ckeditor.com/addon/bidi <br>
                                 Then, place it in  /libraries directory of your installation.<br>
                                 For more detailes see see README.txt of the module.'),
      'severity'    => REQUIREMENT_ERROR,
    ];
  }

  return $requirements;
}
+12 −18
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
 */

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;

/**
 * Implements hook_help().
@@ -14,29 +15,22 @@ function ckeditor_bidi_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.ckeditor_bidi':
      $output = '';
      $output .= '<h3>' . t('<strong>Configure/Activare</strong>: Go to admin section of your Drupal site /admin/config/content/formats  select text format to configure and activate BiDi buttons by dragging them into active buttons area of the editor toolbar.About CKEditor BiDi Buttons') . '</h3>';
      $output .= '<p>' . t('This module integrates the <a href=":cke_bidi_url">CKEditor BiDi plugin</a> with CKEditor for Drupal 8.  This plugin provides the  bi directional text flow buttons,  RTL and LTR .',
      $output .= '<h3>' . t('About CKEditor BiDi Buttons module') . '</h3>';
      $output .= '<p>' . t('This module integrates the <a href=":cke_bidi_url">CKEditor BiDi(text direction) plugin</a> and make it available for CKEditor in Drupal 8.  The BiDi(text direction) plugin provides 2 bi directional text flow buttons,  RTL and LTR .',
          array(
            ':cke_bidi_url' => 'http://ckeditor.com/addon/bidi',
          )) . '</p>';
      $output .= '<p>' . t('The buttons provided by CKEditor BiDi plugin makes it possible to change the text direction for an HTML block-level content element like paragraph and list. If you ever created content in languages that are written Right to Left you are probably aware of the need to switch text flow direction.') . '</p>';
      $output .= '<h3>' . t('Configure/Activare') . '</h3>';


      $output .= '<h3>' . t('Configure/Activate') . '</h3>';
      $output .= '<p>' . t('Go to <a href=":formats">Text formats and editors</a> and click the "Configure" button of a text format that already have "CKEditor" selected as "Text Editor".',
            array(
            ':formats' => \Drupal::url('filter.admin_overview')
              ':formats' => Url::fromRoute('filter.admin_overview')->toString()
            )) . '</p>';
      $output .= '<p>' . t('Now, while on configuration page of chosen text format, look at the "Toolbar configuration" field/section, and you should be able to see 2 BiDi buttons ready to be dragged and dropped into your preffered section of the CKEditor buttons toolbar.') . '</p>';

     return $output;
  }
}
      $output .= '<p>' . t('Now, while on configuration page of chosen text format, look at the "Toolbar configuration" field/section, and you should be able to see 2 BiDi buttons ready to be dragged into CKEditor toolbar.') . '</p>';

/**
 * Implements hook_library_info_alter().
 */
function ckeditor_bidi_library_info_alter(&$libraries, $extension) {
  // Add support for "Libraries API" module, if exists.
  if ($extension == 'bidi' && \Drupal::moduleHandler()->moduleExists('libraries')) {
    $libraries['bidi']['js'] = ['/' . libraries_get_path('bidi') . '/plugin.js' => []];

     return $output;
  }
}
+471 B
Loading image diff...
+474 B
Loading image diff...
Loading