FCKeditor offers a complete javascript API so you 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 point to interact with any editor instance placed in a page (you can have more than one ). when placing the editor in the page, you give it an "Instance name ". so, to retrieve it, you 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 object (more than one) on this page ). when you generate an editor on the page, you give it an Instance name. therefore, you only need to call the fckeditorapi. the getinstance method can obtain its object reference.
For example: var oeditor = fckeditorapi. getinstance ('instancename ');
For example, VAR oeditor = fckeditorapi. getinstance ('instancename'); here is the FCKeditor object named "instancename.
The getinstance method returns the main FCKeditor object that gives the necessary bridge to interact with it.
This is a list of properties and methods of this object:
This is a list of FCKeditor attributes and methods:
CopyCode The Code is as follows: * description = string description
* Editmode = integer editing status
* 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 is ready to use (and interact with JavaScript), a standard function is called in the page that contains the editor, if the function is defined.
This function must be named "fckeditor_oncomplete" and has es the related editor instance as the parameter. Using It, You can execute any initial code that 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 be 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 ){
Required parameter Doc ument. Title = editorinstance. Name + ':' + (++ counter );}
Function fckeditor_oncomplete (editorinstance ){
Editorinstance. Events. attachevent ('onselectionchang', dosomething );}
Note that every callback function has es the editor instance as a parameter.
The following is the list of events available:
Onselectionchange: fired when the actual selection in the editor area changes (by selection I mean the cursor position too... it changes on key strokes ). note: in IE6, this event does not fire on every keystroke, but only on some random keystrokes. handy!
Onaftersethtml: fired once the HTML is loaded in the editor (including when 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_complete.
Onpaste: fired when something is pasted in the editor
Configuration Options:
Autodetectlanguage = true/false automatic language Detection
Basehref = "" _ fcksavedurl = ": The base address of the Relative Link
Contentlangdirection = "LTR/RTL" default text direction
Contextmenu = string array, right-click the menu content
Customconfigurationspath = "" custom configuration file path and name
DEBUG = true/false whether to enable debugging. In this way, when fckdebug. Output () is called, the content is output in the debugging window.
Defaultlanguage = "" default language
Editorareacss = "" style table file in the editing area
When enablesourcexhtml = true/false is true, when the code page is switched from the visual interface to the code page, the HTML is processed as XHTML.
Enablexhtml = true/false: Can I use XHTML to replace HTML?
Fillemptyblocks = true/false use this function to replace empty block-level elements with spaces.
Fontcolors = "" sets the text color list when the color picker is displayed
Fontformats = "" set the name displayed in the text format list
Fontnames = "" fontnames
Fontsizes = "" font size in the font size list
Forcepasteasplaintext = true/false force paste to plain text
Forcesimpleampersand = true/false do not convert & symbol to XML Entity
Formatindentator = "" specifies the characters used to indent the code in the source code format.
Formatoutput = true/false: whether to automatically format the code when output content
Formatsource = true/false whether to automatically format the code when switching to the Code view
Fullpage = true/false: whether to allow editing of the entire HTML file or only the content between the bodies
Geckousespan = true/false: whether to allow the span flag to replace the B, I, u flag
Iespelldownloadurl = "" download the spelling checker URL
Imagebrowser = true/false: whether to allow browsing of server functions
Imagebrowserurl = "" the URL that runs when browsing the server
Imagebrowserwindowheight = "" image browser window height
Imagebrowser1_wwidth = "" image browser window width
Linkbrowser = true/false: whether to allow browsing the server when a link is inserted
Linkbrowserurl = "" browsing the server URL when inserting a link
Linkbrowserwindowheight = "" link target browser window height
Linkbrowserdomainwwidth = "" link target browser window width
Plugins = Object Registration plug-in
Pluginspath = "" plug-in folder
Showborders = true/false merge border
Skinpath = "" skin folder location
Smileycolumns = 12 Number of columns in the graphic operator window
Smileyimages = String Array array of image file names in the graphic character window
Smileypath = "" folder path
Smileywindowheight tumbler window height
Smiley1_wwidth tumbler window width
Spellchecker = "iespell/spellerpages" set the spelling checker
When startupfocus = true/false is enabled, focus to the editor.
Stylesxmlpath = "" set the location of the XML file that defines the CSS style list
Tabspaces = 4 Number of space characters generated by the tab key
Toolbarcancollapse = true/false: whether to enable or disable the toolbar.
Toolbarsets = the toolbar set can be used for objects.
Toolbarstartexpanded = true/false enable indicates whether to expand a toolbar.
Usebroncarriagereturn = true/false when you press enter, whether to generate a br mark or a P or Div mark