微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – Rails 4 ckeditor文件上传

我在我的rails项目中使用了ckeditor,我的图像上传有问题.
我不想要ckeditor所拥有的一切,我为它写了一些简单的config.js:

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'} }

使用此配置我没有从我的计算机中选择图像的按钮:

但是当我删除我的config.js并在视图集中时:

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

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

解决方法

我将配置更改为:

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','RemoveFormat']
    },{
      name: 'paragraph',items: ['NumberedList','BidiRtl']
    },{
      name: 'links',items: ['Link','Unlink']
    },{
      name: 'styles',items: ['Styles','FontSize']
    },{
      name: 'colors',items: ['TextColor','BGColor']
    },{
      name: 'insert',items: ['Image','PageBreak']
    }
  ];
  config.toolbar = 'Pure';
  return true;
};

并按预期工作

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐