FCKeditor offers a complete JavaScript API so, can interact with it once the editor is loaded and running.
FCKeditor provides a complete JavaScript API (Application public Interface) that you can use to process the FCK editor as long as it is loaded or running.
Retrieving an editor instanceonce loaded, the editor registers a global object called Fckeditorapi. This object offers the "entry" to interact and any editor instance placed in a page (for you, can have more than one). When placing the ' editor in ' page, you give it ' instance name '. So, to retrieve it, your must simply call the Fckeditorapi.getinstance method.
Once the editor is instantiated, it registers a global object called Fckeditorapi. This object provides an access point to obtain any instantiated objects (more than one) on this page. When you create an editor on the page, you give it an instance name. So you can simply call the Fckeditorapi.getinstance method to get its object reference.
For Example:var oeditor = fckeditorapi.getinstance (' instancename ');
For example, var oeditor = fckeditorapi.getinstance (' instancename '); This is the FCKeditor object that gets the instance named "InstanceName".
The GetInstance method returns the main FCKeditor object, gives the necessary bridge to interact with it.
This are a list of properties and methods of this object:
This is a list of FCKeditor properties and methods:
Copy Code code as follows:
* Description = string description
* EditMode = Integer Edit State
* Name = string name
* Status = Integer status
* Function Attachtoonselectionchange (functionpointer)
* Function Cleanandpaste (HTML)
* Function createelement (TAG)
* function Createlink (URL)
* Function Execonselectionchange ()//fires Onselectionchange event in Event Manager
* Function Execonselectionchangetimer ()
* Function Executenamedcommand (commandName, CommandParameter)
* Function Executeredirectednamedcommand (commandName, CommandParameter)
* Function focus ()
* Function gethtml (format)//doesnt work. Use getxhtml instead.
* Function Getnamedcommandstate (commandName)
* Function Getnamedcommandvalue (commandName)
* Function getxhtml (format)
* Function Initializebehaviors ()
* Function insertelement (Element)
* Function Insertelementandgetit (e)
* Function inserthtml (HTML)
* function IsDirty ();
* Function makeeditable ()
* Function OnDoubleClick (Element)
* Function Paste ()
* Function Pasteasplaintext ()
* Function Pastefromword ()
* Function Preview ()
* Function Registerdoubleclickhandler (handlerfunction, tag)
* function Resetisdirty ();
* Function sethtml (HTML, FORCEWYSIWYG)
* Function SetStatus ()
* Function ShowContextMenu (x, y)
* Function Switcheditmode ()
* Function Updatelinkedfield ()
Eventsonce the editor loading is complete and it are ready to use (and interact with JavaScript), a standard function is CA Lled in the page this contains the editor, if the function is defined.
This function must is named "Fckeditor_oncomplete" and receives the related editor as the instance. Using it, you can execute any initial code which is makes the initial interaction with the editor.
This is a declaration example:
function Fckeditor_oncomplete (editorinstance) {
alert (editorinstance.name); }
Apart the above standard event, every FCKeditor instance has a "event" object that can is used to listen for events to be Fired.
For example, the following code listens for the ' Onselectionchange ' to execute custom code:
var counter = 0;
function DoSomething (editorinstance) {
Window.document.title = Editorinstance.name + ': ' + (++counter); }
function Fckeditor_oncomplete (editorinstance) {
EditorInstance.Events.AttachEvent (' Onselectionchange ', dosomething); }
Note that every callback function receives the editor instance as a parameter.
The following is the list of events available:
Onselectionchange:fired when the actual selection into the editor area changes (by selection I mean the cursor position ... it changes on key strokes). Note:in IE6, this event does not fire on every keystroke, but only on some random. handy!
Onaftersethtml:fired once the HTML is loaded in the editor (including while changing views).
Onstatuschange:fired when the editor status changes. The following constants are also available globally in the page:fck_status_notloaded, Fck_status_active and Fck_status_co Mplete.
Onpaste:fired when something are pasted in the editor
Configuration options:
Autodetectlanguage=true/false Automatic Detection language
basehref= "" _fcksavedurl= "" "" "relative to the base address of the link
contentlangdirection= "Ltr/rtl" Default text direction
contextmenu= string array, right-click the contents of the menu
Customconfigurationspath= "" Custom profile path and name
Debug=true/false whether debugging is turned on, so that when Fckdebug.output () is invoked, the contents are output in the debug window
Defaultlanguage= "" Default language
editorareacss= the style sheet file in the edit area
When Enablesourcexhtml=true/false is true, HTML is processed as XHTML when switched from a visual interface to a code page
Enablexhtml=true/false whether to allow XHTML to be used instead of HTML
Fillemptyblocks=true/false uses this feature to replace empty block-level elements with empty cells
fontcolors= Set the text color list when the color picker is displayed
Fontformats= the name of the display in a list of text formats
fontnames= the font name in the Font list
fontsizes= a list of font sizes in the font size
Forcepasteasplaintext=true/false forced Paste as plain text
Forcesimpleampersand=true/false whether to convert & symbols to XML entities
Formatindentator= "" When you indent code in source format using characters
Formatoutput=true/false whether the code is automatically formatted when the content is output
Formatsource=true/false automatically format code when switching to Code view
Fullpage=true/false whether to allow editing of the entire HTML file, or only to edit the content between the body
Geckousespan=true/false whether span markers are allowed instead of b,i,u tags
Iespelldownloadurl= "" Download the address of the spelling checker
Imagebrowser=true/false whether to allow browsing of server features
Imagebrowserurl= the URL to run when browsing the server
imagebrowserwindowheight= "" Image browser window height
Imagebrowserwindowwidth= "" Image browser window width
Linkbrowser=true/false whether the server is allowed to browse when the link is inserted
Linkbrowserurl= the URL of the server when inserting a link
linkbrowserwindowheight= "" Link target browser window height
Linkbrowserwindowwidth= "" Link target browser window width
Plugins=object Registration Plugin
Pluginspath= "" Plug-in folder
Showborders=true/false merge borders
Skinpath= "" Skin folder location
smileycolumns=12 Number of Chart window columns
Array of picture filenames in smileyimages= character array
Smileypath= "" "" "" "" "" "
Smileywindowheight Picture Window Height
Smileywindowwidth Picture Window width
Spellchecker= "Iespell/spellerpages" to set the spelling checker
Focus to editor when Startupfocus=true/false Open
Stylesxmlpath= "" Setting the location of the XML file that defines the list of CSS styles
Number of space characters produced by the Tabspaces=4 tab key
Toolbarcancollapse=true/false whether to allow expansion/collapse of toolbars
Toolbarsets=object allow use of toolbar collection
Toolbarstartexpanded=true/false Open is toolbar whether to unfold
Usebroncarriagereturn=true/false whether to generate a BR mark or a P or div tag when carriage return