Skip to content

Instantly share code, notes, and snippets.

@segovia94
Created August 4, 2016 01:12
Show Gist options
  • Save segovia94/b067ab2ad8da43e8b08ddbde2379f3f3 to your computer and use it in GitHub Desktop.
Save segovia94/b067ab2ad8da43e8b08ddbde2379f3f3 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_editor_js_settings_alter().
*/
function sitefarm_core_editor_js_settings_alter(array &$settings) {
// New Styles
$styles = array(
[
'name' => 'Align Left',
'type' => 'widget',
'widget' => 'embed',
'attributes' => ['class' => 'u-align--left u-width--half'],
],
[
'name' => 'Align Center',
'type' => 'widget',
'widget' => 'embed',
'attributes' => ['class' => 'u-align--center u-width--two-thirds'],
],
[
'name' => 'Align Right',
'type' => 'widget',
'widget' => 'embed',
'attributes' => ['class' => 'u-align--right u-width--half'],
],
);
foreach ($settings['editor']['formats'] as $name => $value) {
// Add new styles
$current_styles = $settings['editor']['formats'][$name]['editorSettings']['stylesSet'];
if ($current_styles) {
$settings['editor']['formats'][$name]['editorSettings']['stylesSet'] = array_merge($current_styles, $styles);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment