twitter-bootstrap 自定义 WYSIHTML5 工具栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18305497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 18:00:57  来源:igfitidea点击:

Customize WYSIHTML5 Toolbar

twitter-bootstrapwysihtml5x-editable

提问by user2694939

How do you customize the toolbar in WYSIHTML5. I want to disable the font size and image insert buttons, particularly for the WYSIHTML5 version used in Bootstrap X-editable.

您如何自定义WYSIHTML5 中的工具栏。我想禁用字体大小和图像插入按钮,特别是对于 Bootstrap X-editable 中使用的 WYSIHTML5 版本。

回答by mdemolin

If you happen to use bootstrap-wysiwyg/bootstrap3-wysiwyg(which is for example used by gem bootstrap-wysihtml5-rails), since version 3.0, you will need to nest it inside toolbar :

如果您碰巧使用bootstrap-wysiwyg/bootstrap3-wysiwyg(例如由 gem bootstrap-wysihtml5-rails 使用),从 3.0 版开始,您需要将其嵌套在工具栏内:

$('#some-textarea').wysihtml5({
  toolbar: {
    "font-styles": true, // Font styling, e.g. h1, h2, etc.
    "emphasis": true, // Italics, bold, etc.
    "lists": true, // (Un)ordered lists, e.g. Bullets, Numbers.
    "html": false, // Button which allows you to edit the generated HTML.
    "link": true, // Button to insert a link.
    "image": true, // Button to insert an image.
    "color": false, // Button to change color of font
    "blockquote": true, // Blockquote
    "size": <buttonsize> // options are xs, sm, lg
  }
});

回答by Renan Barreiro

You can disable toolbar options using startup parameters:

您可以使用启动参数禁用工具栏选项:

$('#[YOUR INPUT ID]').wysihtml5({
     "font-styles": false, //Font styling, e.g. h1, h2, etc.
     "emphasis": true, //Italics, bold, etc.
     "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers.
     "html": true, //Button which allows you to edit the generated HTML.
     "link": true, //Button to insert a link.
     "image": false, //Button to insert an image.
     "color": true //Button to change color of font
});

This info should be pasted in the tag:

此信息应粘贴在标签中:

<head>
   <script> HERE </scrip>
</head>

回答by Michael Bridak

You can do it through CSS

你可以通过 CSS 来实现

ul.wysihtml5-toolbar li a[title="Insert image"] { display: none; }
ul.wysihtml5-toolbar li.dropdown { display: none; }