6

我将 CKEditor 与 CKEditor gem ( https://github.com/galetahub/ckeditor ) 一起使用,一切正常,直到我尝试添加自定义工具栏。

我看到的一些帖子建议使用 config.js 文件。但是,按照说明进行设置后/ckeditor/config.jsapp/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"

在 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';
};
4

1 回答 1

1

You have to create your own config.js file manually. To preserve the Upload tab, follow this issue on the ckeditor gem repo, which explains how to solve it:

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

Just paste the referenced config javascript for the filebrowser into your config.js file and the Upload tab will return with full functionality.

于 2013-08-10T20:51:40.613 回答