Remove TinyMCE Toolbar Button

安稳与你 提交于 2020-01-04 02:49:12

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/2737440/remove-tinymce-toolbar-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!