Created
May 20, 2015 15:36
-
-
Save leahtard/8bca9a972ceb3a13a788 to your computer and use it in GitHub Desktop.
Common config options for ckeditor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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