ckeditor_config.module in CKEditor custom config 8.3
Same filename and directory in other branches
Provides UI to manage CKEditor configuration.
File
ckeditor_config.moduleView source
<?php
/**
* @file
* Provides UI to manage CKEditor configuration.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function ckeditor_config_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.ckeditor_config':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('CKEditor custom config allows for custom CKEditor configuration to be attached to individual editors.') . '</p>';
$output .= '<p>' . t('See <a href="@url">https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html</a> for configuration options.', [
'@url' => 'https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html',
]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Adding custom configuration to an editor') . '</dt>';
$output .= '<dd>';
$output .= '<p>' . t('Navigate to an editor configuration page (/admin/config/content/formats/manage/[editor]).') . '</p>';
$output .= '<p>' . t('On the configuration page, navigate to <em>CKEditor custom configuration</em> under <em>CKEditor plugin settings</em>.') . '</p>';
$output .= '<p>' . t('Enter custom configuration with each item on its own line formatted as <code>[setting.name] = [value]</code>') . '</p>';
$output .= '<p>';
$output .= t('Examples:<br>');
$output .= t('<code>forcePasteAsPlainText = true</code><br>');
$output .= t('<code>forceSimpleAmpersand = true</code>');
$output .= '</p>';
$output .= '</dd>';
$output .= '</dl>';
return $output;
}
}
/**
* Implements hook_editor_js_settings_alter().
*/
function ckeditor_config_editor_js_settings_alter(array &$settings) {
foreach ($settings['editor']['formats'] as &$editor) {
if (isset($editor['editorSettings']['ckeditor_custom_config'])) {
// Loop through custom config values and set/override settings.
foreach ($editor['editorSettings']['ckeditor_custom_config'] as $name => $value) {
$editor['editorSettings'][$name] = $value;
}
}
// Settings have been copied to 'editorSettings' and can now be removed.
unset($editor['editorSettings']['ckeditor_custom_config']);
}
}
Functions
Name![]() |
Description |
---|---|
ckeditor_config_editor_js_settings_alter | Implements hook_editor_js_settings_alter(). |
ckeditor_config_help | Implements hook_help(). |