Eri*_*oss 6 javascript ruby-on-rails ckeditor
我正在使用CKEditor和CKEditor gem(https://github.com/galetahub/ckeditor)并且一切正常,直到我尝试添加自定义工具栏.
我见过的一些帖子建议使用config.js文件.但是,根据说明进行设置,没有/ckeditor/config.js文件app/assets/javascripts.此外,如果我添加/ckeditor/config.js到javascripts目录,文件上载功能将停止工作.即使config.js是空文件也会发生这种情况.通过重新启动服务器,"上载"选项卡将变为隐藏且无法正常运行.
有没有办法可以普遍定制工具栏?或者即使我可以将选项内联或有用的东西配对......
使用Rails 3.2.11
在我的Gemfile中我有:
gem "jquery-rails", "~> 2.2.1"
gem "ckeditor"
gem "carrierwave"
gem "mini_magick"
gem "cloudinary"
Run Code Online (Sandbox Code Playgroud)
在application.rb我有:
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
Run Code Online (Sandbox Code Playgroud)
在application.js我有:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require ckeditor/init
//= require_tree ../../../vendor/assets/javascripts/.
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
在我的表格中,我有:
= f.cktext_area :content
Run Code Online (Sandbox Code Playgroud)
我尝试使用的config.js文件:
CKEDITOR.editorConfig = function( config ) {
config.toolbar_Custom = [
{ name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','-','Templates' ] },
{ name: 'clipboard', items : [ 'PasteFromWord','-','Undo','Redo' ] },
{ name: 'insert', items : [ 'Image','Table','HorizontalRule','SpecialChar','PageBreak' ] },
{ name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] },
'/',
{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
'/',
{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
{ name: 'colors', items : [ 'TextColor','BGColor' ] }
];
config.toolbar = 'Custom';
};
Run Code Online (Sandbox Code Playgroud)
小智 1
您必须手动创建自己的 config.js 文件。要保留“上传”选项卡,请在 ckeditor gem 存储库上关注此问题,其中解释了如何解决该问题:
https://github.com/galetahub/ckeditor/issues/238
只需将文件浏览器引用的配置 javascript 粘贴到 config.js 文件中,上传选项卡就会返回并具有完整功能。