我不想在我的Rails-App中使用CKEditor。
在我的gemfile中我添加了这一行
gem 'ckeditor', :git => 'https://github.com/galetahub/ckeditor.git'
运行"捆绑更新"和" rails生成ckeditor:install --orm = active_record --backend = paperclip"我添加到我的application.js这一行:
//= require ckeditor/init
在我看来,我添加了这一行:
<%= f.cktext_area :img, :ckeditor => {:toolbar => 'img', :customConfig => asset_path('ckeditor/config.js')} %>
我创建了这个文件夹和文件:
/app/assets/javascripts/ckeditor
/app/assets/javascripts/ckeditor/config.js
/app/assets/javascripts/ckeditor/contents.css
我的config.js看起来像这样:
CKEDITOR.editorConfig = function( config )
{
config.toolbar_img = [
{ name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] },
]
}
为什么我的编辑器看起来像这样?
答案 0 :(得分:5)
使用以下命令更改config.js文件:
CKEDITOR.config.toolbar= [
{ name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] }
];
确保在application.js文件中需要config.js:
//= require ckeditor/init
//= require_tree ./ckeditor
另外,CSS文件应该在这里: /app/assets/stylesheets/ckeditor/contents.css 不在这里 /app/assets/javascripts/ckeditor/contents.css
完成上述更改后,您可以执行以下操作:<%= f.cktext_area :img %>
。
但是,如果你想直接在text_area中传递配置值,那么应该这样做:
<%= f.cktext_area :img, :ckeditor => {:toolbar => 'mini'} %>
或:
<%= f.cktext_area :img, :ckeditor => {:toolbar => {'name' => 'document', 'items' => ['Source']} } %>
答案 1 :(得分:1)
在视图中:
<%= k.cktext_area :template_text, required: true, :class =>"emailBodyTemplate", :id => "emailBodyText", placeholder: "Email Body Text", :maxlength => 255 %>
在app / assets / javascripts / ckeditor / config.js中:
CKEDITOR.editorConfig = function (config) {
config.toolbar_mini = [
["Bold", "Italic", "Underline", "Strike", "-"],
['BulletedList','NumberedList' ],['Outdent','Indent'],
];
config.toolbar = "mini";
config.toolbarLocation = 'bottom';
config.height = 280;
config.width = 620;
config.removePlugins = 'elementspath';config.removePlugins = 'elementspath';
}
输出: