Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove TinyMCE Toolbar Button

Tags:

tinymce

How do I remove a button from the TinyMCE toolbar?

Do I directly edit the tiny_mce.js file? If so, where? Do I edit my theme's editor_template.js file?

Any instruction or hints would be appreciated.

like image 408
David Avatar asked Nov 15 '25 21:11

David


2 Answers

You can define exactly what you want on the toolbar with the advanced theme and you wind up just specifying a list of buttons. See http://wiki.moxiecode.com/index.php/TinyMCE:Configuration for the configuration reference or the examples at http://tinymce.moxiecode.com/examples/full.php

like image 164
ajsutton Avatar answered Nov 18 '25 21:11

ajsutton


In case you need to remove button dynamically, you can use following technique:

    tinymce.init({
        selector: "textarea",
        toolbar: "custom",
        formats: {custom: {inline: "span", styles: {color: "red"}}},
        setup: function(editor){

            editor.addCustomButton = function () {
               if(this.customButton){
                   this.customButton.show();
               } else {
                   this.addButton("custom", {
                       onpostrender: function() {
                           editor.customButton = this; //saving button reference
                       }
                   });
               }
            };

            editor.removeCustomButton = function () { this.customButton.hide(); };
        }
    });

Now you can call editor's methods addCustomButton and removeCustomButton from wherever you need.

like image 35
Grengas Avatar answered Nov 18 '25 20:11

Grengas