Custom styles in TinyMCE Style Formats list

In order to add style_formats to TinyMCE you should register them for tinyMCEStyleFormats property. Example of code:
 


function extendTinyMCEStyleFormats($motopressCELibrary) {
// add Text highlight
$motopressCELibrary->tinyMCEStyleFormats[] = array(
'title' =>'Text highlight',
'inline' => 'span',
'classes' => 'text-highlight'
);
// add Dropcap
$motopressCELibrary->tinyMCEStyleFormats[] = array(
'title' =>'Dropcap',
'inline' => 'span',
'classes' => 'dropcap'
);
}
add_action('mp_library', 'extendTinyMCEStyleFormats', 11, 1);

You’ll get a dropdown ‘Formats’ on tinyMCE panel with your custom formats.

tinymce-add.jpg

Leave a Reply

Your email address will not be published. Required fields are marked *