3

我在我的rails项目中使用ckeditor,我有一个图像上传的问题。 我不希望CKEDITOR拥有的一切,我写了它的一些简单的config.js:Rails 4 ckeditor文件上传

CKEDITOR.editorConfig = (config) -> 
    config.language = 'pl' 
    config.toolbar_Pure = [ 
    '/', 
    { 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' ] }, 
    '/', 
    { name: 'styles',  items: [ 'Styles','Format','Font','FontSize' ] }, 
    { name: 'colors',  items: [ 'TextColor','BGColor' ] }, 
    { name: 'insert',  items: [ 'Image','Table','HorizontalRule','PageBreak' ] }, 
    ] 
    config.toolbar = 'Pure' 
    true 

在我看来:

= f.input :answer, label: false, :as => :ckeditor, :input_html => { :ckeditor => {:toolbar => 'Pure'} } 

有了这个配置我没有一个按钮,从我的电脑中选择图片: enter image description here

但是,当我删除我的config.js,并考虑设置:

= f.input :answer, label: false, :as => :ckeditor, :input_html => { :ckeditor => {:toolbar => 'Full'} } 

然后我有按钮来从我的电脑上传文件,一切工作正常。现在我的目标是编辑我的config.js以使这个文件上传工作。请帮忙。

回答

7

我改变配置来:

CKEDITOR.editorConfig = function(config) { 
    config.language = 'pl'; 
    config.filebrowserBrowseUrl = "/ckeditor/attachment_files"; 
    config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files"; 
    config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files"; 
    config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures"; 
    config.filebrowserImageBrowseUrl = "/ckeditor/pictures"; 
    config.filebrowserImageUploadUrl = "/ckeditor/pictures"; 
    config.filebrowserUploadUrl = "/ckeditor/attachment_files"; 
    config.toolbar_Pure = [ 
    '/', { 
     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'] 
    }, '/', { 
     name: 'styles', 
     items: ['Styles', 'Format', 'Font', 'FontSize'] 
    }, { 
     name: 'colors', 
     items: ['TextColor', 'BGColor'] 
    }, { 
     name: 'insert', 
     items: ['Image', 'Table', 'HorizontalRule', 'PageBreak'] 
    } 
    ]; 
    config.toolbar = 'Pure'; 
    return true; 
}; 

,并如预期

工作