geshifilter-8.x-2.0-beta1/codesnippetgeshi/codesnippetgeshi.module
codesnippetgeshi/codesnippetgeshi.module
<?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::service('extension.list.module')->getPath('codesnippetgeshi') . '/css/style-ckeditor.css'; }