CKEDITOR
This is the API entry point. The entire CKEditor code runs under this object.
Filtering
Config options
-
disableAutoInline : Boolean
Disables creating the inline editor automatically for elements with the
contenteditable
attribute set totrue
.CKEDITOR.disableAutoInline = true;
Defaults to
false
-
replaceClass : String
The class name used to identify
<textarea>
elements to be replaced by CKEditor instances. Set it to empty/null
to disable this feature.CKEDITOR.replaceClass = 'rich_editor';
Defaults to
'ckeditor'
-
skinName : String
The skin to load for all created instances, it may be the name of the skin folder inside the editor installation path, or the name and the path separated by a comma.
Note: This is a global configuration that applies to all instances.
CKEDITOR.skinName = 'moono'; CKEDITOR.skinName = 'myskin,/customstuff/myskin/';
Defaults to
'moono-lisa'
Properties
-
ALT : Number
readonly
ALT key (0x440000).
Defaults to
0x440000
-
CTRL : Number
readonly
CTRL key (0x110000).
Defaults to
0x110000
-
DATA_TRANSFER_CROSS_EDITORS : Number
since 4.5.0 readonly
Data transfer operation (drag and drop or copy and paste) started in one editor instance and ended in another.
Defaults to
2
-
DATA_TRANSFER_EXTERNAL : Number
since 4.5.0 readonly
Data transfer operation (drag and drop or copy and paste) started outside of the editor. The source of the data may be a textarea, HTML, another application, etc.
Defaults to
3
-
DATA_TRANSFER_INTERNAL : Number
since 4.5.0 readonly
Data transfer operation (drag and drop or copy and paste) started and ended in the same editor instance.
Defaults to
1
-
DIALOG_RESIZE_BOTH : Number
readonly
Allow the dialog to be resized in both directions.
Defaults to
3
-
DIALOG_RESIZE_HEIGHT : Number
readonly
Only allow vertical resizing for this dialog, disable horizontal resizing.
Defaults to
2
-
DIALOG_RESIZE_NONE : Number
readonly
No resize for this dialog.
Defaults to
0
-
DIALOG_RESIZE_WIDTH : Number
readonly
Only allow horizontal resizing for this dialog, disable vertical resizing.
Defaults to
1
-
DIALOG_STATE_BUSY : Number
readonly
Dialog state when busy.
Defaults to
2
-
DIALOG_STATE_IDLE : Number
readonly
Dialog state when idle.
Defaults to
1
-
ELEMENT_MODE_APPENDTO : Number
readonly
The editor is to be created inside the element.
Defaults to
2
-
ELEMENT_MODE_INLINE : Number
readonly
The editor is to be attached to the element, using it as the editing block.
Defaults to
3
-
ELEMENT_MODE_NONE : Number
readonly
The editor has no associated element.
Defaults to
0
-
ELEMENT_MODE_REPLACE : Number
readonly
The element is to be replaced by the editor instance.
Defaults to
1
-
END : Number
readonly
Defaults to
2
-
ENLARGE_BLOCK_CONTENTS : Number
readonly
Defaults to
2
-
ENLARGE_ELEMENT : Number
readonly
Defaults to
1
-
ENLARGE_INLINE : Number
readonly
Defaults to
4
-
ENLARGE_LIST_ITEM_CONTENTS : Number
readonly
Defaults to
3
-
ENTER_BR : Number
readonly
Used in conjunction with the CKEDITOR.config.enterMode and CKEDITOR.config.shiftEnterMode configuration settings to make the editor produce
<br>
tags when using the Enter key.Read more in the documentation and see the example.
Defaults to
2
-
ENTER_DIV : Number
readonly
Used in conjunction with the CKEDITOR.config.enterMode and CKEDITOR.config.shiftEnterMode configuration settings to make the editor produce
<div>
tags when using the Enter key.Read more in the documentation and see the example.
Defaults to
3
-
ENTER_P : Number
readonly
Used in conjunction with the CKEDITOR.config.enterMode and CKEDITOR.config.shiftEnterMode configuration settings to make the editor produce
<p>
tags when using the Enter key.Read more in the documentation and see the example.
Defaults to
1
-
EVENT_PHASE_AT_TARGET : Number
readonly
Event at target.
Defaults to
2
-
EVENT_PHASE_BUBBLING : Number
readonly
Bubbling phase.
Defaults to
3
-
EVENT_PHASE_CAPTURING : Number
readonly
Capturing phase.
Defaults to
1
-
FILTER_SKIP_TREE : Number
since 4.4.0 readonly
A flag indicating that the current element and all its ancestors should not be filtered.
See CKEDITOR.filter.addElementCallback for more details.
Defaults to
2
-
LINEUTILS_AFTER : Number
readonly
Determines a position relative to an element in DOM (after).
Defaults to
2
-
LINEUTILS_BEFORE : Number
readonly
Determines a position relative to an element in DOM (before).
Defaults to
0
-
LINEUTILS_INSIDE : Number
readonly
Determines a position relative to an element in DOM (inside).
Defaults to
4
-
MOUSE_BUTTON_LEFT : Number
since 4.7.3 readonly
Left mouse button.
Defaults to
0
-
MOUSE_BUTTON_MIDDLE : Number
since 4.7.3 readonly
Middle mouse button.
Defaults to
1
-
MOUSE_BUTTON_RIGHT : Number
since 4.7.3 readonly
Right mouse button.
Defaults to
2
-
NODE_COMMENT : Number
readonly
Comment node type.
Defaults to
8
-
NODE_DOCUMENT : Number
readonly
Document node type.
Defaults to
9
-
NODE_DOCUMENT_FRAGMENT : Number
readonly
Document fragment node type.
Defaults to
11
-
NODE_ELEMENT : Number
readonly
Element node type.
Defaults to
1
-
NODE_TEXT : Number
readonly
Text node type.
Defaults to
3
-
POSITION_AFTER_END : Number
readonly
Indicates a position after end of a node.
// When used according to an element: // <element>contents</element>^ (range is anchored in element's parent) // When used according to a text node: // "text"^ (range is anchored in text node's parent)
It is used as a parameter of methods like: CKEDITOR.dom.range.moveToPosition, CKEDITOR.dom.range.setStartAt and CKEDITOR.dom.range.setEndAt.
Defaults to
4
-
POSITION_AFTER_START : Number
readonly
Indicates a position after start of a node.
// When used according to an element: // <element>^contents</element> // When used according to a text node: // "^text" (range is anchored in the text node)
It is used as a parameter of methods like: CKEDITOR.dom.range.moveToPosition, CKEDITOR.dom.range.setStartAt and CKEDITOR.dom.range.setEndAt.
Defaults to
1
-
POSITION_BEFORE_END : Number
readonly
Indicates a position before end of a node.
// When used according to an element: // <element>contents^</element> // When used according to a text node: // "text^" (range is anchored in the text node)
It is used as a parameter of methods like: CKEDITOR.dom.range.moveToPosition, CKEDITOR.dom.range.setStartAt and CKEDITOR.dom.range.setEndAt.
Defaults to
2
-
POSITION_BEFORE_START : Number
readonly
Indicates a position before start of a node.
// When used according to an element: // ^<element>contents</element> (range is anchored in element's parent) // When used according to a text node: // ^"text" (range is anchored in text node's parent)
It is used as a parameter of methods like: CKEDITOR.dom.range.moveToPosition, CKEDITOR.dom.range.setStartAt and CKEDITOR.dom.range.setEndAt.
Defaults to
3
-
POSITION_CONTAINS : Number
readonly
Indicates that the context node contains the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
16
-
POSITION_DISCONNECTED : Number
readonly
Indicates that nodes are in different (detached) trees. See CKEDITOR.dom.node.getPosition.
Defaults to
1
-
POSITION_FOLLOWING : Number
readonly
Indicates that the context node follows the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
2
-
POSITION_IDENTICAL : Number
readonly
Indicates that positions of both nodes are identical (this is the same node). See CKEDITOR.dom.node.getPosition.
Defaults to
0
-
POSITION_IS_CONTAINED : Number
readonly
Indicates that the context node is a descendant of the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
8
-
POSITION_PRECEDING : Number
readonly
Indicates that the context node precedes the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
4
-
SELECTION_ELEMENT : Number
readonly
Element selection.
if ( editor.getSelection().getType() == CKEDITOR.SELECTION_ELEMENT ) alert( 'An element is selected' );
Defaults to
3
-
SELECTION_NONE : Number
readonly
No selection.
if ( editor.getSelection().getType() == CKEDITOR.SELECTION_NONE ) alert( 'Nothing is selected' );
Defaults to
1
-
SELECTION_TEXT : Number
readonly
A text or a collapsed selection.
if ( editor.getSelection().getType() == CKEDITOR.SELECTION_TEXT ) alert( 'A text is selected' );
Defaults to
2
-
SHIFT : Number
readonly
SHIFT key (0x220000).
Defaults to
0x220000
-
SHRINK_ELEMENT : Number
readonly
Defaults to
1
-
SHRINK_TEXT : Number
readonly
Defaults to
2
-
START : Number
readonly
Defaults to
1
-
STYLE_BLOCK : Number
readonly
Block style type.
Read more in the CKEDITOR.style class documentation.
Defaults to
1
-
STYLE_INLINE : Number
readonly
Inline style type.
Read more in the CKEDITOR.style class documentation.
Defaults to
2
-
STYLE_OBJECT : Number
readonly
Object style type.
Read more in the CKEDITOR.style class documentation.
Defaults to
3
-
TRISTATE_DISABLED : Number
readonly
Used to indicate the DISABLED state.
Defaults to
0
-
TRISTATE_OFF : Number
readonly
Used to indicate the OFF or INACTIVE state.
Defaults to
2
-
TRISTATE_ON : Number
readonly
Used to indicate the ON or ACTIVE state.
Defaults to
1
-
UI_BUTTON : String
readonly
Button UI element.
Defaults to
'button'
-
UI_MENUBUTTON : String
readonly
Button UI element.
Defaults to
'menubutton'
-
UI_PANEL : String
readonly
Panel UI element.
Defaults to
'panel'
-
UI_PANELBUTTON : String
readonly
Button UI element.
Defaults to
'panelbutton'
-
UI_RICHCOMBO : String
readonly
Button UI element.
Defaults to
'richcombo'
-
UI_SEPARATOR : String
readonly
Separator UI element.
Defaults to
'separator'
-
VALIDATE_AND : Number
readonly
Dialog
AND
logical value indicates the relation between validation functions.Defaults to
2
-
VALIDATE_OR : Number
readonly
Dialog
OR
logical value indicates the relation between validation functions.Defaults to
1
-
VERBOSITY_ERROR : Number
since 4.5.4 readonly
Error reporting verbosity level. When verbosity is set to this value, only error messages will be output to the console. It is a binary flag so it might be combined with the VERBOSITY_WARN flag.
Defaults to
2
-
VERBOSITY_WARN : Number
since 4.5.4 readonly
Warning reporting verbosity level. When verbosity is set to this value, only warn messages will be output to the console. It is a binary flag so it might be combined with the VERBOSITY_ERROR flag.
Defaults to
1
-
basePath : String
The full URL for the CKEditor installation directory. It is possible to manually provide the base path by setting a global variable named
CKEDITOR_BASEPATH
. This global variable must be set before the editor script loading.alert( CKEDITOR.basePath ); // e.g. 'http://www.example.com/ckeditor/'
-
The editor which is currently active (has user focus).
function showCurrentEditorName() { if ( CKEDITOR.currentInstance ) alert( CKEDITOR.currentInstance.name ); else alert( 'Please focus an editor first.' ); }CKEDITOR#event-currentInstance
-
The document of the window storing the CKEDITOR object.
alert( CKEDITOR.document.getBody().getName() ); // 'body'
-
instances : Object
Stores references to all editor instances created. The name of the properties in this object correspond to instance names, and their values contain the CKEDITOR.editor object representing them.
alert( CKEDITOR.instances.editor1.name ); // 'editor1'
Defaults to
{}
-
loadFullCoreTimeout : Number
The time to wait (in seconds) to load the full editor code after the page load, if the "ckeditor_basic" file is used. If set to zero, the editor is loaded on demand, as soon as an instance is created.
This value must be set on the page before the page load completion.
// Loads the full source after five seconds. CKEDITOR.loadFullCoreTimeout = 5;
Defaults to
0
-
revision : String
Contains the CKEditor revision number. The revision number is incremented automatically, following each modification to the CKEditor source code.
alert( CKEDITOR.revision ); // e.g. '3975'
Defaults to
'%REV%'
-
rnd : Number
A 3-digit random integer, valid for the entire life of the CKEDITOR object.
alert( CKEDITOR.rnd ); // e.g. 319
-
status : String
Indicates the API loading status. The following statuses are available:
- unloaded: the API is not yet loaded.
- basic_loaded: the basic API features are available.
- basic_ready: the basic API is ready to load the full core code.
- loaded: the API can be fully used.
Example:
if ( CKEDITOR.status == 'loaded' ) { // The API can now be fully used. doSomething(); } else { // Wait for the full core to be loaded and fire its loading. CKEDITOR.on( 'load', doSomething ); CKEDITOR.loadFullCore && CKEDITOR.loadFullCore(); }
Defaults to
'unloaded'
-
timestamp : String
A constant string unique for each release of CKEditor. Its value is used, by default, to build the URL for all resources loaded by the editor code, guaranteeing clean cache results when upgrading.
alert( CKEDITOR.timestamp ); // e.g. '87dm'
Defaults to
''
-
verbosity : Number
since 4.5.4
Verbosity of error and warn methods. Accepts binary flags VERBOSITY_WARN and VERBOSITY_ERROR.
CKEDITOR.verbosity = 0; // No console output after CKEDITOR.warn and CKEDITOR.error methods. CKEDITOR.verbosity = CKEDITOR.VERBOSITY_WARN; // Console output after CKEDITOR.warn only. CKEDITOR.verbosity = CKEDITOR.VERBOSITY_ERROR; // Console output after CKEDITOR.error only. CKEDITOR.verbosity = CKEDITOR.VERBOSITY_WARN | CKEDITOR.VERBOSITY_ERROR; // Console output after both methods.
Default value enables both VERBOSITY_WARN and VERBOSITY_ERROR.
-
version : String
Contains the CKEditor version number.
alert( CKEDITOR.version ); // e.g. 'CKEditor 3.4.1'
Defaults to
'%VERSION%'
-
_ : Object
private
Private object used to hold core stuff. It should not be used outside of the API code as properties defined here may change at any time without notice.
-
pasteFilters : Object
since 4.13.0 private
Static properties
-
useCapture : Boolean
mixed static
Methods
-
constructor() → event
Creates an event class instance.
Returns
-
add( editor )
-
addCss( css )
Adds CSS rules to be appended to the editor document. This method is mostly used by plugins to add custom styles to the editor document. For basic content styling the
contents.css
file should be used instead.Note: This function should be called before the creation of editor instances.
// Add styles for all headings inside editable contents. CKEDITOR.addCss( '.cke_editable h1,.cke_editable h2,.cke_editable h3 { border-bottom: 1px dotted red }' );
Parameters
css : String
The style rules to be appended. CKEDITOR.config.contentsCss
-
addTemplate( name, source ) → template
Adds a named CKEDITOR.template instance to be reused among all editors. This will return the existing one if a template with same name is already defined. Additionally, it fires the "template" event to allow template source customization.
Parameters
name : String
The name which identifies a UI template.
source : String
The source string for constructing this template.
Returns
template
The created template instance.
-
Creates a new editor instance at the end of a specific DOM element.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CKEditor</title> <!-- Make sure the path to CKEditor is correct. --> <script src="/ckeditor/ckeditor.js"></script> </head> <body> <div id="editorSpace"></div> <script> CKEDITOR.appendTo( 'editorSpace' ); </script> </body> </html>
Parameters
element : Object | String
The DOM element, its ID, or name.
[ config ] : Object
The specific configuration to apply to this editor instance. Configuration set here will override the global CKEditor settings (see CKEDITOR.config).
[ data ] : String
Since 3.3. Initial value for the instance.
Returns
editor
The editor instance created.
-
capture()
Register event handler under the capturing stage on supported target.
-
define( name, meta )
Predefine some intrinsic properties on a specific event name.
Parameters
name : String
The event name
meta : Object
-
Properties
[ errorProof ]
Whether the event firing should catch error thrown from a per listener call.
Defaults to
false
-
domReady()
Specify a function to execute when the DOM is fully loaded.
If called after the DOM has been initialized, the function passed in will be executed immediately.
-
editorConfig( config )
Function called upon loading a custom configuration file that can modify the editor instance configuration (CKEDITOR.editor.config). It is usually defined inside the custom configuration files that can include developer defined settings.
// This is supposed to be placed in the config.js file. CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: config.language = 'fr'; config.uiColor = '#AADC6E'; };
Parameters
config : config
A configuration object containing the settings defined for a CKEDITOR.editor instance up to this function call. Note that not all settings may still be available. See Configuration Loading Order for details.
-
error( errorCode, [ additionalData ] )
since 4.5.4
Error reporting function. When verbosity has VERBOSITY_ERROR flag set, it fires log event with the type set to
error
. The fired event also contains the providederrorCode
andadditionalData
.Parameters
errorCode : String
Error code describing the reported problem.
[ additionalData ] : Object
Additional data associated with the reported problem.
-
fire( eventName, [ data ], [ editor ] ) → Boolean | Object
Fires an specific event in the object. All registered listeners are called at this point.
someObject.on( 'someEvent', function() { ... } ); someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // Both listeners are called. someObject.on( 'someEvent', function( event ) { alert( event.data ); // 'Example' } ); someObject.fire( 'someEvent', 'Example' );
Parameters
eventName : String
The event name to fire.
[ data ] : Object
Data to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editor
The editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | Object
A boolean indicating that the event is to be canceled, or data returned by one of the listeners.
-
fireOnce( eventName, [ data ], [ editor ] ) → Boolean | Object
Fires an specific event in the object, releasing all listeners registered to that event. The same listeners are not called again on successive calls of it or of fire.
someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // Above listener called. someObject.fireOnce( 'someEvent' ); // Above listener called. someObject.fire( 'someEvent' ); // No listeners called.
Parameters
eventName : String
The event name to fire.
[ data ] : Object
Data to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editor
The editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | Object
A booloan indicating that the event is to be canceled, or data returned by one of the listeners.
-
getCss() → String
Returns a string with all CSS rules passed to the addCss method.
Returns
String
A string containing CSS rules.
-
getTemplate( name )
Retrieves a defined template created with addTemplate.
Parameters
name : String
The template name.
-
getUrl( resource ) → String
Gets the full URL for CKEditor resources. By default, URLs returned by this function contain a querystring parameter ("t") set to the timestamp value.
It is possible to provide a custom implementation of this function by setting a global variable named
CKEDITOR_GETURL
. This global variable must be set before the editor script loading. If the custom implementation returns nothing (==null
), the default implementation is used.// e.g. 'http://www.example.com/ckeditor/skins/default/editor.css?t=87dm' alert( CKEDITOR.getUrl( 'skins/default/editor.css' ) ); // e.g. 'http://www.example.com/skins/default/editor.css?t=87dm' alert( CKEDITOR.getUrl( '/skins/default/editor.css' ) ); // e.g. 'http://www.somesite.com/skins/default/editor.css?t=87dm' alert( CKEDITOR.getUrl( 'http://www.somesite.com/skins/default/editor.css' ) );
Parameters
resource : String
The resource whose full URL we want to get. It may be a full, absolute, or relative URL.
Returns
String
The full URL.
-
hasListeners( eventName ) → Boolean
Checks if there is any listener registered to a given event.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); alert( someObject.hasListeners( 'someEvent' ) ); // true alert( someObject.hasListeners( 'noEvent' ) ); // false
Parameters
eventName : String
The event name.
Returns
Boolean
-
Turns a DOM element with the
contenteditable
attribute set totrue
into a CKEditor instance. Check CKEDITOR.dtd.$editable for a list of allowed element names.Note: If the DOM element for which inline editing is being enabled does not have the
contenteditable
attribute set totrue
or theconfig.readOnly
configuration option is set tofalse
, the editor will start in read-only mode.<div contenteditable="true" id="content">...</div> ... CKEDITOR.inline( 'content' );
It is also possible to create an inline editor from the
<textarea>
element. If you do so, an additional<div>
element with editable content will be created directly after the<textarea>
element and the<textarea>
element will be hidden.Parameters
element : Object | String
The DOM element or its ID.
[ instanceConfig ] : Object
The specific configurations to apply to this editor instance. See CKEDITOR.config.
Returns
editor
The editor instance created.
-
Calls the
CKEDITOR.inline()
method for all page elements with thecontenteditable
attribute set totrue
that are allowed in the CKEDITOR.dtd.$editable object. -
Forces the full CKEditor core code, in the case only the basic code has been loaded (
ckeditor_basic.js
). This method self-destroys (becomes undefined) in the first call or as soon as the full code is available.// Check if the full core code has been loaded and load it. if ( CKEDITOR.loadFullCore ) CKEDITOR.loadFullCore();
-
on( eventName, listenerFunction, [ scopeObj ], [ listenerData ], [ priority ] ) → Object
Registers a listener to a specific event in the current object.
someObject.on( 'someEvent', function() { alert( this == someObject ); // true } ); someObject.on( 'someEvent', function() { alert( this == anotherObject ); // true }, anotherObject ); someObject.on( 'someEvent', function( event ) { alert( event.listenerData ); // 'Example' }, null, 'Example' ); someObject.on( 'someEvent', function() { ... } ); // 2nd called someObject.on( 'someEvent', function() { ... }, null, null, 100 ); // 3rd called someObject.on( 'someEvent', function() { ... }, null, null, 1 ); // 1st called
Note: CKEditor's event system has a limitation that one function cannot be used as a listener for the same event more than once. Hence, to reuse it with multiple listeners, it should be wrapped into additional wrapper function:
function listener( evt ) { ... }; someObject.on( 'someEvent', function() { listener(); } ); someObject.on( 'someEvent', function( evt ) { listener( evt ); } );
Parameters
eventName : String
The event name to which listen.
listenerFunction : Function
The function listening to the event. A single CKEDITOR.eventInfo object instanced is passed to this function containing all the event data.
[ scopeObj ] : Object
The object used to scope the listener call (the
this
object). If omitted, the current object is used.[ listenerData ] : Object
Data to be sent as the CKEDITOR.eventInfo.listenerData when calling the listener.
[ priority ] : Number
The listener priority. Lower priority listeners are called first. Listeners with the same priority value are called in registration order.
Defaults to
10
Returns
Object
An object containing the
removeListener
function, which can be used to remove the listener at any time.
-
once()
Similiar with on but the listener will be called only once upon the next event firing.
-
Remove all existing listeners on this object, for cleanup purpose.
-
removeListener( eventName, listenerFunction )
Unregisters a listener function from being called at the specified event. No errors are thrown if the listener has not been registered previously.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener called. someObject.removeListener( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener not called.
Parameters
eventName : String
The event name.
listenerFunction : Function
The listener function to unregister.
-
Replaces a
<textarea>
or a DOM element (<div>
) with a CKEditor instance. For textareas, the initial value in the editor will be the textarea value. For DOM elements, theirinnerHTML
will be used instead. It is recommended to use<textarea>
and<div>
elements only.<textarea id="myfield" name="myfield"></textarea> ... CKEDITOR.replace( 'myfield' ); var textarea = document.body.appendChild( document.createElement( 'textarea' ) ); CKEDITOR.replace( textarea );
Parameters
element : Object | String
The DOM element (textarea), its ID, or name.
[ config ] : Object
The specific configuration to apply to this editor instance. Configuration set here will override the global CKEditor settings (see CKEDITOR.config).
Returns
editor
The editor instance created.
-
replaceAll( [ className ], [ evaluator ] )
Replaces all
<textarea>
elements available in the document with editor instances.// Replace all <textarea> elements in the page. CKEDITOR.replaceAll(); // Replace all <textarea class="myClassName"> elements in the page. CKEDITOR.replaceAll( 'myClassName' ); // Selectively replace <textarea> elements, based on a custom evaluation function. CKEDITOR.replaceAll( function( textarea, config ) { // A function that needs to be evaluated for the <textarea> // to be replaced. It must explicitly return "false" to ignore a // specific <textarea>. // You can also customize the editor instance by having the function // modify the "config" parameter. } ); // Full page example where three <textarea> elements are replaced. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CKEditor</title> <!-- Make sure the path to CKEditor is correct. --> <script src="/ckeditor/ckeditor.js"></script> </head> <body> <textarea name="editor1"></textarea> <textarea name="editor2"></textarea> <textarea name="editor3"></textarea> <script> // Replace all three <textarea> elements above with CKEditor instances. CKEDITOR.replaceAll(); </script> </body> </html>
Parameters
[ className ] : String
The
<textarea>
class name.[ evaluator ] : Function
An evaluation function that must return
true
for a<textarea>
to be replaced with the editor. If the function returnsfalse
, the<textarea>
element will not be replaced.
-
warn( errorCode, [ additionalData ] )
since 4.5.4
Warning reporting function. When verbosity has the VERBOSITY_WARN flag set, it fires the log event with type set to
warn
. Fired event contains also providederrorCode
andadditionalData
.Parameters
errorCode : String
Error code describing reported problem.
[ additionalData ] : Object
Additional data associated with reported problem.
-
remove( editor )
private
Removes an editor instance from the global CKEDITOR object. This function is available for internal use only. External code must use CKEDITOR.editor.destroy.
Parameters
editor : editor
The editor instance to be removed.
Static methods
-
implementOn( targetObject )
mixed static
Implements the CKEDITOR.event features in an object.
var myObject = { message: 'Example' }; CKEDITOR.event.implementOn( myObject ); myObject.on( 'testEvent', function() { alert( this.message ); } ); myObject.fire( 'testEvent' ); // 'Example'
Parameters
targetObject : Object
The object into which implement the features.
Events
-
ariaWidget( evt )
Fired when a panel is added to the document.
Parameters
evt : eventInfo
-
Properties
data : Object
The element wrapping the panel.
-
currentInstance( evt )
Fired when the CKEDITOR.currentInstance object reference changes. This may happen when setting the focus on different editor instances in the page.
var editor; // A variable to store a reference to the current editor. CKEDITOR.on( 'currentInstance', function() { editor = CKEDITOR.currentInstance; } );
Parameters
evt : eventInfo
-
dialogDefinition( evt )
Event fired when a dialog definition is about to be used to create a dialog in an editor instance. This event makes it possible to customize the definition before creating it.
Note that this event is called only the first time a specific dialog is opened. Successive openings will use the cached dialog, and this event will not get fired.
Parameters
evt : eventInfo
-
Properties
data : Object
-
Properties
name : String
The name of the dialog.
definition : definition
The dialog definition that is being loaded.
dialog : dialog
A dialog instance that the definition is loaded for. Introduced in CKEditor 4.13.0.
editor : editor
The editor instance that will use the dialog.
-
instanceCreated( evt )
Event fired when a CKEDITOR instance is created, but still before initializing it. To interact with a fully initialized instance, use the instanceReady event instead.
-
instanceDestroyed( evt )
Event fired when a CKEDITOR instance is destroyed.
-
instanceLoaded( evt )
Event fired when CKEDITOR instance's components (configuration, languages and plugins) are fully loaded and initialized. However, the editor will be fully ready for interaction on instanceReady.
-
instanceReady( evt )
Event fired when a CKEDITOR instance is created, fully initialized and ready for interaction.
-
loaded( evt )
Fired when a CKEDITOR core object is fully loaded and ready for interaction.
Parameters
evt : eventInfo
-
log( evt )
since 4.5.4
This event can be used to provide a custom error/warning handler:
CKEDTIOR.on( 'log', function( evt ) { // Cancel default listener. evt.cancel(); // Log event data. console.log( evt.data.type, evt.data.errorCode, evt.data.additionalData ); } );
Parameters
evt : eventInfo
-
Properties
data : Object
-
Properties
type : String
Log type. Can be
error
orwarn
.errorCode : String
Error code describing the reported problem.
[ additionalData ] : Object
Additional data associated with this log event.
-
reset( evt )
Fired when the last instance has been destroyed. This event is used to perform global memory cleanup.
Parameters
evt : eventInfo