You are here

ckeditorheight.module in CKEditorHeight 8

File

ckeditorheight.module
View source
<?php

/**
 * @file ckeditorheight.module
 */

/**
 * Implements hook_library_info_alter().
 */
function ckeditorheight_library_info_alter(&$libraries, $extension) {
  if ($extension === 'ckeditor' && isset($libraries['drupal.ckeditor'])) {
    $module_path = drupal_get_path('module', 'ckeditorheight');
    assert((bool) $module_path);
    $js_path = "/{$module_path}/ckeditorheight.js";
    $libraries['drupal.ckeditor']['js'][$js_path] = [];
  }
}

/**
 * Implements hook_page_attachments().
 */
function ckeditorheight_page_attachments(array &$attachments) {
  $config = \Drupal::config('ckeditorheight.settings');
  $attachments['#attached']['drupalSettings']['ckeditorheight'] = [
    'offset' => $config
      ->get('offset'),
    'line_height' => $config
      ->get('line_height'),
    'unit' => $config
      ->get('unit'),
    'disable_autogrow' => $config
      ->get('disable_autogrow'),
  ];
}