2013-06-21 14 views
5

CKEditor gem(https://github.com/galetahub/ckeditor)でCKEditorを使用していて、カスタムツールバーを追加しようとするまで、すべてが正しく機能しています。レールでCKEditorにカスタムツールバーを追加

私が見た記事の中には、config.jsファイルを使用することをお勧めします。ただし、指示に従って設定すると、app/assets/javascriptsには/ckeditor/config.jsというファイルはありません。さらに、/ckeditor/config.jsをjavascriptsディレクトリに追加すると、ファイルのアップロード機能が動作しなくなります。これは、config.jsが空のファイルであっても発生します。 [アップロード]タブは非表示になり、サーバーの再起動時に機能しなくなります。

私は普遍的なツールバーをカスタマイズする方法はありますか?私が持っているかさえ、私はちょうど私のGemfileでのRails 3.2.11

を使用して...オプションをインラインまたは参考になる何かダウン

をペアにすることができた場合:で

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) 

を。私が持っている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

あなたのを作成する必要があります独自のconfig.jsファイルを手動で作成します。 [アップロード]タブを維持するために、それを解決する方法を説明しCKEditorバージョンの宝石のレポでこの問題、次のとおりです。

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

ちょうど、参照設定をペーストをごconfig.jsのファイルにfilebrowserとアップロード]タブ用のJavaScript完全な機能を備えた状態に戻ります。

関連する問題