【问题标题】:Remove TinyMCE Toolbar Button删除 TinyMCE 工具栏按钮
【发布时间】:2010-04-29 12:58:24
【问题描述】:

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

我是否直接编辑 tiny_mce.js 文件?如果有,在哪里?我要编辑我的主题的 editor_template.js 文件吗?

任何说明或提示将不胜感激。

【问题讨论】:

    标签: tinymce


    【解决方案1】:

    您可以使用高级主题在工具栏上准确定义您想要的内容,最后只需指定一个按钮列表。请参阅http://wiki.moxiecode.com/index.php/TinyMCE:Configuration 以获取配置参考或http://tinymce.moxiecode.com/examples/full.php 中的示例

    【讨论】:

      【解决方案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

      【讨论】: