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:
- Fckconfig. js
- Zh-cn.js
- 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
- Fckconfig. toolbarsets ["Basic"] = [
- ['Bold ', 'italic', '-', 'about', 'test']
- ];
Step 2: Add a Chinese name for the button Zh-cn.js: Name your button
- Dlgaboutinfo:"For more information, visit",
- 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:
- Case'Newpage': B =NewFcktoolbarbutton ('newpage', fcklang. Newpage,Null,Null,True,Null, 4 );Break;
Insert your code after break
- 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:
- VaRFcknewpagecommand =Function(){This. Name = 'newpage ';};
- Fcknewpagecommand. Prototype. Execute =Function() {Fckundo. saveundostep (); fck. sethtml (''); Fckundo. Typing =True;};
- 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)
- VaRFcktestcommand =Function(){This. Name = 'newpage ';};
- Fcktestcommand. Prototype. Execute =Function(){Function() {Fckundo. saveundostep (); fck. sethtml (''); Fckundo. Typing =True;};
- Fcknewpagecommand. Prototype. getstate =Function(){ReturnFck_tristate_off ;};
Search the above Code to find the content. Step 5: Button Function instantiation: Ckeditorcode_gecko.js:
Search:
- Case'Newpage': B =NewFcknewpagecommand ();Break;
Function instantiation:
- Case'Test': B =NewFcktestcommand ();Break;
Search the above Code to find the content. OK, so that you can add a Custom button to FCKeditor. |