简体   繁体   English

TinyMCE:如何去掉一些按钮

[英]TinyMCE: How to get rid of some buttons

I'm trying to make a minimal implementation of TinyMCE. The only buttons I want are bold, italic, font size, font color, links and undo/redo.我正在尝试最小化 TinyMCE 的实现。我想要的唯一按钮是粗体、斜体、字体大小、字体颜色、链接和撤消/重做。

I've trimmed the example from their fiddle demo, and I've been able to remove many of the undesired buttons.我已经从他们的小提琴演示中删减了示例,而且我已经能够删除许多不需要的按钮。

This is what I've reduced the init to, but I don't see what else I could possibly eliminate.这就是我将 init 减少到的内容,但我看不出还有什么可以消除的。 Is there a separate config I failed to find?有没有我找不到的单独配置? With this, I still get list buttons, super/subscript and remove formatting and insert special character...有了这个,我仍然得到列表按钮,超级/下标并删除格式并插入特殊字符......

tinyMCE.init({
    // General options
    mode: "textareas",
    theme: "advanced",
    plugins: "", //note, i've removed every plugin for demnstration, stll have unwanted buttons

    // Theme options
    theme_advanced_buttons1: "|,bold,italic,|,fontsizeselect,|,forecolor,",
    theme_advanced_toolbar_location: "top",
    theme_advanced_toolbar_align: "left",
    theme_advanced_statusbar_location: "bottom",
    theme_advanced_resizing: true,
    theme_advanced_text_colors : "FF00FF,FFFF00,000000",
    width: "100%",
    height: "400"
});

Under the theme options, you can enter what you want to have disabled by using theme_advanced_disable .在主题选项下,您可以使用theme_advanced_disable输入要禁用的内容。 For example to get rid of the subscript and superscript buttons, add the following code:例如要去掉下标和上标按钮,添加以下代码:

theme_advanced_disable : "sup,sub"

This comment was addressing TinyMCE 3.X此评论针对 TinyMCE 3.X

You need to empty out the second (an possibly third) set of buttons您需要清空第二组(可能是第三组)按钮

theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
//etc

TinyMCE 4. TinyMCE 4.

The default toolbar in V4 only seems to have a single set of buttons so the above answer for 3. is a bit misleading. V4 中的默认工具栏似乎只有一组按钮,因此上面对 3. 的回答有点误导。 In V4, if you don't specify a toolbar, it'll build one for you.在 V4 中,如果您不指定工具栏,它会为您构建一个。

To set what buttons show up in a toolbar, just specify what items you want.要设置在工具栏中显示哪些按钮,只需指定您想要的项目。

Single toolbar单个工具栏

toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter

Multiple Toolbars多个工具栏

toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
toolbar2: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"

OR要么

toolbar: [
    "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
 ]

Official Docs:官方文档:

You should be able to remove the plugins in the code snippet you mentioned.您应该能够删除您提到的代码片段中的插件。 Just remove what you don't need, and it should adjust.只需删除不需要的内容,它就会进行调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM