Search code examples
javascripttinymcerte

Tiny MCE change the format dropdown display text


Tiny MCE has a format select method: theme_advanced_blockformats dropdown in which you can select formatting. It shows values like: paragraph, heading 1, heading 2 etc. I want to change the names shown in this dropdown. For instance I want to show "heading 1" as "sub heading". It makes more sense to the client working with the editor. Is there a way to do this in the tinyMCE.init? Not in the configuration files.


Solution

  • Yes, this is possible. To set theme_advanced_blockformats use

    tinyMCE.init({
            ...
            theme_advanced_blockformats : "p,div,h1,h2,h3,h4,h5,h6,blockquote,dt,dd,code,samp"
    });
    

    To change the title you will have to modify the lang files under tiny_mce/themes/advanced/langs/en.js

    Update:

    You may change the title using the oninit and setup tinymce configuration parameter in tinymce.init:

    tinymce.EditorManager.i18n['en.advanced.h1'] = 'My desired title';
    

    So, you could try:

    tinyMCE.init({
       ...
       setup : function(ed) {
         ed.onBeforeRenderUI.add(function(ed, cm) {
             tinymce.EditorManager.i18n['en.advanced.h1'] = 'My desired title';
         });
       }
    });