JavaScript API"

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

Line 16: Line 16:
  
 
Both methods return the main FCKeditor object that gives the necessary bridge to interact with it. These are the most useful properties and methods of this object:
 
Both methods return the main FCKeditor object that gives the necessary bridge to interact with it. These are the most useful properties and methods of this object:
<pre>
+
 
 
Properties:
 
Properties:
* Name = (string) The instance name.
+
 
* Status = (integer) The editor status (loading status).
+
* '''Name = (string)''' - the instance name.
* EditorDocument = (object) The DOM Document object for the editing area.
+
* '''Status = (integer)''' - the editor status (loading status).
* EditorWindow = (object) The DOM Window object for the editing area.
+
* '''EditorDocument = (object)''' - the DOM Document object for the editing area.
 +
* '''EditorWindow = (object)''' - the DOM Window object for the editing area.
 +
 
 
Methods:
 
Methods:
* AttachToOnSelectionChange( functionPointer )
+
 
* Focus()
+
* '''AttachToOnSelectionChange( functionPointer )'''
* GetXHTML( formatted )
+
* '''Focus()'''
* InsertElement(element)
+
* '''GetXHTML( formatted )'''
* InsertElementAndGetIt(e)
+
* '''InsertElement(element)'''
* InsertHtml(html) // Inserts HTML in the current cursor position
+
* '''InsertElementAndGetIt(e)'''
* IsDirty() // Checks if the content in the editor has been changed
+
* '''InsertHtml(html)''' - inserts HTML in the current cursor position
* MakeEditable()
+
* '''IsDirty()''' - checks if the content in the editor has been changed
* ResetIsDirty() // Resets the dirty state
+
* '''MakeEditable()'''
* SetHTML( html ) // Sets the contents of the editor
+
* '''ResetIsDirty()''' - resets the dirty state
    // Note that when using this method, you will loose any listener that you
+
* '''SetHTML( html )''' - sets the contents of the editor. Note that when using this method, you will loose any listener that you may have previously registered on the editor.EditorDocument.
    // may have previously registered on the editor.EditorDocument.
+
* '''GetHTML()''' - retrieves the edited html from the editor.
* GetHTML() // retrieves the edited html from the editor.
+
* '''SwitchEditMode()'''
* SwitchEditMode()
+
* '''UpdateLinkedField()'''
</pre>
 

Revision as of 12:46, 18 January 2008

FCKeditor JavaScript API

FCKeditor offers a complete JavaScript API so you can interact with it once the editor is loaded and running.

Once loaded, the editor registers a global object called FCKeditorAPI. This object offers the entry point to interact with any editor instance placed in a page (you can have more than one).

NOTE: The FCKeditorAPI object will not be available during the page load. You need to wait for the editor to be loaded to use it. If you need to interact with the editor right after is has been loaded, use the "FCKeditor_OnComplete" function (see "Events").

Retrieving an Editor Instance

  • From out of an external script
    When placing the editor in the page, you give it an "instance name". To retrieve it, you must simply call the FCKeditorAPI.GetInstance method.
    Example:
    var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;
  • From out of a dialog of the editor
    Call the InnerDialogLoaded to get the FCKObject.
    Example:
    var oEditor = window.parent.InnerDialogLoaded().FCK ;

Both methods return the main FCKeditor object that gives the necessary bridge to interact with it. These are the most useful properties and methods of this object:

Properties:

  • Name = (string) - the instance name.
  • Status = (integer) - the editor status (loading status).
  • EditorDocument = (object) - the DOM Document object for the editing area.
  • EditorWindow = (object) - the DOM Window object for the editing area.

Methods:

  • AttachToOnSelectionChange( functionPointer )
  • Focus()
  • GetXHTML( formatted )
  • InsertElement(element)
  • InsertElementAndGetIt(e)
  • InsertHtml(html) - inserts HTML in the current cursor position
  • IsDirty() - checks if the content in the editor has been changed
  • MakeEditable()
  • ResetIsDirty() - resets the dirty state
  • SetHTML( html ) - sets the contents of the editor. Note that when using this method, you will loose any listener that you may have previously registered on the editor.EditorDocument.
  • GetHTML() - retrieves the edited html from the editor.
  • SwitchEditMode()
  • UpdateLinkedField()