CKEditor 插件开发:工具栏按钮快速入门
2013-01-04 16:47
411 查看
转自:http://mjxy.cn/a-CKEditor-plug-in-development-a-toolbar-button-Quick-Start.aspx
介绍
这是一个CKEditor3.4插件开发的简易教程,介绍如何为工具栏toolbar增加例如 p,h1,h2,h3,h4,h5,h6,pre,div的按钮。
目录结构
按如下目录结构创建文件夹和文件
ckeditor/
config.js
plugins/
button-pre/
button-pre.png
plugin.js
plugin.js 插件配置脚本
(function(){
var a= {
exec:function(editor){
var format = {
element : "pre"
};
var style = new CKEDITOR.style(format);
style.apply(editor.document);
}
},
b="button-pre";
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton("button-pre",{
label:"Button PRE",
icon: this.path + "button-pre.png",
command:b
});
}
});
})();
下载Button图片 button-pre.png:
注册插件
修改config.js文件
CKEDITOR.editorConfig = function( config )
{
CKEDITOR.config.toolbar_Basic = [['button-pre', 'Bold', 'Italic', 'Underline' ]];
config.toolbar = 'Basic';
config.startupOutlineBlocks = true;
config.extraPlugins = "button-pre";
};
结果如下图:
介绍
这是一个CKEditor3.4插件开发的简易教程,介绍如何为工具栏toolbar增加例如 p,h1,h2,h3,h4,h5,h6,pre,div的按钮。
目录结构
按如下目录结构创建文件夹和文件
ckeditor/
config.js
plugins/
button-pre/
button-pre.png
plugin.js
plugin.js 插件配置脚本
(function(){
var a= {
exec:function(editor){
var format = {
element : "pre"
};
var style = new CKEDITOR.style(format);
style.apply(editor.document);
}
},
b="button-pre";
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton("button-pre",{
label:"Button PRE",
icon: this.path + "button-pre.png",
command:b
});
}
});
})();
下载Button图片 button-pre.png:
注册插件
修改config.js文件
CKEDITOR.editorConfig = function( config )
{
CKEDITOR.config.toolbar_Basic = [['button-pre', 'Bold', 'Italic', 'Underline' ]];
config.toolbar = 'Basic';
config.startupOutlineBlocks = true;
config.extraPlugins = "button-pre";
};
结果如下图:
相关文章推荐
- CKEditor 插件开发:工具栏按钮快速入门
- Eclipse插件开发快速入门(一)
- Eclipse插件开发快速入门
- 插件开发或RCP中如何通过actions扩展点配置工具栏按钮(插入到指定的ToolBarManger中)
- Eclipse插件开发快速入门(二)
- Eclipse插件开发快速入门
- JQuery--JQuery面向对象编程快速入门-插件开发
- Eclipse插件开发快速入门
- jquery插件开发快速入门
- Datatables快速入门开发--一款好用的JQuery表格插件
- Eclipse插件开发快速入门
- Netbeans 6.0 CLDC/MIDP开发快速入门指南(一)
- HealthKit开发快速入门教程之HealthKit数据的操作
- wordpress 插件的开发 入门
- NPAPI插件开发详细记录:插件开发入门
- 2013年7月01日_.net开发快速入门
- SpriteKit快速入门和新时代iOS游戏开发指南
- 程序员带你学习安卓开发,十天快速入门-基础知识(四)
- iOS蓝牙开发CoreBluetooth快速入门
- .NET Core快速入门教程 4、使用VS Code开发.NET Core控制台应用程序