For example, although CUTEEDITOR is more powerful than FCKEDITOR, it is also huge enough. As for FREETEXTBOX, there is still a gap between its ease of use and FCKEDITOR, FCKEDITOR is an ingenious online editor that integrates the author's advanced object-oriented JAVASCRIPT capabilities and integrates ease of use and powerful functions.
All images, scripts, and call pages related to the editor
. Language file
. Editor skin file
. Tool-like textures, etc.
This will generate a considerable amount of traffic between the server and the client. If many files are called, even if each file is small, it will make users wait impatiently.
Loading Sequence
Starting from version 2.0, the editor loads resources by following these steps:
. Basic page (that is, the page where the editor is located) and JS script for loading the editor
. Used to create the editor script
The language and skin of the editor.
. Create an editor.
. Load the preset editing document content.
From now on, you can read and edit the document. However, drag-and-drop support and toolbar are unavailable.
. Load the editor engine script
. Create a toolbar and use it.
From now on, all the functions of the editor have been complete.
. Load toolbar icon
Script Compression
When any new version is packaged, the editor's JS script is preprocessed. The preprocessing steps are as follows:
. Remove all code comments
. Remove all useless white space characters.
. Merge the script into several files.
Using the above method, we can compress the script file to 50% of the original size.
After compression, the original code still exists in a folder named _ Source.
How to pack?
Then, copy it to the FCKEDITOR root folder and run it to automatically package and compress the JS script.
Note that this program is a. NET program and must be installed with. net framework.
Want to obtain support?
If you donate 15000 euros, you can get one year of free technical support (more expensive, equivalent to 0.15 million yuan, but the cost of Western Europe is quite amazing)
How to install?
1. download the latest FCKEDITOR version.
2. decompress the package to the FCKEDITOR folder in the root folder of your site (the name must be FCKEDITOR because the FCKEDITOR location has been identified in the configuration file)
3. Now, the editor can be used. To view the demo, you can access it as follows:
Http: // <your-site>/FCKeditor/_ samples/default.html
Note: You can place FCKEDITOR in any folder. By default, it is the easiest way to put FCKEDITOR in the folder. if the folder you put uses another name, modify the BasePath parameter in the configuration folder, as shown below:
OFckeditor. BasePath = "/Components/fckeditor /";
In addition, all the folders and files starting with the following line in the FCKEDITOR folder are optional and can be safely deleted from your release. They are not required when the editor is running.
How can I integrate FCKEDITOR into my page?
Currently, FCKEDITOR only provides JAVASCRIPT-based integration, so here we only show how to apply JAVASCRIPT to integrate FCKEDITOR into the site. Of course, the integration of other languages, you can refer to the example in the _ samples folder to complete
1. If the editor has been installed in the/FCKEDITOR/folder of your site. so, the first step we need to do is to add the SCRIPT tag in the header segment of the page to introduce the JAVASCRIPT integration module. for example:
<Script type = "text/javascript" src = "/fckeditor. js"> </script>
The path is changeable.
2. Now, the FCKEDITOR class can be used. There are two ways to create a FCKEDITOR editor on the page:
Method 1: inline (recommended): Insert the following code to the place where the editor needs to be inserted in the FORM tag of the page:
Script type = "text/javascript">
Var oFCKeditor = new FCKeditor ('fckeditor1 ');
OFCKeditor. Create ();
</Script>
Method 2: TEXTAREA tag replacement method (not recommended): In the ONLOAD event on the page, add the following code to replace an existing TEXTAREA tag.
<Html>
<Head>
<Script type = "text/javascript">
Window. onload = function ()
{
Var oFCKeditor = new FCKeditor ('mytextarea ');
OFCKeditor. ReplaceTextarea ();
}
</Script>
</Head>
<Body>
<Textarea id = "MyTextarea" name = "MyTextarea"> This is <B> the </B> initial value. </textarea>
</Body>
</Html>
3. Now, the editor can be used.
FCKEDITOR class reference:
The following describes the FCKEDITOR class used to create an editor on the page.
Constructor:
FCKeditor (instanceName [, width, height, toolbarSet, value])
InstanceName: Unique name of the Editor (equivalent to ID)
WIDTH: WIDTH
HEIGHT: HEIGHT
ToolbarSet: name of the toolbar set
Value: the initialization content of the editor.
Attribute:
InstanceName: Editor Instance name
Width: width. The default value is 100%.
Height: height. The default value is 200.
ToolbarSet: tool set name. For details, refer to FCKCONFIG. JS. The Default value is Default.
Value: Initialize the HTML code of the editor. The default value is null.
BasePath: The base path of the editor. The default path is/Fckeditor/folder. Be sure not to use the relative path. It is best to use the Representation Method Relative to the root path of the site and end /.
CheckBrowser: whether to check the browser compatibility before the editor is displayed. The default value is true.
DisplayErrors: Indicates whether an error is displayed. The default value is true;
Set:
Config [Key] = value;
This set is used to change the value of a configuration item, as shown in figure
OFckeditor. Config ["DefaultLanguage"] = "pt-br ";
Method:
Create ()
Create and output an editor
RepaceTextArea (TextAreaName)
Replace the text box with the editor
How to configure FCKEDITOR?
FCKEDITOR provides a set of settings for customizing its appearance, characteristics, and behavior. The main configuration file name is Fckconfig. js.
You can edit the main configuration file or define a separate configuration file. The configuration file uses the JAVASCRIPT syntax.
After modification, you can use the following syntax when creating an Editor:
Var oFCKeditor = new FCKeditor ('fckeditor1 ');
OFCKeditor. Config ['customconfigurationspath'] = '/myconfig. js ';
OFCKeditor. Create ();
Reminder: After you modify the configuration, clear the browser cache to view the effect.
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
How do I customize the style list?
The FCKEDITOR style toolbar provides predefined styles defined by the XML file. The default XML style file exists in the FckStyls. xml file in the FCkEditor root folder.
The structure of the XML file is analyzed as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Styles>
<Style name = "My Image" element = "img">
<Attribute name = "style" value = "padding: 5px"/>
<Attribute name = "border" value = "2"/>
</Style>
<Style name = "Italic" element = "em"/>
<Style name = "Title" element = "span">
<Attribute name = "class" value = "Title"/>
</Style>
<Style name = "Title H3" element = "h3"/>
</Styles>
Each STYLE tag defines a STYLE. NAME is the style name displayed in the drop-down list. The ELEMENT attribute specifies the objects applicable to this STYLE, because the STYLE in FCKEDITOR is context sensitive, that is, select different objects. Only the styles defined for these objects are displayed.
Spelling check
FCKEDITOR comes with two spell checking tools, ieSpell, which is used by default. This method requires the customer to download and install the small software iespell. In addition, spellPager is also provided for spelling checks. However, since SPELLPAGER is a server-side script compiled by PHP, your WEB server must support the PHP script language.
For more information about how to change the spelling checker, see the configuration file.
Compression script
To improve the efficiency of Script Loading, FCKEDITOR uses the following methods to compress the script as much as possible to reduce the script size:
1. Remove the comments from the script.
2. Remove the meaningless blank in the script.
In addition, FCKEDITOR provides a tool specifically used to compress scripts so that you can reduce the file size during release,
You can copy fckeditor.packager.exe in the _packagerfolder to the fckeditor root folder to run and compress the script.
Localized FCKEDITOR
If FCKEDITOR does not provide all the languages you need (actually all of them are available), you can create a new language by yourself.
, You only need to copy the EN. JS. in addition, the Language name and the corresponding script file name must follow the RFC 3066 standard, but must be in lower case. For example, the script file name corresponding to Portuguess Language must be pt. js
If you want to target a certain country, you can add a horizontal line and a country abbreviation after the abbreviation.
During use, the system automatically detects the client language and country and uses the appropriate interface language.
After creating a new language, you must create an entry for it in "Edit/lang/fcklanguagemanager. js", as shown below:
Fck1_agemanager. AvailableLanguages =
{
En: 'English ',
Pt: 'portranges'
}
Note that the file must be saved in UTF-8 format
How can I interact with server scripts?
Please check the example to get the relevant content
In addition, use the following steps in ASP. NET:
1. Add FCKEDITOR to the toolbox
2. Drag the FCKEDITOR Control to the page
3. Specify a name for it
4. all attributes of the FCKEDITOR class can be used not only in code, but also directly as attributes of the FCKEDITOR Control. For example, to change the skin, you can specify SkinPath = "/fckeditor/editor/skins/office2003" on the UI page. NET version can be better, you can find fckeditor asp. NET 2.1 source file, then modify the control design, expose more useful properties for it, and re-compile it.
5. Use the value Attribute of the FCKEDITOR Control to obtain the POSTBACK data.
6. due to the default status, ASP. NET does not allow the submission of HTML and JAVASCRIPT content. Therefore, you must set ValidateRequest to false for pages using FCKEDITOR. (<% @ page validteRequest = "false" %>)
Appendix:
I. How to set the language for uploading files
In the fckconfig. js file under the root directory of FCKeditor
Var _ FileBrowserLanguage = 'asp '; // asp | aspx | cfm | lasso | perl | php | py
Var _ QuickUploadLanguage = 'asp '; // asp | aspx | cfm | lasso | php
The two lines are changed to the editor language you need to call. If asp.net is used, it is changed to aspx;
2. Solve Chinese problems:
Add the following to web. config:
<Globalization requestEncoding = "GB2312" responseEncoding = "GB2312"/>
In this way, Chinese files can be displayed, but the URL address is also Chinese;
If the server does not parse the Chinese address properly, the image may not be browsed;
So modify: editor \ filemanager \ browser \ default \ frmresourceslist.html
In OpenFile function
Window. top. opener. SetUrl (fileUrl );
To:
Window. top. opener. SetUrl (escape (fileUrl ));
3. Set the upload directory:
1: Set in web. config:
<Deleetask>
<Add key = "FCKeditor: UserFilesPath" value = "/fck/UpLoad/"/>
</AppSettings>
2: Set in Session:
Add the following code to editor \ filemanager \ browser \ default \ connectors \ aspx \ connector. aspx:
<Script runat = "server" language = "C #">
Protected override void OnInit (EventArgs e)
{
Session ["FCKeditor: UserFilesPath"] = "/fck/UpLoad1 /";
}
</Script>
In asp.net, how does one dynamically set the path for uploading images?
1. Modify the value of FCKConfig. ImageBrowserURL in javascript as follows:
FCKConfig. ImageBrowserURL + = "? Path = Path of the file to be uploaded ";
For example, to upload a file to the UploadFile folder in the root directory of the site, set it:
FCKConfig. ImageBrowserURL + = "? Path =/UploadFile ";
2. Add the following program to the end of the "editor \ filemanager \ browser \ default \ connectors \ aspx \ connector. aspx" file:
<Script runat = "server" language = "C #">
Protected override void OnInit (EventArgs e)
{
If (Request. QueryString ["Path"] = null ){
Session ["FCKeditor: UserFilesPath"] = "/UpLoadFiles/"; // set the default value
} Else {
Session ["FCKeditor: UserFilesPath"] = Request. QueryString ["Path"];
}
}
</Script>
--------------------------------------------------------------------------------
Configuration and usage skills in multiple Environments
--------------------------------------------------------------------------------
Add right-click menu in fckeditor
I am going to introduce how to configure FCKEditor on the Internet. There are many examples of how to streamline it. If you need it, You can google it. I don't need to go into details here. Now we will introduce how to customize this editor, including how to add items on the toolbar, generate responses, and right-click the menu. It seems very easy!
The book is back to the beginning.
1. Custom right-click menu:
1. First, add the name of the toolbar item you want to add in editor/lang/zh-cn.js, this file defines a FCKLang variable, written in the format of the inside, such as: First: "1", note that if it is not in the penultimate line (the penultimate line is "}"), the comma at the end must exist. Otherwise, no editor will appear on the webpage, I have made such a low-level mistake. After waking up, I would like to say hello to a quiet mouth. We are Chinese, and naturally correspond to Chinese after the colon, this is what will be displayed on the web page in the future.
2. In the editor/_ source/internals/fckcommands. create a new command in js: case 'first': oCommand = new FCKFirstCommand ('first', FCKLang. first); does break pay attention to the FCKFirstCommand in the red font? This is a custom command. We will discuss it later.
3. Then, add a context menu in editor/_ source/internals/fckcontextmenu. js. In case 'generic ': Add the following: oGroup. add (new FCKContextMenuItem (this, 'first', FCKLang. first, true). If the fourth Boolean parameter is set to true, the menu has an icon, and vice versa. Here, I specify that my custom menu has a graphic icon, so I should put the icon under the editor \ skins \ xxx \ toolbar directory, among them, xxx is the skin of the editor you selected in your configuration file, but our icon name is learned and must be renewed. OK, so the right-click menu is added. Run your webpage to see if FCKEditor works? If it does not work, you need to refer to this article again ^_^.
4. Then, the most critical step is to upload the file!
5. Now we will discuss the FCKFirstCommand in step 2. After the menu is added, what functions do you have to have? Well, create this class in editor/_ source/commandclasses/fck_othercommands.js:
Four FCKeditor practical application skills
After a class is created, two static functions are created: xxx. prototype. Execute, xxx. prototype. GetState. The former is an event processing function, that is, all the functions to be executed by right-clicking the menu are written in this function, and the latter returns the menu status (available? Unavailable ?). To demonstrate this, we implement the simplest function: FCKPageCommand. prototype. Execute = function () {window. alert ("It works! ");} Is simple enough, but a prompt box is displayed. Of course, here we can also use the FCKFirstCommand defined by FCKEditor, for example, FCKDialogCommand, which is also defined in fck_othercommands.js. Of course, if so, A dialog box is displayed. Run the webpage again, right-click, and click your custom menu. Is a prompt box displayed?
FCKeditor has now reached version 2.3.1. For WEB developers in China, it has basically been "How much is known", and many people have integrated it into their own projects, many other large websites have benefited from this. Starting today, I will give a little introduction to some of the techniques I have summarized during the use of FCKeditor. Of course, these are actually what FCK originally has, but they are not found when many people use FCK.
1. Open the editor in due time
Most of the time, you do not need to open the editor directly when opening the page, but only open it when you use it. This gives you a good user experience, on the other hand, it can eliminate the impact of FCK on the page opening speed during loading,
Click "Open Editor" to Open the Editor interface.
Implementation principle: Use the javascript fck to create a hidden TextArea domain during page loading (without enabling FCK, the name and ID of this TextArea must be the same as the name of the created FCK instance. When you click the "Open Editor" button, you can call a function to create FCKeditor using the ReplaceTextarea () method of FCK, the Code is as follows:
<Script type = "text/javascript">
<! --
Function showFCK (){
Var oFCKeditor = new FCKeditor ('fbcontent ');
OFCKeditor. BasePath = '/FCKeditor /';
OFCKeditor. ToolbarSet = 'basic ';
OFCKeditor. Width = '000000 ';
OFCKeditor. Height = '20140901 ';
OFCKeditor. ReplaceTextarea ();
}
// -->
</Script>
<Textarea name = "fbContent" id = "fbContent"> <textarea>
2. Use the FCKeditor API
The FCKeditor Editor provides a rich set of APIs to implement many customized functions for End users, such as basic data verification, the fck api provides the GetLength () method to determine whether content exists in the current editor area by using JS when submitting the file;
For example, how to insert content to FCK through a script and use InsertHTML;
Also, when you customize features, the intermediate steps may need to execute some nested FCK operations, so use the ExecuteCommand () method.
For a detailed list of APIS, see the FCKeditor Wiki. For common APIs, see _ samples/html/sample08.html in the fck compressed package. No code is pasted here.
3. external editing bar (multiple editing fields share one editing bar)
This feature is provided only in Version 2.3. If FCKeditor of the previous version uses multiple editors on the same page, it must be created one by one. Now, this external function is available, you don't have to worry about it. You just need to place the toolbar in a proper position, and then you can create and edit domains without restrictions,
To implement this function, you must first define the container of a toolbar in the page: <divid = "xToolbar"> </div>, and then set it based on the container id attribute.
ASP implementation code: <div id = "fckToolBar"> </div>
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
With oFCKeditor
. BasePath = fckPath
. Config ("ToolbarLocation") = "Out: fckToolBar"
. ToolbarSet = "Basic"
. Width = "100%"
. Height = "200"
. Value = ""
. Create "jcontent"
. Height = "150"
. Value = ""
. Create "jreach"
End
%>
JAVASCRIPT implementation code: <div id = "xToolbar"> </div>
FCKeditor 1:
<Script type = "text/javascript">
<! --
// Automatically calculates the editor base path based on the _ samples directory.
// This is usefull only for these samples. A real application shoshould use something like this:
// OFCKeditor. BasePath = '/fckeditor/'; // '/fckeditor/' is the default value.
Var sBasePath = document. location. pathname. substring (0, document. location. pathname. lastIndexOf ('_ samples '));
Var oFCKeditor = new FCKeditor ('fckeditor _ 1 ');
OFCKeditor. BasePath = sBasePath;
OFCKeditor. Height = 100;
OFCKeditor. Config ['toolbarlocation'] = 'out: parent (xToolbar )';
OFCKeditor. Value = 'this is some <strong> sample text </strong>. You are using FCKeditor .';
OFCKeditor. Create ();
// -->
</Script>
<Br/>
FCKeditor 2:
<Script type = "text/javascript">
<! --
OFCKeditor = new FCKeditor ('fckeditor _ 2 ');
OFCKeditor. BasePath = sBasePath;
OFCKeditor. Height = 100;
OFCKeditor. Config ['toolbarlocation'] = 'out: parent (xToolbar )';
OFCKeditor. Value = 'this is some <strong> sample text </strong>. You are using FCKeditor .';
OFCKeditor. Create ();
// -->
</Script>
For detailed demos in this section, refer:
_ Samples/html/sample11.html
_ Samples/html/sample11_frame.html
4. File Management and file upload Permissions
The security of file management in FCKeditor is worth noting, but many people have not noticed it, although FCKeditor has always been used to filter the types of uploaded files in each Release version, she has not considered another question: Who can upload files? Who can browse server files?
I encountered this problem when I first started using FCKeditor. Fortunately, NetRube (author of The FCKeditor culture and FCKeditor ASP upload program) promptly reminded me, the method is to modify the FCK upload program, perform permission judgment in it, and then in fckconfig. remove some functions from js. However, with the constant upgrade of the FCK version, the configuration program fckconfig. js needs to be changed once every upgrade. I find bored, so there is no way to better control this configuration? Actually, there is.
In fckconfig. js, there are settings about whether to enable the upload and browsing server. When creating FCKeditor, you can use a program to determine whether to create an editor with the upload and browsing function. First, I first set all the upload and browsing settings to false in fckconfig. js. Then I use the following code:
ASP version: <%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
With oFCKeditor
. BasePath = fckPath
. Config ("ToolbarLocation") = "Out: fckToolBar"
If request. cookies (site_sn) ("issuper") = "yes" then
. Config ("LinkBrowser") = "true"
. Config ("ImageBrowser") = "true"
. Config ("FlashBrowser") = "true"
. Config ("LinkUpload") = "true"
. Config ("ImageUpload") = "true"
. Config ("FlashUpload") = "true"
End if
. ToolbarSet = "Basic"
. Width = "100%"
. Height = "200"
. Value = ""
. Create "jcontent"
%>
JAVASCRIPT version: var oFCKeditor = new FCKeditor ('fbcontent ');
<% If power = powercode then %>
OFCKeditor. Config ['linkbrowser '] = true;
OFCKeditor. Config ['imagebrowser '] = true;
OFCKeditor. Config ['flashbroath'] = true;
OFCKeditor. Config ['linkupload'] = true;
OFCKeditor. Config ['imageupload'] = true;
OFCKeditor. Config ['flashupload'] = true;
<% End if %>
OFCKeditor. ToolbarSet = 'basic ';
OFCKeditor. Width = '000000 ';
OFCKeditor. Height = '20140901 ';
OFCKeditor. Value = '';
OFCKeditor. Create ();
FCKPageCommand. prototype. Execute = function ()
{
Window. alert ("It works! ");
}
Configure and use FCKeditor in ASP environment
Let's talk about my testing environment: XPSP2, IIS5.1, FCKeditor2.0
Create a new site on IIS. I directly named it FCKeditor.
Create a site in DW. The test Server is a local machine and supports VBScript.
Download FCKeditor2.0, which is open-source and can be found in many places on the Internet ......
The downloaded package should be a compressed package. decompress the package to the root directory of the FCKeditor site and call the package without any changes. When you get there, you will find it easy to die!
Create an index. asp page under the root directory of the site, and add the following code in the <body> section (call the editor ):
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
OFCKeditor. BasePath = "/FCKeditor/" // set the editor path, which is a directory under the root directory of my site
OFCKeditor. ToolbarSet = "Default"
OFCKeditor. Width = "100%"
OFCKeditor. Height = "600"
OFCKeditor. Value = "" // This is the initial Value for the editor.
OFCKeditor. Create "logbody" // the content in the later editor is obtained by this logbody, And the name is determined by you.
%>
After adding this section, do not forget to add the second line before index. asp
<! -- # Include file = "FCKeditor/fckeditor. asp" -->
Include fckeditor. asp. Remember!
That's easy!
Now you only need to use this editor as a control to extract its data: request ("logbody ")
Now let's relax. The test is successful.