Skip to content

Instantly share code, notes, and snippets.

@leahtard
Created May 20, 2015 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leahtard/8bca9a972ceb3a13a788 to your computer and use it in GitHub Desktop.
Save leahtard/8bca9a972ceb3a13a788 to your computer and use it in GitHub Desktop.
Common config options for ckeditor.
/**
* @file thejibe_ckeditor_custom_config.js
* Includes custom js config - http://docs.ckeditor.com/#!/api/CKEDITOR.config
*/
CKEDITOR.editorConfig = function( config )
{
// Preserve class formatting.
config.allowedContent = true;
// Don't add   to empty elements
config.fillEmptyBlocks = false;
}
/**
* Set link button to have a default setting of _blank.
*/
// Register a placeholder plugin so CKEditor won't complain.
CKEDITOR.plugins.add('default_target', {
requires: ['link'],
init: function(editor) {
}
});
// Hook into dialog creation to set our override.
CKEDITOR.on('dialogDefinition', function(ev) {
var dialogName = ev.data.name, dialogDefinition = ev.data.definition;
if (dialogName == 'link') {
var targetTab = dialogDefinition.getContents('target');
var targetField = targetTab.get('linkTargetType');
targetField['default'] = ev.editor.config.DefaultLinkTarget;
var oldSetup = targetField.setup;
targetField.setup = function(data) {
targetField.onChange.call(this);
if (oldSetup) {
oldSetup.call(this, data);
}
}
}
});
// Sets the default config value to _blank.
CKEDITOR.config.DefaultLinkTarget = '_blank';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment