1 ckeditor.module ckeditor_ckeditor_plugins()

Implements hook_ckeditor_plugins().

Return a list of all plugins provided by this module.

File

core/modules/ckeditor/ckeditor.module, line 148
Provides integration with the CKEditor 4 WYSIWYG editor.

Code

function ckeditor_ckeditor_plugins() {
  $image_prefix = backdrop_get_path('module', 'ckeditor') . '/images/buttons/';
  $buttons = array(
    'Bold' => array(
      'label' => t('Bold'),
      'required_html' => array(array('tags' => array('strong'))),
    ),
    'Italic' => array(
      'label' => t('Italic'),
      'required_html' => array(array('tags' => array('em'))),
    ),
    'Underline' => array(
      'label' => t('Underline'),
      // A class is used on spans for underline.
      'required_html' => array(array('tags' => array('span'))),
    ),
    'Strike' => array(
      'label' => t('Strike-through'),
      'required_html' => array(array('tags' => array('del'))),
    ),
    'JustifyLeft' => array(
      'label' => t('Align left'),
      'required_html' => array(array('tags' => array('p'), 'classes' => array('text-align-left'))),
    ),
    'JustifyCenter' => array(
      'label' => t('Align center'),
      'required_html' => array(array('tags' => array('p'), 'classes' => array('text-align-center'))),
    ),
    'JustifyRight' => array(
      'label' => t('Align right'),
      'required_html' => array(array('tags' => array('p'), 'classes' => array('text-align-right'))),
    ),
    'JustifyBlock' => array(
      'label' => t('Justify'),
      'required_html' => array(array('tags' => array('p'), 'classes' => array('text-align-justify'))),
    ),
    'BulletedList' => array(
      'label' => t('Bullet list'),
      'image_rtl' => $image_prefix . '/bulletedlist-rtl.png',
      'required_html' => array(array('tags' => array('ul', 'li'))),
    ),
    'NumberedList' => array(
      'label' => t('Numbered list'),
      'image_rtl' => $image_prefix . '/numberedlist-rtl.png',
      'required_html' => array(array('tags' => array('ol', 'li'))),
    ),
    'Undo' => array(
      'label' => t('Undo'),
      'image_rtl' => $image_prefix . '/undo-rtl.png',
    ),
    'Redo' => array(
      'label' => t('Redo'),
      'image_rtl' => $image_prefix . '/redo-rtl.png',
    ),
    'Superscript' => array(
      'label' => t('Superscript'),
      'required_html' => array(array('tags' => array('sup'))),
    ),
    'Subscript' => array(
      'label' => t('Subscript'),
      'required_html' => array(array('tags' => array('sub'))),
    ),
    'Blockquote' => array(
      'label' => t('Blockquote'),
      'required_html' => array(array('tags' => array('blockquote'))),
    ),
    'Source' => array(
      'label' => t('Source code'),
    ),
    'HorizontalRule' => array(
      'label' => t('Horizontal rule'),
      'required_html' => array(array('tags' => array('hr'))),
    ),
    'Cut' => array(
      'label' => t('Cut'),
    ),
    'Copy' => array(
      'label' => t('Copy'),
    ),
    'Paste' => array(
      'label' => t('Paste'),
    ),
    'PasteText' => array(
      'label' => t('Paste Text'),
      'image_rtl' => $image_prefix . '/pastetext-rtl.png',
    ),
    'PasteFromWord' => array(
      'label' => t('Paste from Word'),
      'image_rtl' => $image_prefix . '/pastefromword-rtl.png',
    ),
    'ShowBlocks' => array(
      'label' => t('Show blocks'),
      'image_rtl' => $image_prefix . '/showblocks-rtl.png',
    ),
    'RemoveFormat' => array(
      'label' => t('Remove format'),
    ),
    'SpecialChar' => array(
      'label' => t('Character map'),
    ),
    'Format' => array(
      'label' => t('HTML block format'),
      'image_alternative' => '<span class="ckeditor-button-dropdown">' . t('Format') . '<span class="ckeditor-button-arrow"></span></span>',
    ),
    'Styles' => array(
      'label' => t('Font style'),
      'image_alternative' => '<span class="ckeditor-button-dropdown">' . t('Styles') . '<span class="ckeditor-button-arrow"></span></span>',
    ),
    'Table' => array(
      'label' => t('Table'),
      'required_html' => array(array('tags' => array('table', 'thead', 'tbody', 'tr', 'td', 'th'))),
      'dependencies' => array('contextmenu', 'tabletools', 'tableresize'),
    ),
    'Maximize' => array(
      'label' => t('Maximize'),
    ),
    '-' => array(
      'label' => t('Separator'),
      'image_alternative' => '<span class="ckeditor-separator" title="' . t('Button separator') . '" aria-label="' . t('Button separator') . '">&nbsp;</span>',
      'attributes' => array('class' => array('ckeditor-button-separator')),
      'multiple' => TRUE,
    ),
  );

  // Populate image locations that match button names.
  foreach ($buttons as $button_name => &$button) {
    if (!isset($button['image_alternative']) && !isset($button['image'])) {
      // Because button names are ASCII text, backdrop_strtolower() is not needed.
      $button['image'] = $image_prefix . strtolower($button_name) . '.png';
    }
  }

  // List all the basic plugin buttons as an "internal" plugin.
  $plugins['default'] = array(
    'buttons' => $buttons,
    'internal' => TRUE,
  );

  // The backdropimage plugin replaces normal image functionality.
  $plugins['backdropimage'] = array(
    'path' => backdrop_get_path('module', 'ckeditor') . '/js/plugins/backdropimage',
    'file' => 'plugin.js',
    'buttons' => array(
      'BackdropImage' => array(
        'label' => t('Image'),
        'required_html' => array(
          array(
            'tags' => array('img'),
            'attributes' => array('src', 'alt', 'data-file-id', 'data-align'),
          ),
        ),
        'image' => $image_prefix . '/image.png',
      ),
    ),
  );

  // The backdropcaption plugin provides consistent behaviors for image captions.
  $plugins['backdropimagecaption'] = array(
    'path' => backdrop_get_path('module', 'ckeditor') . '/js/plugins/backdropimagecaption',
    'file' => 'plugin.js',
    'css' => array(backdrop_get_path('module', 'ckeditor') . '/css/ckeditor-caption.css'),
    'enabled callback' => 'ckeditor_image_plugin_check',
    'required_html' => array(
      array(
        'tags' => array('img'),
        'attributes' => array('data-caption'),
      ),
      array(
        'tags' => array('figure', 'figcaption'),
        'attributes' => array('src', 'alt', 'class', 'data-placeholder'),
      ),
    )
  );

  // The backdroplink plugin replaces normal link functionality.
  $plugins['backdroplink'] = array(
    'path' => backdrop_get_path('module', 'ckeditor') . '/js/plugins/backdroplink',
    'file' => 'plugin.js',
    'buttons' => array(
      'BackdropLink' => array(
        'label' => t('Link'),
        'required_html' => array(array(
          'tags' => array('a'),
          'attributes' => array('href'),
        )),
        'image' => $image_prefix . '/link.png',
      ),
      'BackdropUnlink' => array(
        'label' => t('Unlink'),
        'required_html' => array(array(
          'tags' => array('a'),
          'attributes' => array('href'),
        )),
        'image' => $image_prefix . '/unlink.png',
      ),
    ),
  );

  return $plugins;
}