CKEditor和Rails管理员使用自定义工具栏

时间:2018-08-04 20:10:19

标签: ruby-on-rails ckeditor rails-admin

我有以下ckeditor config.js工具栏代码:

  config.toolbar_image = [
    { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
    { name: 'styles', items: [ 'Font', 'FontSize' ] },
    { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
    { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
    { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule' ] }
  ];

我正在尝试让rails_admin使用此图像工具栏,就像在我的模型文件中一样:

class BlogPost < ApplicationRecord
  mount_uploader :header_image, HeaderImageUploader
  validates :header_image, file_size: { less_than_or_equal_to: 2.megabytes },
                   file_content_type: { allow: /^image\/.*/ }

  rails_admin do
    edit do
      field :description, :ck_editor, ckeditor: { height: '15em', toolbar: 'image' }
      field :article_copy, :ck_editor, ckeditor: { height: '15em', toolbar: 'image' }
      include_all_fields
    end
  end
end

ckeditor加载到我的管理编辑视图中,而不加载我想要的自定义工具栏。我该怎么做呢?

config.js文件适用于我的应用程序中其他位置使用的ckeditor,但不适用于rails admin。

0 个答案:

没有答案