You are here

codesnippetgeshi.module in GeSHi Filter for syntax highlighting 8

Same filename and directory in other branches
  1. 8.2 codesnippetgeshi/codesnippetgeshi.module

File

codesnippetgeshi/codesnippetgeshi.module
View source
<?php

/**
 * @file
 * Contains codesnippetgeshi.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\editor\Entity\Editor;

/**
 * Implements hook_help().
 */
function codesnippetgeshi_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the codesnippetgeshi module.
    case 'help.page.codesnippetgeshi':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Integrate the plugin CodeSnippetGeshi from CKEditor in Drupal.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_editor_js_settings_alter().
 */
function codesnippetgeshi_editor_js_settings_alter(array &$settings) {
  foreach (array_keys($settings['editor']['formats']) as $text_format_id) {
    if ($settings['editor']['formats'][$text_format_id]['editor'] === 'ckeditor') {

      // Change the path for ajax request, used to show code with highlight
      // inside the editor.
      $settings['editor']['formats'][$text_format_id]['editorSettings']['codeSnippetGeshi_url'] = '/codesnippetgeshi/ajax';
    }
  }
}

/**
 * Implements hook_ckeditor_css_alter().
 */
function codesnippetgeshi_ckeditor_css_alter(array &$css, Editor $editor) {

  // Add a css file to use inside ckeditor.
  $css[] = drupal_get_path('module', 'codesnippetgeshi') . '/css/style-ckeditor.css';
}