我在我的rails 3应用程序中安装了CKeditor gem。现在我想添加一些额外的插件。我查了一下ckeditor文档,它说明插件文件需要去ckeditor解压的地方。我是rails新手,我试图找到我的ckeditor文件,但除了安装ckeditor时创建的模型文件之外,我无法在应用程序目录中找到它们。在rails 3中使用额外的插件修改Ckeditor 3
我应该在哪里为我的自定义ckeditor插件放置文件,以便在初始化时将它们包含在编辑器中?
编辑: 根据下面的答案在所提到的目录中添加插件文件。试图config.js加载使用下面的命令插件CKEditor的:
CKEDITOR.editorConfig = function(config)
{
CKEDITOR.plugins.addExternal('insert_blank','http://localhost:3000/assets/ckeditor/plugins/insert_blank/', 'plugin.js');
var temp = CKEDITOR.registered;
alert(temp) ;
config.extraPlugins = 'insert_blank' ;
config.toolbar =
[
{ name: 'basicstyles', items : [ 'Bold','-','Italic' ] },
{ name: 'insert', items : [ 'Image','insert_blank.btn'
] },
];
config.toolbar.push(['insert_blank.btn']);
config.height = 300 ;
config.width = 300 ;
config.removePlugins = 'elementspath,resize' ;
};
这是我plugin.js文件:
CKEDITOR.plugins.add('insert_blank',
{
init: function(editor)
{
editor.addCommand('InsertBlank',
{
exec function(editor)
{
editor.insertHtml('__');
}
});
editor.ui.addButton('insert_blank.btn',
{
label: 'Insert Blank',
command: 'InsertBlank',
icon: this.path + 'images/blank.png'
});
}
}) ;
我给的绝对路径,只是因为我在开发中,稍后会改变。上面的警报产生'未定义'。我检查了我的服务器日志,这些文件是由应用程序服务器找到的。看起来我不能将插件正确添加到ckeditor。任何关于什么可能出错的想法?
更新:我的plugin.js出现了一些错误。其他一切都很好。
你是如何安装ckeditor的?我不熟悉ruby,但通常你会通过将它解压到网站目录来“安装”ckeditor。 – Alko 2013-04-30 11:46:10
Rails有Gems的概念。我刚刚在gems目录中找到ckeditor文件夹,但它没有插件文件夹。我应该创建一个并将其新插件放入其中吗? – Superq 2013-04-30 11:49:57
我不知道宝石:P但是,我认为你应该创建文件夹,然后你就可以走了。 – Alko 2013-04-30 11:53:48