# CKEditor 3.0 JavaScript API Documentation

Code Index | File Index

## Namespaces

- CKEDITOR
- CKEDITOR.ajax
- CKEDITOR.config
- CKEDITOR.dom
- CKEDITOR.dtd
- CKEDITOR.env
- CKEDITOR.imageCacher
- CKEDITOR.loader
- CKEDITOR.plugins
- CKEDITOR.resourceManager
- CKEDITOR.scriptLoader
- CKEDITOR.skins
- CKEDITOR.test
- CKEDITOR.themes
- CKEDITOR.tools

## Classes

- CKEDITOR.commandDefinition
- CKEDITOR.dialog
- CKEDITOR.dialog.buttonDefinition
- CKEDITOR.dialog.contentDefinition
- CKEDITOR.dialog.contentDefinitionObject
- CKEDITOR.dialog.dialogDefinition
- CKEDITOR.dialog.dialogDefinitionObject
- CKEDITOR.dialog.uiElementDefinition
- CKEDITOR.dialogCommand
- CKEDITOR.dom.document
- CKEDITOR.dom.domObject
- CKEDITOR.dom.element
- CKEDITOR.dom.event
- CKEDITOR.dom.node
- CKEDITOR.dom.selection
- CKEDITOR.dom.text
- CKEDITOR.dom.window
- CKEDITOR.editor
- CKEDITOR.event
- CKEDITOR.eventInfo
- CKEDITOR.focusManager
- CKEDITOR.htmlParser
- CKEDITOR.htmlParser.cdata
- CKEDITOR.htmlParser.comment
- CKEDITOR.htmlParser.element
- CKEDITOR.htmlParser.fragment
- CKEDITOR.htmlParser.text
- CKEDITOR.htmlWriter
- CKEDITOR.keystrokeHandler
- CKEDITOR.pluginDefinition
- CKEDITOR.ui
- CKEDITOR.ui.button
- CKEDITOR.ui.dialog.button
- CKEDITOR.ui.dialog.checkbox
- CKEDITOR.ui.dialog.file
- CKEDITOR.ui.dialog.fileButton
- CKEDITOR.ui.dialog.hbox
- CKEDITOR.ui.dialog.html
- CKEDITOR.ui.dialog.labeledElement
- CKEDITOR.ui.dialog.radio
- CKEDITOR.ui.dialog.select
- CKEDITOR.ui.dialog.textarea
- CKEDITOR.ui.dialog.textInput
- CKEDITOR.ui.dialog.uiElement
- CKEDITOR.ui.dialog.vbox
- CKEDITOR.ui.handlerDefinition
- CKEDITOR.xml

# Namespace CKEDITOR

This is the API entry point. The entire CKEditor code runs under this object.
Defined in: core/ckeditor_base.js.

Namespace Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| CKEDITOR This is the API entry point.

Constants Summary
Constant Attributes | Constant Name and Description
--- | ---
<static> | CKEDITOR.ALT ALT key (4000).
<static> | CKEDITOR.CTRL CTRL key (1000).
<static> | CKEDITOR.DIALOG_RESIZE_HEIGHT Only allow vertical resizing for this dialog, disable horizontal resizing.
<static> | CKEDITOR.DIALOG_RESIZE_NONE No resize for this dialog.
<static> | CKEDITOR.DIALOG_RESIZE_WIDTH Only allow horizontal resizing for this dialog, disable vertical resizing.
<static> | CKEDITOR.ELEMENT_MODE_APPENDTO The editor is to be created inside the element.
<static> | CKEDITOR.ELEMENT_MODE_NONE No element is linked to the editor instance.
<static> | CKEDITOR.ELEMENT_MODE_REPLACE The element is to be replaced by the editor instance.
<static> | CKEDITOR.NODE_COMMENT Comment node type.
<static> | CKEDITOR.NODE_ELEMENT Element node type.
<static> | CKEDITOR.NODE_TEXT Text node type.
<static> | CKEDITOR.SELECTION_ELEMENT Element selection.
<static> | CKEDITOR.SELECTION_NONE No selection.
<static> | CKEDITOR.SELECTION_TEXT Text or collapsed selection.
<static> | CKEDITOR.SHIFT SHIFT key (2000).
<static> | CKEDITOR.TRISTATE_DISABLED Used to indicate DISABLED state.
<static> | CKEDITOR.TRISTATE_OFF Used to indicate the OFF or NON ACTIVE state.
<static> | CKEDITOR.TRISTATE_ON Used to indicate the ON or ACTIVE state.
<static> | CKEDITOR.UI_BUTTON Button UI element.
<static> | CKEDITOR.UI_MENUBUTTON Button UI element.
<static> | CKEDITOR.UI_PANEL Panel UI element.
<static> | CKEDITOR.UI_PANELBUTTON Button UI element.
<static> | CKEDITOR.UI_RICHCOMBO Button UI element.

Field Summary
Field Attributes | Field Name and Description
--- | ---
<static> | CKEDITOR.basePath Contains the full URL for the CKEditor installation directory.
<static> | CKEDITOR.document The document of the window holding the CKEDITOR object.
<static> | CKEDITOR.instances Holds references to all editor instances created.
<static> | CKEDITOR.loadFullCoreTimeout The time to wait (in seconds) to load the full editor code after the page load, if the "ckeditor_basic" file is used.
<static> | CKEDITOR.replaceByClassEnabled Enables the replacement of all textareas with class name matching CKEDITOR.replaceClass.
<static> | CKEDITOR.replaceClass The class name used to identify <textarea> elements to be replace by CKEditor instances.
<static> | CKEDITOR.revision Contains the CKEditor revision number.
<static> | CKEDITOR.START Check boundary types.
<static> | CKEDITOR.status Indicates the API loading status.
<static> | CKEDITOR.timestamp A constant string unique for each release of CKEditor.
<static> | CKEDITOR.version Contains the CKEditor version number.

Method Summary
Method Attributes | Method Name and Description
--- | ---
<static> | CKEDITOR.add(editor) Adds an editor instance to the global CKEDITOR object.
<static> | CKEDITOR.addStylesSet(name, styles)
<static> | CKEDITOR.addTemplates(name, definition)
<static> | CKEDITOR.appendTo(elementOrId, config) Creates a new editor instance inside a specific DOM element.
<static> | CKEDITOR.command(editor, commandDefinition)
<static> | CKEDITOR.exec(data)
<static> | CKEDITOR.getClipboardData()
<static> | CKEDITOR.getTemplates(name)
<static> | CKEDITOR.getUrl(resource) Gets the full URL for CKEditor resources.
<static> | CKEDITOR.htmlDataProcessor(editor)
<static> | CKEDITOR.loadFullCore() Forces the full CKEditor core code, in the case only the basic code has been loaded (ckeditor_basic.js).
<static> | CKEDITOR.loadStylesSet(name, url, callback)
<static> | CKEDITOR.loadTemplates(templateFiles, callback)
<static> | CKEDITOR.remove(editor) Removes and editor instance from the global CKEDITOR object.
<static> | CKEDITOR.replace(elementOrIdOrName, config) Replaces a <textarea> or a DOM element (DIV) with a CKEditor instance.
<static> | CKEDITOR.replaceAll() Replace all <textarea> elements available in the document with editor instances.
<static> | CKEDITOR.style(styleDefinition, variablesValues)
<static> | CKEDITOR.styleCommand(style)
<static> | CKEDITOR.unlinkCommand()

Namespace Detail
CKEDITOR
Since: 3.0
This is the API entry point. The entire CKEditor code runs under this object.
Field Detail
<static> {String} CKEDITOR.basePath
Since: 3.0
Contains the full URL for the CKEditor installation directory. It's 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 );  // "http://www.example.com/ckeditor/" (e.g.)

<static> {Undefined} CKEDITOR.document
Since: 3.0
The document of the window holding the CKEDITOR object.
Defined in: core/ckeditor.js.

    alert( CKEDITOR.document.getBody().getName() );  // "body"

<static> {Undefined} CKEDITOR.instances
Since: 3.0
Holds references to all editor instances created. The name of the properties in this object correspond to instance names, and their values contains the CKEDITOR.editor object representing them.
Defined in: core/ckeditor.js.

    alert( CKEDITOR.instances.editor1.name );  // "editor1"

<static> {Number} CKEDITOR.loadFullCoreTimeout
Since: 3.0
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.
Defined in: core/ckeditor_basic.js.

    // Loads the full source after five seconds.
    CKEDITOR.loadFullCoreTimeout = 5;

Default Value:
  0 (zero)

<static> {Boolean} CKEDITOR.replaceByClassEnabled
Since: 3.0
Enables the replacement of all textareas with class name matching CKEDITOR.replaceClass.
Defined in: core/ckeditor_basic.js.

    // Disable the auto-replace feature.
    CKEDITOR.replaceByClassEnabled = false;

Default Value:
  true

<static> {String} CKEDITOR.replaceClass
Since: 3.0
The class name used to identify <textarea> elements to be replace by CKEditor instances.
Defined in: core/ckeditor_basic.js.

    CKEDITOR.replaceClass = 'rich_editor';

Default Value:
  'ckeditor'

<static> {String} CKEDITOR.revision
Since: 3.0
Contains the CKEditor revision number. Revision number is incremented automatically after each modification of CKEditor source code.

    alert( CKEDITOR.revision );  // e.g. '3975'

<static> {Undefined} CKEDITOR.START
Since: 3.0
Check boundary types.
Defined in: core/dom/range.js.

    NO EXAMPLE AVAILABLE

See:
  CKEDITOR.dom.range::checkBoundaryOfElement

<static> {String} CKEDITOR.status
Since: 3.0
Indicates the API loading status. The following status 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.
- loading: the full API is being loaded.
- ready: the API can be fully used.

    if ( CKEDITOR.status == 'ready' )
    {
        // The API can now be fully used.
    }

<static> {String} CKEDITOR.timestamp
Since: 3.0
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, guaranteing clean cache results when upgrading.

    alert( CKEDITOR.timestamp );  // e.g. '87dm'

<static> {String} CKEDITOR.version
Since: 3.0
Contains the CKEditor version number.

    alert( CKEDITOR.version );  // e.g. 'CKEditor 3.0 Beta'

Method Detail
<static> {Undefined} CKEDITOR.add(editor)
Since: 3.0
Adds an editor instance to the global CKEDITOR object. This function is available for internal use mainly.
Defined in: core/ckeditor.js.

Parameters:
{CKEDITOR.editor} editor
  The editor instance to be added.

<static> {Undefined} CKEDITOR.addStylesSet(name, styles)
Since: 3.0
Defined in: plugins/stylescombo/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} name
{Undefined} styles

<static> {Undefined} CKEDITOR.addTemplates(name, definition)
Since: 3.0
Defined in: plugins/templates/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} name
{Undefined} definition

<static> {CKEDITOR.editor} CKEDITOR.appendTo(elementOrId, config)
Since: 3.0
Creates a new editor instance inside a specific DOM element.
Defined in: core/ckeditor_basic.js.

    <div id="editorSpace"><:/div>
    ...
    CKEDITOR.appendTo( 'editorSpace' );

Parameters:
{Object|String} elementOrId
  The DOM element or its ID.
{Object} config Optional
  The specific configurations to apply to this editor instance. Configurations set here will override global CKEditor settings.

Returns:
  {CKEDITOR.editor} The editor instance created.

<static> {Undefined} CKEDITOR.command(editor, commandDefinition)
Since: 3.0
Defined in: core/command.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} editor
{Undefined} commandDefinition

<static> {Undefined} CKEDITOR.exec(data)
Since: 3.0
Defined in: core/command.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} data

<static> {Undefined} CKEDITOR.getClipboardData()
Since: 3.0
Defined in: plugins/pastetext/plugin.js.

    NO EXAMPLE AVAILABLE

<static> {Undefined} CKEDITOR.getTemplates(name)
Since: 3.0
Defined in: plugins/templates/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} name

<static> {String} CKEDITOR.getUrl(resource)
Since: 3.0
Gets the full URL for CKEditor resources. By default, URLs returned by this function contains a querystring parameter ("t") set to the CKEDITOR.timestamp value. It's possible to provide a custom implementation to 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, 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:
{Undefined} resource

Returns:
  {String} The full URL.

<static> {Undefined} CKEDITOR.htmlDataProcessor(editor)
Since: 3.0
Defined in: plugins/htmldataprocessor/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} editor

<static> {Undefined} CKEDITOR.loadFullCore()
Since: 3.0
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.
Defined in: core/ckeditor_basic.js.

    // Check if the full core code has been loaded and load it.
    if ( CKEDITOR.loadFullCore )
        CKEDITOR.loadFullCore();

<static> {Undefined} CKEDITOR.loadStylesSet(name, url, callback)
Since: 3.0
Defined in: plugins/stylescombo/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} name
{Undefined} url
{Undefined} callback

<static> {Undefined} CKEDITOR.loadTemplates(templateFiles, callback)
Since: 3.0
Defined in: plugins/templates/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} templateFiles
{Undefined} callback

<static> {Undefined} CKEDITOR.remove(editor)
Since: 3.0
Removes and editor instance from the global CKEDITOR object. his function is available for internal use mainly.
Defined in: core/ckeditor.js.

Parameters:
{CKEDITOR.editor} editor
  The editor instance to be added.

<static> {CKEDITOR.editor} CKEDITOR.replace(elementOrIdOrName, config)
Since: 3.0
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, their innerHTML will be used instead. We recommend using TEXTAREA and DIV elements only.
Defined in: core/ckeditor_basic.js.

    <textarea id="myfield" name="myfield"><:/textarea>
    ...
    CKEDITOR.replace( 'myfield' );

    var textarea = document.body.appendChild( document.createElement( 'textarea' ) );
    CKEDITOR.replace( textarea );

Parameters:
{Object|String} elementOrIdOrName
  The DOM element (textarea), its ID or name.
{Object} config Optional
  The specific configurations to apply to this editor instance. Configurations set here will override global CKEditor settings.

Returns:
  {CKEDITOR.editor} The editor instance created.

<static> {Undefined} CKEDITOR.replaceAll()
Since: 3.0
Replace all <textarea> elements available in the document with editor instances.
Defined in: core/ckeditor_basic.js.

    // 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 custom assertions.
    CKEDITOR.replaceAll( function( textarea, config )
        {
            // Custom code to evaluate the replace, returning false
            // if it must not be done.
            // It also passes the "config" parameter, so the
            // developer can customize the instance.
        } );

<static> {Undefined} CKEDITOR.style(styleDefinition, variablesValues)
Since: 3.0
Defined in: plugins/styles/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} styleDefinition
{Undefined} variablesValues

<static> {Undefined} CKEDITOR.styleCommand(style)
Since: 3.0
Defined in: plugins/styles/plugin.js.

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} style

<static> {Undefined} CKEDITOR.unlinkCommand()
Since: 3.0
Defined in: plugins/link/plugin.js.

    NO EXAMPLE AVAILABLE

Copyright © 2003-2009, CKSource - Frederico Knabben. All rights reserved.