移除TinyMCE工具栏按钮

4

如何从TinyMCE工具栏中删除按钮?

我需要直接编辑tiny_mce.js文件吗?如果是这样,应该在哪里编辑?还是我需要编辑我的主题的editor_template.js文件?

如果有任何指示或提示,将不胜感激。

2个回答

5

2

如果您需要动态地删除按钮,可以使用以下技术:

    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(); };
        }
    });

现在您可以从任何地方调用编辑器的方法addCustomButtonremoveCustomButton。请注意保留html标签。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接