Contents
- 1 CONFIGURATION
- 1.1 CONFIGURATION OVERVIEW
- 1.2 CONFIGURATION OPTIONS
- 1.2.1 No Custom Configuration File
- 1.2.2 baseHref
- 1.2.3 contentsCss
- 1.2.4 Writing direction of the language
- 1.2.5 Default CKEditor language
- 1.2.6 CKEditor language
- 1.2.7 EnterMode
- 1.2.8 ShiftEnterMode
- 1.2.9 fullPage
- 1.2.10 DocType
- 1.2.11 toolbarLocation
- 1.2.12 toolbar_Basic and toolbar_Full
- 1.2.13 tabIndex
- 1.2.14 width and height
- 1.2.15 skin
- 1.2.16 plugins
CONFIGURATION
CONFIGURATION OVERVIEW
Numerous configuration options included in CKEditor enable the developer to customize the appearance, features and behavior of the editor accordingly to end user needs.
Main configuration file is called config.js and is placed in the root of the CKEditor installation directory. The default configuration of CKEditor can be overridden either by editing the main configuration file or by changing the settings in separate file.
Editing the main configuration file is not recommended as the customized configuration settings will be lost every time the CKEditor is updated to a newer version. Default custom configuration file is called ‘config.js’ and is placed in the root directory of CKEditor. If you want your settings to be stored in a different location, you need to point the CKeditor to use them. This is done by editing the main configuration file e.g. CKEDITOR.replace( 'myfiled', { customConfig : '/myconfig.js' } );
The above line will load myconfig.js configuration file. CKEditor recursively loads custom configuration files defined inside other custom configuration files.
In order to amend default settings of CKEditor, your custom configuration file needs to be edited to include required settings
e.g. config.defaultLanguage = 'de';
Custom configuration file does not need to contain all available settings, it is enough to include only the ones that you want to change.
NOTE: Do not delete nor move config.js file from _source\core directory!
CONFIGURATION OPTIONS
In this section configuration options and commands that need to be issued inside the custom configuration file are described.
No Custom Configuration File
To configure the editor not to load any custom configuration files, use the following setting:
CKEDITOR.config.customConfig = ;
All editor instances created after this command will not load custom configuration files.
baseHref
This setting is used to resolve relative and absolute URLs in the editor content:
config.baseHref = 'http://www.yourSite.com/path/';
contentsCss
This setting specifies the CSS file to be used to apply style to the contents:
config.contentsCss = '/css/mysitestyles.css';
Writing direction of the language
The default writing direction in CKEditor is Left-To-Right which is the most frequently used. To change this setting use the following command:
config.contentsLangDirection = 'rtl';
Default CKEditor language
Default language is used in case no language is set using config.language option and the editor is not able to use the user language.
In order to change default language use the following command:
config.defaultLanguage = 'it';
CKEditor language
This setting is used to set the CKEditor language. In case this option is not set, the editor will automatically try to load with user language if supported, otherwise the default language will be used. To set the language use the following command:
config.language = 'de';
EnterMode
This setting is used to change editor’s behavior when the ENTER key is pressed. By default pressing ENTER creates a new paragraph. In order to change it the following command needs to be used:
config.enterMode = CKEDITOR.ENTER_BR
The following values are accepted:
- CKEDITOR.ENTER_P
- CKEDITOR.ENTER_BR
- CKEDITOR.ENTER_DIV
ShiftEnterMode
This setting is used to change editor’s behavior when the SHIFT + ENTER keys are pressed. By default pressing it creates new line. In order to change it the following command needs to be used:
config.shiftEnterMode = CKEDITOR.ENTER_P
The following values are accepted:
- CKEDITOR.ENTER_P
- CKEDITOR.ENTER_BR
- CKEDITOR.ENTER_DIV
fullPage
This option is used to indicate whether the content of the edited area is a full web page or just its part. In order to change it use the following command:
config.fullPage = true;
DocType
This option sets the Document Type Declaration to be used in the edited area. To change this setting use the following command:
config.docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
toolbarLocation
This option sets the position of CKEditor toolbar ('top' by default). To change this setting use the following command:
config.toolbarLocation = 'bottom';
toolbar_Basic and toolbar_Full
These two features allow the developer to specify what options will be available on the toolbar for the end user. In order to change buttons on the toolbar use the following commands:
CKEDITOR.config.toolbar_Basic = [ [ 'Source', '-', 'Bold', 'Italic' ] ];
CKEDITOR.config.toolbar_Full = [
['Source','-','Save','NewPage','Preview','-','Templates'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['Link','Unlink','Anchor'],
'/',
['Styles','Format','Font','FontSize'],
];
The order of the buttons on the toolbar is determined by the order they appear in the above code. To divide the toolbar into sections, place all the functions for each section in separate square brackets []. To separate functions inside one section ‘-‘ sign should be used. To start a new line on the toolbar after chosen section ‘/’ sign should be used.
tabIndex
This option is used to specify how many “ ” are inserted into HTML when TAB key is pressed and by default it is set to 0. To change editor’s behavior use the following command:
config.tabIndex = 1;
width and height
These two options are used to set the editor's width and height in CSS size format or in pixels. To change these settings use the following commands:
config.height = 220;
config.width = '100%';
skin
This option is used to specify the skin to be loaded. In order to change this setting use one of the following commands:
- for skins located inside ckeditor/_source/skins folder: config.skin = 'v2';
- for skins located elsewhere, provide its name and a path separated by a comma: config.skin = 'myskin,/customstuff/myskin/';
plugins
This option is used to specify the list of plugins to be loaded and initialized. In order to change the list of plugins to be loaded use the following command:
config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';