function codesnippet_preprocess_html in CKEditor CodeSnippet 8
Implements hook_preprocess_html().
Ensure our necessary scripts are loaded to the page.
File
- ./
codesnippet.module, line 32 - Provides integration with the CKEditor WYSIWYG editor.
Code
function codesnippet_preprocess_html(&$variables) {
$variables['#attached']['library'][] = 'codesnippet/codesnippet.highlightjs';
$entity = \Drupal::entityTypeManager()
->getStorage('editor');
$editors = $entity
->loadMultiple();
foreach ($editors as $editor) {
if ($editor
->getEditor() != 'ckeditor') {
// bail, as the plugin only works for CKEditor.
continue;
}
$settings = $editor
->getSettings();
if (!empty($settings['plugins']['codesnippet']['highlight_style'])) {
$variables['#attached']['library'][] = 'codesnippet/codesnippet.style.' . $settings['plugins']['codesnippet']['highlight_style'];
}
}
}