jules0x
11/12/2015 - 10:32 AM

TinyMCE custom classes

TinyMCE custom classes

Apply custom classes to html elements via a dropdown

<?

$htmlEditorConfig = HtmlEditorConfig::get('cms');

// Add half' and 'third' wrappers to tinyMCE (will appear in styles drop-down).
$htmlEditorConfig->setOption('style_formats', [
		[
		  'title' => 'Half (md)',
		  'block' => 'div',
		  'wrapper' => true,
		  'classes' => 'pure-u-md-6',
		  'merge_siblings' => false
	  ],
		[
		  'title' => 'Third (md)',
		  'block' => 'div',
		  'wrapper' => true,
		  'classes' => 'pure-u-md-4',
		  'merge_siblings' => false
	  ]
	]
);