自定义WYSIHTML5工具栏

时间:2013-08-19 02:04:06

标签: twitter-bootstrap wysihtml5 x-editable

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

3 个答案:

答案 0 :(得分:15)

如果您碰巧使用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
  }
});

答案 1 :(得分:13)

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

$('#[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
});

此信息应粘贴在标记中:

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

答案 2 :(得分:6)

你可以通过CSS

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