Forum

Thread tagged as: Question, Redactor

Remove some default options in Redactor

I added the source plugin to the default Redactor following the description I found on this page: https://docs.grabaperch.com/api/editors/ Now I wanted to remove some options from the default configuration. Having a look at the core file does not give any help to me. Can anyone give me some advice how this could be done? Here's my config.js so far:

Perch.UserConfig.redactor = function(){

  var get = function(profile, config, field) {

    if (config.plugins.indexOf('source') === -1) config.plugins.push('source');
    if (config.plugins.indexOf('fontcolor') === -1) config.plugins.push('fontcolor');

    return config;
  };

  var load = function(cb) {
    if (typeof jQuery.Redactor.prototype.source == 'undefined') {
      jQuery.getScript(Perch.path+'/addons/plugins/editors/redactor-plugins/fontcolor.js', function(){
        jQuery.getScript(Perch.path+'/addons/plugins/editors/redactor-plugins/source.js', cb);    
      }); 

    } else {
      cb();
    }
  };

  return  {
    'get': get,
    'load': load
  }

}();

Thanks a lot!

Martin Stettler

Martin Stettler 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The configuration is the config object that is passed to your get() method. You can modify this and then return it.

So if you wanted to change the formatting option, for example, you could do that with:

config.formatting = ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5'];

Great, thanks a lot, Drew!