ckeditor.module 3.18 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

/**
 * @file
 * Provides integration with the CKEditor WYSIWYG editor.
 */

/**
 * Implements hook_library_info().
 */
function ckeditor_library_info() {
  $module_path = drupal_get_path('module', 'ckeditor');

  $settings = array(
    'ckeditor' => array(
      'modulePath' => drupal_get_path('module', 'ckeditor'),
    ),
  );
  $libraries['drupal.ckeditor'] = array(
    'title' => 'Drupal behavior to enable CKEditor on textareas.',
    'version' => VERSION,
    'js' => array(
      $module_path . '/js/ckeditor.js' => array(),
      array('data' => $settings, 'type' => 'setting'),
    ),
    'dependencies' => array(
      array('system', 'drupal'),
      array('ckeditor', 'ckeditor'),
      array('editor', 'drupal.editor'),
    ),
  );
  $libraries['drupal.ckeditor.admin'] = array(
    'title' => 'Drupal behavior for drag-and-drop CKEditor toolbar builder UI.',
    'version' => VERSION,
    'js' => array(
      $module_path . '/js/ckeditor.admin.js' => array(),
    ),
    'css' => array(
      $module_path . '/css/ckeditor.admin.css' => array(),
      'core/misc/ckeditor/skins/moono/editor.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'jquery'),
      array('system', 'drupal'),
      array('system', 'drupalSettings'),
      array('system', 'jquery.once'),
      array('system', 'jquery.ui.sortable'),
      array('system', 'jquery.ui.draggable'),
    ),
  );
  $libraries['drupal.ckeditor.stylescombo.admin'] = array(
    'title' => 'Only show the "stylescombo" plugin settings when its button is enabled.',
    'version' => VERSION,
    'js' => array(
      $module_path . '/js/ckeditor.stylescombo.admin.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'jquery'),
      array('system', 'drupal'),
      array('system', 'jquery.once'),
      array('system', 'drupal.vertical-tabs'),
    ),
  );
  $libraries['ckeditor'] = array(
    'title' => 'Loads the main CKEditor library.',
66
    'version' => '4.1',
67
    'js' => array(
68
69
70
      'core/misc/ckeditor/ckeditor.js' => array(
        'preprocess' => FALSE,
      ),
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    ),
  );

  return $libraries;
}

/**
 * Implements hook_theme().
 */
function ckeditor_theme() {
  return array(
    'ckeditor_settings_toolbar' => array(
      'file' => 'ckeditor.admin.inc',
      'variables' => array('editor' => NULL, 'plugins' => NULL),
    ),
  );
}

/**
 * Retrieves the default theme's CKEditor stylesheets defined in the .info file.
 *
 * Themes may specify iframe-specific CSS files for use with CKEditor by
 * including a "ckeditor_stylesheets" key in the theme .info file.
 *
 * @code
 * ckeditor_stylesheets[] = css/ckeditor-iframe.css
 * @endcode
 */
function _ckeditor_theme_css($theme = NULL) {
  $css = array();
  if (!isset($theme)) {
102
    $theme = config('system.theme')->get('default');
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
  }
  if ($theme_path = drupal_get_path('theme', $theme)) {
    $info = system_get_info('theme', $theme);
    if (isset($info['ckeditor_stylesheets'])) {
      $css = $info['ckeditor_stylesheets'];
      foreach ($css as $key => $path) {
        $css[$key] = $theme_path . '/' . $path;
      }
    }
    if (isset($info['base theme'])) {
      $css = array_merge(_ckeditor_theme_css($info['base theme'], $css));
    }
  }
  return $css;
}