Skip to content

Instantly share code, notes, and snippets.

@clivewalker
Last active December 7, 2018 06:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clivewalker/6f8152c899c23b822742611ecb8c8965 to your computer and use it in GitHub Desktop.
Save clivewalker/6f8152c899c23b822742611ecb8c8965 to your computer and use it in GitHub Desktop.
A config file to load additional plugins for Perch CMS default Redactor editor
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');
if (config.plugins.indexOf('alignment') === -1) config.plugins.push('alignment');
return config;
};
var load = function(cb) {
if (typeof jQuery.Redactor.prototype.source == 'undefined') {
jQuery.getScript(Perch.path+'/addons/plugins/editors/redactor-plugins/alignment.js', function() {
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
}
}();
@clivewalker
Copy link
Author

clivewalker commented Jul 22, 2017

A config file to load additional Redactor plugins (View Source, Font Colour and Alignment) for Perch CMS. Based on the example at the bottom of this page. See also my post here.

This is a quick example that works on my site but there may be better ways of coding the load method for multiple scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment