Skip to content

Instantly share code, notes, and snippets.

@smk
Last active October 26, 2016 11:45
Show Gist options
  • Save smk/0ad7de7bda565165d3a3 to your computer and use it in GitHub Desktop.
Save smk/0ad7de7bda565165d3a3 to your computer and use it in GitHub Desktop.
Adding style_formats to wysiwyg settings.
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function hook_wysiwyg_editor_settings_alter(&$settings, $context) {
if ($context['profile']->editor == 'tinymce') {
// Add custom styles for the styleselect plugin.
if (!isset($settings['style_formats'])) {
$settings['style_formats'] = array();
}
$settings['style_formats'][] = array('title' => t('Image left aligned'), 'selector' => 'img', 'classes' => 'image-align-left');
$settings['style_formats'][] = array('title' => t('Image right aligned'), 'selector' => 'img', 'classes' => 'image-align-right');
$settings['style_formats'][] = array('title' => t('Image with border'), 'selector' => 'img', 'classes' => 'image-with-border');
$settings['style_formats'][] = array('title' => t('Link without decoration'), 'selector' => 'a', 'classes' => 'no-styled-link');
$settings['style_formats'][] = array('title' => t('List without bullets'), 'selector' => 'ul', 'classes' => 'no-bullets');
// Format filter = 'full_html' specific options.
if ($context['profile']->format == 'full_html') {
$settings['style_formats'][] = array('title' => t('Table with border'), 'selector' => 'table', 'classes' => 'table-with-border');
}
// Format filter = 'info_process_html' specific options.
if ($context['profile']->format == 'info_process_html') {
$settings['style_formats'][] = array('title' => t('Table without border'), 'selector' => 'table', 'classes' => 'table-without-border');
}
// Remove default css classes from dropdown list.
$settings['table_styles'] = ' ';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment