CKEDITOR
This is the API entry point. The entire CKEditor code runs under this object.
Filtering
Config options
-
disableAutoInline : BooleanCKEDITOR#disableAutoInlineDisables creating the inline editor automatically for elements with the
contenteditableattribute set totrue.CKEDITOR.disableAutoInline = true;Defaults to
false -
replaceClass : StringCKEDITOR#replaceClassThe class name used to identify
<textarea>elements to be replaced by CKEditor instances. Set it to empty/nullto disable this feature.CKEDITOR.replaceClass = 'rich_editor';Defaults to
'ckeditor' -
skinName : StringCKEDITOR#skinNameThe 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
-
-
-
Data transfer operation (drag and drop or copy and paste) started in one editor instance and ended in another.
Defaults to
2 -
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 operation (drag and drop or copy and paste) started and ended in the same editor instance.
Defaults to
1 -
-
-
-
-
-
-
-
-
-
-
-
Defaults to
2 -
Defaults to
1 -
Defaults to
4 -
Defaults to
3 -
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 -
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 -
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 -
-
-
-
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 -
Integration with browser's "Go back" and "Go forward" buttons using hash-based navigation.
Defaults to
2 -
Integration with browser's "Go back" and "Go forward" buttons using Native History API.
Defaults to
1 -
-
-
-
-
-
-
-
-
-
-
-
-
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 -
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 -
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 -
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 -
Indicates that the context node contains the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
16 -
Indicates that nodes are in different (detached) trees. See CKEDITOR.dom.node.getPosition.
Defaults to
1 -
Indicates that the context node follows the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
2 -
Indicates that positions of both nodes are identical (this is the same node). See CKEDITOR.dom.node.getPosition.
Defaults to
0 -
Indicates that the context node is a descendant of the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
8 -
Indicates that the context node precedes the other node. See CKEDITOR.dom.node.getPosition.
Defaults to
4 -
Element selection.
if ( editor.getSelection().getType() == CKEDITOR.SELECTION_ELEMENT ) alert( 'An element is selected' );Defaults to
3 -
No selection.
if ( editor.getSelection().getType() == CKEDITOR.SELECTION_NONE ) alert( 'Nothing is selected' );Defaults to
1 -
A text or a collapsed selection.
if ( editor.getSelection().getType() == CKEDITOR.SELECTION_TEXT ) alert( 'A text is selected' );Defaults to
2 -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Dialog
ANDlogical value indicates the relation between validation functions.Defaults to
2 -
Dialog
ORlogical value indicates the relation between validation functions.Defaults to
1 -
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 -
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 : StringCKEDITOR#basePathThe 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/' -
currentInstance : editorCKEDITOR#currentInstanceThe 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 -
document : documentCKEDITOR#documentThe document of the window storing the CKEDITOR object.
alert( CKEDITOR.document.getBody().getName() ); // 'body' -
instances : ObjectCKEDITOR#instancesStores 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 : NumberCKEDITOR#loadFullCoreTimeoutThe 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 : StringCKEDITOR#revisionContains 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%' -
A 3-digit random integer, valid for the entire life of the CKEDITOR object.
alert( CKEDITOR.rnd ); // e.g. 319Generated integer is not cryptographically secure. It has been deprecated to prevent using it in a security-sensitive context by accident. Use
window.crypto.getRandomValues()native browser method instead. -
status : StringCKEDITOR#statusIndicates 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 : StringCKEDITOR#timestampA 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 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 : StringCKEDITOR#versionContains the CKEditor version number.
alert( CKEDITOR.version ); // e.g. 'CKEditor 3.4.1'Defaults to
'%VERSION%' -
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.
Static properties
Methods
-
constructor() → eventCKEDITOR#constructor -
add( editor )CKEDITOR#addAdds an editor instance to the global CKEDITOR object. This function is available for internal use mainly.
Parameters
editor : editorThe editor instance to be added.
-
addCss( css )CKEDITOR#addCssAdds 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.cssfile 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 : StringThe style rules to be appended. CKEDITOR.config.contentsCss
-
addTemplate( name, source ) → templateCKEDITOR#addTemplateAdds 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 : StringThe name which identifies a UI template.
source : StringThe source string for constructing this template.
Returns
templateThe created template instance.
-
addTemplates( name, definition )CKEDITOR#addTemplatesAdds templates' collection to the list of all available templates.
Parameters
name : StringName of the templates' collection.
definition : collectionDefinitionDefinition of templates' collection.
-
Appends timestamp to the provided URL as querystring parameter ("t").
Leaves the URL unchanged if it is a directory URL or it already contains querystring parameter.
Parameters
resource : StringThe resource URL to which the timestamp should be appended.
Returns
StringThe resource URL with cache key appended whenever possible.
-
appendTo( element, [ config ], [ data ] ) → editor | Function | nullCKEDITOR#appendToCreates 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>Since 4.17 this function also supports the Delayed Editor Creation feature allowing to postpone the editor initialization.
Since 4.19 if the editor has been configured to use the Delayed Editor Creation feature and the editor has not been initialized yet, this function will return a handle allowing to cancel the interval set by the CKEDITOR.config.delayIfDetached and CKEDITOR.config.delayIfDetached_interval options.
var cancelInterval = CKEDITOR.appendTo( 'editorSpace', { delayIfDetached: true, delayIfDetached_interval: 50 // Default value, you can skip that option. } ); cancelInterval(); // Cancel editor initialization if needed.It is recommended to use this function to prevent potential memory leaks. Use it if you know that the editor host element will never be attached to the DOM. As an example, execute cancel handle in your component cleanup logic (e.g.
onDestroylifecycle methods in popular frontend frameworks).Read more about this feature in the documentation.
Parameters
element : Object | StringThe DOM element, its ID, or name.
[ config ] : ObjectThe specific configuration to apply to this editor instance. Configuration set here will override the global CKEditor settings (see CKEDITOR.config).
[ data ] : StringSince 3.3. Initial value for the instance.
Returns
editor | Function | nullThe editor instance or a cancelation function. If Delayed Editor Creation feature has not been set and element is missing in DOM, this function will return
null.
-
capture()CKEDITOR#captureRegister event handler under the capturing stage on supported target.
-
define( name, meta )CKEDITOR#definePredefine some intrinsic properties on a specific event name.
Parameters
name : StringThe event name
meta : Object
-
domReady()CKEDITOR#domReadySpecify 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 )CKEDITOR#editorConfigFunction 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 : configA 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 reporting function. When verbosity has VERBOSITY_ERROR flag set, it fires event-log event with the type set to
error. The fired event also contains the providederrorCodeandadditionalData.Parameters
errorCode : StringError code describing the reported problem.
[ additionalData ] : ObjectAdditional data associated with the reported problem.
-
fire( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR#fireFires 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 : StringThe event name to fire.
[ data ] : ObjectData to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editorThe editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | ObjectA boolean indicating that the event is to be canceled, or data returned by one of the listeners.
-
fireOnce( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR#fireOnceFires 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 : StringThe event name to fire.
[ data ] : ObjectData to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editorThe editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | ObjectA booloan indicating that the event is to be canceled, or data returned by one of the listeners.
-
getCss() → StringCKEDITOR#getCssReturns a string with all CSS rules passed to the addCss method.
Returns
StringA string containing CSS rules.
-
getTemplate( name )CKEDITOR#getTemplate -
getTemplates( name ) → collectionDefinitionCKEDITOR#getTemplatesGets templates' collection by its name.
Parameters
name : StringName of the templates' collection.
Returns
collectionDefinition
-
getUrl( resource ) → StringCKEDITOR#getUrlGets 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 : StringThe resource whose full URL we want to get. It may be a full, absolute, or relative URL.
Returns
StringThe full URL.
-
hasListeners( eventName ) → BooleanCKEDITOR#hasListenersChecks 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' ) ); // falseParameters
eventName : StringThe event name.
Returns
Boolean
-
inline( element, [ instanceConfig ] ) → editor | Function | nullCKEDITOR#inlineTurns a DOM element with the
contenteditableattribute set totrueinto 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
contenteditableattribute set totrueor theconfig.readOnlyconfiguration option is set totrue, 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.Since 4.17 this function also supports the Delayed Editor Creation feature allowing to postpone the editor initialization.
Since 4.19 if the editor has been configured to use the Delayed Editor Creation feature and the editor has not been initialized yet, this function will return a handle allowing to cancel the interval set by the CKEDITOR.config.delayIfDetached and CKEDITOR.config.delayIfDetached_interval options.
var cancelInterval = CKEDITOR.inline( 'editor', { delayIfDetached: true, delayIfDetached_interval: 50 // Default value, you can skip that option. } ); cancelInterval(); // Cancel editor initialization if needed.It is recommended to use this function to prevent potential memory leaks. Use it if you know that the editor host element will never be attached to the DOM. As an example, execute cancel handle in your component cleanup logic (e.g.
onDestroylifecycle methods in popular frontend frameworks).Read more about this feature in the documentation.
Parameters
element : Object | StringThe DOM element or its ID.
[ instanceConfig ] : ObjectThe specific configurations to apply to this editor instance. See CKEDITOR.config.
Returns
editor | Function | nullThe editor instance or a cancellation function. If Delayed Editor Creation feature has not been set and element is missing in DOM, this function will return
null.
-
inlineAll()CKEDITOR#inlineAllCalls the
CKEDITOR.inline()method for all page elements with thecontenteditableattribute set totruethat are allowed in the CKEDITOR.dtd.$editable object.Since 4.17 this function also supports the Delayed Editor Creation feature allowing to postpone the editor initialization. Read more about this feature in the documentation.
-
loadFullCore()CKEDITOR#loadFullCoreForces 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(); -
loadTemplates( templateFiles, callback )CKEDITOR#loadTemplatesLoads files that contains templates' collection definition.
Parameters
templateFiles : String[]Array of files' paths.
callback : FunctionFunction to be run after loading all files.
-
on( eventName, listenerFunction, [ scopeObj ], [ listenerData ], [ priority ] ) → ObjectCKEDITOR#onRegisters 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 calledNote: 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 : StringThe event name to which listen.
listenerFunction : FunctionThe function listening to the event. A single CKEDITOR.eventInfo object instanced is passed to this function containing all the event data.
[ scopeObj ] : ObjectThe object used to scope the listener call (the
thisobject). If omitted, the current object is used.[ listenerData ] : ObjectData to be sent as the CKEDITOR.eventInfo.listenerData when calling the listener.
[ priority ] : NumberThe listener priority. Lower priority listeners are called first. Listeners with the same priority value are called in registration order.
Defaults to
10
Returns
ObjectAn object containing the
removeListenerfunction, which can be used to remove the listener at any time.
-
once()CKEDITOR#onceSimiliar with on but the listener will be called only once upon the next event firing.
-
removeAllListeners()CKEDITOR#removeAllListenersRemove all existing listeners on this object, for cleanup purpose.
-
removeListener( eventName, listenerFunction )CKEDITOR#removeListenerUnregisters 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 : StringThe event name.
listenerFunction : FunctionThe listener function to unregister.
-
replace( element, [ config ] ) → editor | Function | nullCKEDITOR#replaceReplaces 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, theirinnerHTMLwill 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 );Since 4.17 this function also supports the Delayed Editor Creation feature allowing to postpone the editor initialization.
Since 4.19 if the editor has been configured to use the Delayed Editor Creation feature and the editor has not been initialized yet, this function will return a handle allowing to cancel the interval set by the CKEDITOR.config.delayIfDetached and CKEDITOR.config.delayIfDetached_interval options.
var cancelInterval = CKEDITOR.replace( 'editor', { delayIfDetached: true, delayIfDetached_interval: 50 // Default value, you can skip that option. } ); cancelInterval(); // Cancel editor initialization if needed.It is recommended to use this function to prevent potential memory leaks. Use it if you know that the editor host element will never be attached to the DOM. As an example, execute cancel handle in your component cleanup logic (e.g.
onDestroylifecycle methods in popular frontend frameworks).Read more about this feature in the documentation.
Parameters
element : Object | StringThe DOM element (textarea), its ID, or name.
[ config ] : ObjectThe specific configuration to apply to this editor instance. Configuration set here will override the global CKEditor settings (see CKEDITOR.config).
Returns
editor | Function | nullThe editor instance or a cancellation function. If Delayed Editor Creation feature has not been set and element is missing in DOM, this function will return
null.
-
replaceAll( [ className ], [ evaluator ] )CKEDITOR#replaceAllReplaces 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>Since 4.17 this function also supports the Delayed Editor Creation feature allowing to postpone the editor initialization. Read more about this feature in the documentation.
Parameters
[ className ] : StringThe
<textarea>class name.[ evaluator ] : FunctionAn evaluation function that must return
truefor a<textarea>to be replaced with the editor. If the function returnsfalse, the<textarea>element will not be replaced.
-
Warning reporting function. When verbosity has the VERBOSITY_WARN flag set, it fires the event-log event with type set to
warn. Fired event contains also providederrorCodeandadditionalData.Parameters
errorCode : StringError code describing reported problem.
[ additionalData ] : ObjectAdditional data associated with reported problem.
-
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 : editorThe editor instance to be removed.
Static methods
-
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 : ObjectThe object into which implement the features.
Events
-
ariaWidget( evt )CKEDITOR#ariaWidget -
currentInstance( evt )CKEDITOR#currentInstanceFired 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 )CKEDITOR#dialogDefinitionEvent 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
-
instanceCreated( evt )CKEDITOR#instanceCreatedEvent fired when a CKEDITOR instance is created, but still before initializing it. To interact with a fully initialized instance, use the instanceReady event instead.
Parameters
evt : eventInfo
-
instanceDestroyed( evt )CKEDITOR#instanceDestroyed -
instanceLoaded( evt )CKEDITOR#instanceLoadedEvent 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.
Parameters
evt : eventInfo
-
instanceReady( evt )CKEDITOR#instanceReadyEvent fired when a CKEDITOR instance is created, fully initialized and ready for interaction.
Parameters
evt : eventInfo
-
loaded( evt )CKEDITOR#loadedFired when a CKEDITOR core object is fully loaded and ready for interaction.
Parameters
evt : eventInfo
-
Fired by warn and error methods. Default listener logs provided information to the console.
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
-
reset( evt )CKEDITOR#resetFired when the last instance has been destroyed. This event is used to perform global memory cleanup.
Parameters
evt : eventInfo