[Reprint] FCKeditor add Custom button

Source: Internet
Author: User
Original article: http://hi.baidu.com/samxx8/blog/item/d3eadccaf795dc45f21fe718.html. Html
Recently, the project needs to add new functions to the existing FCKeditor. The previous practice was to encapsulate the function again in the shell. This time it looks like a complete transformation.

Files to be modified:

    1. Fckconfig. js
    2. Zh-cn.js
    3. Fckeditorcode_gecko.js | fckeditorcode_ie.js (the IE is the same for gecko browsers)

Step 1: Add a function button in the toolbar

Fckconfig. JS: fckconfig. toolbarsets ["Basic"] Add button name

    1. Fckconfig. toolbarsets ["Basic"] = [
    2. ['Bold ', 'italic', '-', 'about', 'test']
    3. ];

Step 2: Add a Chinese name for the button

Zh-cn.js: Name your button

    1. Dlgaboutinfo:"For more information, visit",
    2. Test:"Test"

Step 3: display the button in the toolbar

Fckeditorcode_gecko.js :( this JSCodeAfter compression, you can use the tool to format and then modify it)

Search:

    1. Case'Newpage': B =NewFcktoolbarbutton ('newpage', fcklang. Newpage,Null,Null,True,Null, 4 );Break;

Insert your code after break

    1. Case'Test': B =NewFcktoolbarbutton ('test', fcklang. Test,Null,Null,True,Null, 50 );Break;

In this way, your buttons can be displayed in the toolbar.

Step 4: Define a button function prototype

Ckeditorcode_gecko.js:

Search:

    1. VaRFcknewpagecommand =Function(){This. Name = 'newpage ';};
    2. Fcknewpagecommand. Prototype. Execute =Function() {Fckundo. saveundostep (); fck. sethtml (''); Fckundo. Typing =True;};
    3. Fcknewpagecommand. Prototype. getstate =Function(){ReturnFck_tristate_off ;};


Define a functional prototype: (here we can directly Repeat The Newpage implementation code, which can be modified to our own)

    1. VaRFcktestcommand =Function(){This. Name = 'newpage ';};
    2. Fcktestcommand. Prototype. Execute =Function(){Function() {Fckundo. saveundostep (); fck. sethtml (''); Fckundo. Typing =True;};
    3. Fcknewpagecommand. Prototype. getstate =Function(){ReturnFck_tristate_off ;};


Search the above Code to find the content.

Step 5: Button Function instantiation:

Ckeditorcode_gecko.js:

Search:

    1. Case'Newpage': B =NewFcknewpagecommand ();Break;

Function instantiation:

    1. Case'Test': B =NewFcktestcommand ();Break;

Search the above Code to find the content.

OK, so that you can add a Custom button to FCKeditor.

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.