题
默认情况下,在“格式化”菜单下(单击按钮时),有这些选项:
Normal Text
Quote
Code
Header 1
Header ...
Header 5
.
我希望只有这些选项:
Normal Text
Quote
Code
.
有没有办法做到这一点?我一直在练习配置选项,并无法找到如何做到这一点。
解决方案
olivérs答案是错误的。
您可以通过执行以下操作来轻松实现这一目标:
$('#redactor').redactor({
formattingTags: ['p', 'blockquote', 'pre']
});
.
其他提示
遗憾的是实现这一目标的唯一方法是在init之前装饰您的Redactor实例并覆盖重定动工中的默认工具栏设置。
您可以在此处查看一个工作POC: http://jsfiddle.net/zmetser/7m3f9/ << / a>
$(function() {
// Decorate redactor Object before init
$.Redactor.fn = (function () {
var toolbarInitOriginal = this.toolbarInit;
// Create a new toolbarInit method which suits our needs
this.toolbarInit = function (lang) {
// Grab the default toolbar...
var toolbar = toolbarInitOriginal(lang);
// ...and overwrite the formatting dropdown menu
toolbar.formatting.dropdown = {
p: {
title: lang.paragraph,
func: 'formatBlocks'
},
blockquote: {
title: lang.quote,
func: 'formatQuote',
className: 'redactor_format_blockquote'
},
pre: {
title: lang.code,
func: 'formatBlocks',
className: 'redactor_format_pre'
},
};
return toolbar;
};
return this;
}.call($.Redactor.fn));
// Init redactor
$('#redactor').redactor({
buttons: ['link', 'formatting', 'html']
});
});
.不隶属于 StackOverflow