您现在的位置是:网站首页> 编程资料编程资料
ckeditor插件开发简单实例_网页编辑器_
2023-05-25
271人已围观
简介 ckeditor插件开发简单实例_网页编辑器_
CKeditor就是FCKeditor,在发布一个新版本的时候,把自己的名字都改了,不要"F"。
需求:我需要在编辑文本的时候,选择一段文字,点击自定义的按钮,就能够在这段文字后面增加一个图标,图标超链接去一个地址,以选中的文字作为参数。
做法:
1、在CKeditor的plugins文件夹下,创建新文件夹"addmap",这个名字可以自定义,这个名字是我项目中用的名字
2、在addmap文件夹下,放一张gif图片"map.gif",用来作图标用的。
3、在addmap文件夹下,新建"plugin.js",编辑这个js文件,我们这里的代码是:
复制代码 代码如下:
(function() {
//Section 1 : 按下自定义按钮时执行的代码
var a = {
exec: function(editor) {
var data="";
var mySelection = editor.getSelection();
if (CKEDITOR.env.ie) {
mySelection.unlock(true);
data = mySelection.getNative().createRange().text;
} else {
data = mySelection.getNative();
}
if(data!=null&&data!=''){
editor.insertHtml(data+'
}
}
},
b = 'addmap';
CKEDITOR.plugins.add(b, {
init: function(editor) {
editor.addCommand(b, a);
editor.ui.addButton('addmap', {
label: 'add map link',
icon: this.path + 'map.gif',
command: b
});
}
});
})();
4、回到CKeditor的根目录,编辑config.js
复制代码 代码如下:
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
config.language = 'zh-cn';
//config.uiColor = '#AADC6E';
//字体.
config.font_names = '宋体;楷体_GB2312;新宋体;黑体;隶书;幼圆;微软雅黑;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana;';
//工具按钮
config.toolbar=
[
['Source','-','Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','Link','Unlink','Anchor'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['addmap']
];
config.extraPlugins = 'addmap';
5、测试
您可能感兴趣的文章:
相关内容
- UEditor 编辑器跨域上传解决方法_网页编辑器_
- 关于jsp版ueditor1.2.5的部分问题解决(上传图片失败)_网页编辑器_
- kindSoft在线网页编辑器简单的配置参数介绍_网页编辑器_
- ajax php实现给fckeditor文本编辑器增加图片删除功能_网页编辑器_
- SyntaxHighlighter配合CKEditor插件轻松打造代码语法着色_网页编辑器_
- Fckeditor XML Request error:internal server error (500) 解决方法小结_网页编辑器_
- FCKeditor smarty 编辑器的应用PHP_网页编辑器_
- ThinkPHP中FCKeditor编辑器的使用方法_网页编辑器_
- 为ckeditor编辑器加上传图片的功能_网页编辑器_
- 百度编辑器 如何获取光标位置与不同帧内的节点_网页编辑器_
