If you need to remove a button dynamically, you can use the 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;
}
});
}
};
editor.removeCustomButton = function () { this.customButton.hide(); };
}
});
addCustomButton removeCustomButton removeCustomButton .