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 /)