在Rails中向CKEditor添加自定义工具栏

6
我使用带有CKEditor gem (https://github.com/galetahub/ckeditor)的CKEditor,并且一切正常,直到我尝试添加自定义工具栏。
一些帖子建议使用config.js文件。然而,按照说明设置后,app/assets/javascripts中没有/ckeditor/config.js文件。此外,即使在javascript目录中添加/ckeditor/config.js,文件上传功能也会停止工作。即使config.js是一个空文件,服务器重新启动后,“上传”选项卡也将变为隐藏和无法使用。
是否有一种方法可以通用地自定义工具栏?或者即使我只能内联地缩小选项,这也将很有帮助...
使用Rails 3.2.11
在我的Gemfile中:
gem "jquery-rails", "~> 2.2.1"
gem "ckeditor"
gem "carrierwave"
gem "mini_magick"
gem "cloudinary"

在 application.rb 中,我有以下内容:
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)

在 application.js 文件中,我有以下内容:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require ckeditor/init
//= require_tree ../../../vendor/assets/javascripts/.
//= require_tree .

在我的表单中,我有:

= f.cktext_area :content

我尝试使用的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';
};
1个回答

1
你需要手动创建自己的config.js文件。为了保留上传标签,请在ckeditor gem存储库中关注此问题,其中解释了如何解决它:

https://github.com/galetahub/ckeditor/issues/238

只需将文件浏览器的引用配置javascript粘贴到您的config.js文件中,上传选项卡将具有完全的功能。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接