FCKeditor, the best editor on the Internet

Source: Internet
Author: User

FCKeditor version 2.0 has finally come out. The reason for using the word "final" is that the flash insertion function is widely seen in this version. Among all online editors, FCKeditor is currently the best editor on the Internet. It has powerful functions and supports multiple browsers without platform restrictions. It can be integrated with multiple web languages and supports multiple languages, open source, etc ~~

FCKeditor can directly use a brand new website without any modifications. However, for the vast majority of existing websites, some FCKeditor settings are not suitable for your use. This article aims to tell you how to modify FCKeditor to make it easier for your website to use.

The first task is to streamline the powerful editor. Of course, it is to streamline the file, not the function. Here, I use the FCKeditor of ASP as an example to go to The FCKeditor 2.0 folder and delete all the folders starting, these folders contain examples or other tools. In fact, only the Editor folder and fckconfig are retained. JS, FCKeditor. ASP, FCKeditor. JS, fckstyles. XML, fcktemplates. XML is enough. The outermost layer is simplified. after entering the Editor folder, delete the "_ source" folder first. Here are some source files, which are useless for use.

Go to the images folder and delete the smiley folder. Some files are placed with emoticon icons. Because I will use my own emoticon icons to delete them first, of course, if you want to use the emojis here, do not delete them. Exit images and enter the Lang folder. Here, you can clean things in a large way, only keep fck1_agemanager. JS, zh-cn.js, en. JS, Zh. JS. The first file is the language configuration file, which can be used with fckconfig. JS settings correspond to the corresponding language files, zh-cn.js is a simplified Chinese Language Pack, en. JS is not required, Zh. JS is in Traditional Chinese. How is it? A few hundred KB is missing at once ~

Then exit the Lang folder and enter the skin folder. If you want to use the default FCKeditor milk yellow, delete the other two folders except the default folder. If you want to use another folder, I will give you a suggestion. If you don't want to use the default one, select silver, because Silver is gray and it won't be ugly, but the office2003 skin, I really do not like it anyway, and the image is relatively large, and the download time is increased, no!

In the last step of streamlining, exit the skin folder and go to filemanager. If you are not using the latest FCKeditor version, a folder browser is used. The new version also has an upload folder. One by one, first go to filemanager/Browser/default/connectors/. Because I use ASP, all except ASP folders are deleted. Next, go to filemanager/upload/, and leave only the ASP folder. Now, the simplified editor is complete. Next, let's modify the settings of the editor.

--------------------------------------------------------------------------------

The first modified file is the FCKeditor configuration file, which is located in the fckconfig. js file under the root directory. Please follow the list below (take FCKeditor 2.0 as the standard ):

Find row 20th fckconfig. defaultlanguage = 'en'; change to fckconfig. defaultlanguage = 'zh-cn'; set the default language to simplified Chinese
Find row 40th fckconfig. tabspaces = 0; change to fckconfig. tabspaces = 1; that is, you can use the tab key in the editor.

If your editor is still used at the front-end of the website, for example, for message book or diary reply, you have to consider security. Do not use the default toolbar on the front-end or customize the function, either use the basic defined by the system, that is, the basic toolbar,
Find row 64th fckconfig. toolbarsets ["Basic"] = [
['Bold ', 'italic', '-', 'orderedlist', 'unorderedlist', '-',/* 'link', */'unlink ', '-', 'style', 'fontsize', 'textcolor', 'bgcolor', '-', 'smiley ', 'specialchar', 'replace ', 'preview']
];
This is the basic I changed. I removed the image function and removed the Add link function, because the image and link and flash and image button adding functions allow the front-end page to directly access and upload files, if I don't change it here, I will upload a Trojan to you. Isn't it ready? However, FCKeditor also supports the right-click function in the editing area.
Find row 73rd
Fckconfig. contextmenu = ['generic',/* 'link', */'anchor ',/* 'image', */'flash', 'select', 'textarea ', 'checkbox', 'Radio ', 'textfield', 'hiddenfield',/* 'imagebutton', */'call', 'bulletedlist', 'numberedlist', 'tablecell ', 'table', 'form'];

This is also the "link, image, Flash, image button" function that I changed to remove the right mouse button.

Find row 77th fckconfig. fontnames = 'arial; Comic Sans MS; Courier New; tahoma; Times New Roman; verdana ';
Add several common fonts fckconfig. fontnames = '; _ gb2312; Arial; Comic Sans MS; Courier New; tahoma; Times New Roman; verdana ';

After upload and upload. asp? Type = XX is changed to type = YY, where YY is the name of the folder where you want to save the file.

If you still want to use your own emoticon icon, jump to row 3 and change the folder address of the emoticon icon and the file name of the emoticon icon below, the three numbers below are the number of emotices displayed on each line and the width and height of the pop-up window. The size depends on the size of the window arranged by the emoticon icon. OK. The change to the total configuration file is complete.

--------------------------------------------------------------------------------

Next, set the editor location. My habit is to put the editor under the root directory, and the five files mentioned at the beginning are also under the root directory (TIPS: it is recommended to put it under the root directory, we recommend that you set the path to an absolute path, for example, "/FCKeditor/", and my usual setting is "/". This is conducive to the update and upgrade of FCKeditor, in addition, all folders on the website can be called at will. There is no problem where the name of other folders has changed and the editor cannot be used elsewhere.

Open the FCKeditor. asp file and find sbasepath = "/FCKeditor/" to change it to sbasepath = "/"
Open the FCKeditor. js file and find this. basepath = '/FCKeditor/'; change this. basepath = '/';

The default display font in the editor is 12px, while the default font on my home page is 14px, which makes it quite uncomfortable. You can modify the style sheet to meet the requirements, open/Editor/CSS/fck_editorarea.css and change row 4th to font-size: 14px.

The next step is to set the file to be uploaded. This is troublesome. Please perform this operation carefully.

Open/Editor/filemanager/Browser/default/frmresourcetype.html, find row 15th, and insert "['uploadfile', 'uploadfile']," in combination with fckconfig. in JS, the path of the uploaded file is/uploadfile. Of course, you can change it to the folder you want, but the name here must be the same as fckconfig. in JS, The YY in "type = YY" is consistent.

Before you finish, go to editor/filemanager/Browser/default/connectors/asp and open config. ASP: Change configisenabled = false to configisenabled = true. If you cannot upload files, change configuserfilespath = "/userfile" to configuserfilespath = "/".
Add "set configdeniedextensions = Createobject (" scripting. Dictionary ")"
Configallowedextensions. Add "uploadfile ",""
Configdeniedextensions. Add "uploadfile ",""

Similarly, the settings here also correspond to the above and fckconfig. js.

Another upload function is quick upload. This function is available only in FCKeditor 2.0 and is not available in previous versions. Go to/Editor/filemanager/upload/asp and open config. ASP, also set configisenabled = false to configisenabled = true, change configuserfilespath = "/userfiles/" to configuserfilespath = "/uploadfile/" & year (date () & "-" & month (date ()) & "/", because my uploaded files are placed in the uploadfile folder and separated by month. Quick upload does not allow you to select folders. Instead, you can directly upload files using the settings here. If the settings are not compatible with the previous settings, your files will be uploaded in a mess, it is inconvenient to manage. Repeat the operations in the previous config. asp file before adding

Configallowedextensions. Add "uploadfile ",""
Configdeniedextensions. Add "uploadfile ",""

--------------------------------------------------------------------------------

Next, let's talk about how to create your own online editor. Here we take ASP and JS as examples. The sample code of ASP is generally used for background operations:

<%
Dim ofckeditor
Set ofckeditor = new FCKeditor
Ofckeditor. basepath = "/"

Ofckeditor. toolbarset = "default"
Ofckeditor. width = "100%"
Ofckeditor. Height = "400"

Ofckeditor. value = RS ("logbody ")
Ofckeditor. Create "logbody"
%>

ASP version, of course, can only be used in. ASP is the extension of the page, if you are in front of fckedito. if basepath is set to "/" in ASP, the third row can be saved here. asp only has one create function. We recommend that you use ASP when modifying an article.

Next, let's look at the JS version:

<SCRIPT type = "text/JavaScript">
VaR ofckeditor = new FCKeditor ('logbody ');
Ofckeditor. basepath = '/';
Ofckeditor. toolbarset = 'basic ';
Ofckeditor. width = '000000 ';
Ofckeditor. Height = '20140901 ';
Ofckeditor. value = '';
Ofckeditor. Create ();
</SCRIPT>

Basepath settings are described above. The JS version can be used on any webpage or even HTML page. Because it is generated by the client, the advantage is that it can reduce network traffic, because the editor file only needs to be downloaded once. Second, the client can define when to display the file. Because FCKeditor initialization takes some time, JS is very useful at this point.

In addition, another function in JS is the replacetextarea () function, which can replace the specified textarea and take the reply part of the log of my website as an example:

<SCRIPT type = "text/JavaScript">
<! --
Function showfck (){
VaR ofckeditor = new FCKeditor ('fbcontent ');
Ofckeditor. basepath = '/';
Ofckeditor. toolbarset = 'basic ';
Ofckeditor. width = '000000 ';
Ofckeditor. Height = '20140901 ';
Ofckeditor. value = '';
// Ofckeditor. Create ();
Ofckeditor. replacetextarea ();
// Document. blog_feedback.blogsubmit.disabled = '';
Document. blog_feedback.blogsubmit.style.display = '';
Document. blog_feedback.openfck.disabled = 'true ';
Document. blog_feedback.openfck.style.display = 'none ';
}
// -->
</SCRIPT>

Write it into a simple function. This FCKeditor is generated only when the user opens the editor. You do not need to initialize an editor every time you refresh the page, so the page speed will be much faster.

--------------------------------------------------------------------------------

Supplement: As mentioned earlier, JavaScript version is not recommended when editing existing data content, which is caused by single quotation marks, it is inevitable that there will be single quotation marks in the data content. When an editor is generated using JS, the single quotation marks may cause the editor to fail to be generated normally. asp is different, the ASP version is used because the data is treated as a variable and then assigned a value to the editor domain. In addition, unless you use the replacetextarea () method to generate an editor, you do not need to write a tag such as <textarea>, and everything will be automatically generated by FCKeditor, all you need to do is to specify an Instance name for FCKeditor. At the same time, you don't have to worry about how to submit the file. FCKeditor automatically submits the file when submitting the form. The submitted variable name is named after the FCKeditor instance you specified.

Reference: http://3rgb.com/ B? Act = viewthread & category = & threadid = 316 & page = 1

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.