CKeditor is FCKeditor. When releasing a new version, you change your name and don't "F".
Requirements: When editing text, I need to select a paragraph of text and click the custom button to add an icon after this paragraph of text, and the icon hyperlink is used to go to an address, and use the selected text as a parameter.
practice:
1. Create a new folder "addmap" in the plugins folder of CKeditor. This name can be customized. This name is the name used in my project.
2. In the addmap folder, put a gif picture "" to use as an icon.
3. In the addmap folder, create a new "" and edit this js file. Our code here is:
Copy the codeThe code is as follows:
(function() {
//Section 1: Code executed when the custom button is pressed
var a = {
exec: function(editor) {
var data="";
var mySelection = ();
if () {
(true);
data = ().createRange().text;
} else {
data = ();
}
if(data!=null&&data!=''){
(data+'<a href="/map_index.html?ad='+data+'"><img border="0" height="24" src="/images/map_icon.gif" width="24" /></a>');
}
}
},
b = 'addmap';
(b, {
init: function(editor) {
(b, a);
('addmap', {
label: 'add map link',
icon: + '',
command: b
});
}
});
})();
4. Return to the root directory of CKeditor and edit
Copy the codeThe code is as follows:
= function( config )
{
// Define changes to default configuration here. For example:
= 'zh-cn';
// = '#AADC6E';
//Font.
config.font_names = 'Song font;Kai font_GB2312;New Song font;Bold font;Lishu;Youy round;Microsoft Yahei;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana;';
//Tool Button
=
[
['Source','-','Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','Link','Unlink','Anchor'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['addmap']
];
= 'addmap';
5. Test