gpt4 book ai didi

javascript - Rails 4 ckeditor 文件上传

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:34:03 25 4
gpt4 key购买 nike

我在我的 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'} } 

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

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

= f.input :answer, label: false, :as => :ckeditor, :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', '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;
};

并按预期工作

关于javascript - Rails 4 ckeditor 文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21928348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com