How to add new buttons and modify functions in the FCKEditor

Source: Internet
Author: User

Files to be modified:

Fckconfig. js
Zh-cn.js
En. js
Fckeditorcode_gecko.js | fckeditorcode_ie.js (for browsers other than IE | for IE browsers, if you want to support both browsers, modify both packages)

Step 1: Add a function button in the Toolbar
Fckconfig. js: FCKConfig. ToolbarSets ["Default"] Add button name
FCKConfig. ToolbarSets ["Default"] = [
['Bold ', 'italic', '-', 'about', 'mydiy ']
];

Step 2: Add a Chinese name and an English name for the button

Zh-cn.js: Give your button a Chinese name
Mydiy: "My custom buttons"

En. js: Give your button an English name
Mydiy: "mydiybutton"

Step 3: display the button in the Toolbar

Fckeditorcode_gecko.js (fckeditorcode_ie.js ):
Search:

Case 'newpage': B = new FCKToolbarButton ('newpage', FCKLang. NewPage, null, null, true, null, 4); break;
Insert your code after break

For example, case 'mydiy ': B = new FCKToolbarButton ('mydiy', FCKLang. mydiy, null, null, false, true, 50); (this 50 is the display image of the button. to display your Custom button as the picture of the button for inserting the image, enter 37)
In this way, your buttons can be displayed in the Toolbar.

Step 4: Define the button function prototype

Ckeditorcode_gecko.js (fckeditorcode_ie.js ):

Search:

Var FCKNewPageCommand = function () {this. Name = 'newpage ';};
FCKNewPageCommand. prototype. Execute = function () {FCKUndo. SaveUndoStep (); FCK. SetHTML (''); FCKUndo. Typing = true ;};
FCKNewPageCommand. prototype. GetState = function () {return FCK_TRISTATE_OFF ;};
Define the function prototype: (here, the NewPage implementation code is directly put behind and then modified)

For example: var FCKmydiyCommand = function () {this. name = 'mydiy ';}; FCKmydiyCommand. prototype. execute = function () {write the code or function you want to Execute, such as alert ("I am here! ") ;}; FCKmydiyCommand. prototype. GetState = function () {return 0 ;};
Insert the above Code into the search content.

Step 5: Button Function instantiation:

Ckeditorcode_gecko.js (fckeditorcode_ie.js ):

Search:

Case 'newpage': B = new FCKNewPageCommand (); break;
Function instantiation:
Case 'mydiy ': B = new FCKmydiyCommand (); break;
Insert the above Code into the search content.

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

To add a shortcut key to the button, add fckconfig. js to FCKConfig. Keystrokes = [].
[CTRL + 71/* G */, 'mydiy '],

From: Ping ke xiaoju (http://www.piikee.net /)

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.