function insert_editor_js_settings_alter in Insert 8
Same name and namespace in other branches
- 8.2 insert.module \insert_editor_js_settings_alter()
Implements hook_editor_js_settings_alter().
File
- ./
insert.module, line 12
Code
function insert_editor_js_settings_alter(array &$settings) {
$config = \Drupal::config('insert.config');
$text_formats = $config
->get('text_formats');
foreach (array_keys($settings['editor']['formats']) as $text_format_id) {
if (in_array($text_format_id, $text_formats)) {
$settings['editor']['formats'][$text_format_id]['editorSettings']['extraAllowedContent'] = 'img[src,width,height,alt,title,data-insert-class,data-insert-type](*); span[contenteditable,data-insert-type](*); a[title,type,data-insert-type](*)';
}
// If drupalimage is disabled (the editor's image button is removed),
// still, CKEditor's naive image2 plugin wraps the image in a span tag
// blocking from applying a style to the image making it impossible to set
// alignment on the image. Therefore, the image2 plugin needs to be disabled
// in that case.
// With drupalimage enabled, the user has to set alignment using the
// editor's image button; With drupalimage disabled, the user has to set
// alignment using the styles drop-down which allows applying additional
// styles to images as well.
if (!in_array('drupalimage', array_keys($settings['editor']['formats'][$text_format_id]['editorSettings']['drupalExternalPlugins']))) {
$settings['editor']['formats'][$text_format_id]['editorSettings']['removePlugins'] = 'image2';
}
}
}