Reputation: 91
i'm using rails 6.0.0 and ruby 2.6.0, I want to know what's the best way to use ActionText in ActiveAdmin, should I have to use render?
Upvotes: 9
Views: 3497
Reputation: 51
Add this to your Gemfile
gem 'activeadmin_quill_editor'
in your app/assets/stylesheets/active_admin.scss
@import 'activeadmin/quill_editor/quill.snow';
@import 'activeadmin/quill_editor_input';
in your app/assets/javascripts/active_admin.js
//= require activeadmin/quill_editor/quill
//= require activeadmin/quill_editor_input
app/admin/posts.rb
ActiveAdmin.register Post do
permit_params :title, :text, :tag_list
form do |f|
f.inputs 'Article' do
f.input :tag_list, :input_html => {:value => f.object.tag_list.join(", ") }, :label => "Tags (separated by commas)".html_safe
f.input :title
f.input :text, as: :quill_editor, input_html: { data:
{ options:
{ modules:
{ toolbar:
[%w[bold italic underline strike],
%w[blockquote code-block],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'align': [] }],
['link'],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
['clean'],
['image'],
['video']] },
theme: 'snow' } } }
# f.input :published
end
f.actions
end
end
Upvotes: -1
Reputation: 153
I used this f.rich_text_area :content
inside ActiveAdmin but it didn't work for me so I added <trix-editor>
tag inside a custom form following this Form Partial Tricks
but also this didn't work so I ended up using this gem ActiveAdmin Quill Editor it was easy to setup and worked perfectly
Add this to your Gemfile gem 'activeadmin_quill_editor'
in your app/assets/stylesheets/active_admin.scss
file, add this:
@import 'activeadmin/quill_editor_input';
app/assets/javascripts/active_admin.js
file, add this://= require activeadmin/quill_editor/quill
//= require activeadmin/quill_editor_input
# ActiveAdmin article form conf:
form do |f|
f.inputs 'Article' do
f.input :title
f.input :description, as: :quill_editor
f.input :published
end
f.actions
end
Upvotes: 3