Reputation: 4685
I'm trying to customize the buttons on the ribbon of the active_admin_editor gem. According to the documentation, I've set up on initializers/active_admin_editor.rb just to test it:
ActiveAdmin::Editor.configure do |config|
config.parser_rules['tags']['h1'] = {
'remove' => 1
}
config.parser_rules['tags']['h2'] = {
'remove' => 1
}
config.parser_rules['tags']['h3'] = {
'remove' => 1
}
end
But no avail. I did
rm -rf tmp/cache
As suggested on the docs and I restarted the server several times, but still the change makes no effect, and the h1, h2, h3 buttons are still showing up. What could be the problem?
Upvotes: 3
Views: 243
Reputation: 526
Hello!
The parser is the bit that reads your input and defines if a styling has already been attached to it, say if you copy and paste some content from another html page.. And if that styling is applicable or not in the block, you are right.
An other idea i had is to first deactivate all of the selectors and then reactivate them one by one. I think this is quite a good thing as users often tend to just copy formatted text into it. Here is my solution:
ActiveAdmin::Editor.configure do |config|
config.parser_rules['tags'] = {
'remove' => 1
}
config.parser_rules['tags']['h3'] = {
'remove' => 0
}
config.parser_rules['tags']['p'] = {
'remove' => 0
}
end
But this doesn't affect the buttons that you could remove probably by chucking in a little css hack:
.toolbar a[title="bold"]{
display: none;
}
Those two resources might be helpful:
https://github.com/xing/wysihtml5/blob/master/parser_rules/advanced.js
and
https://github.com/ejholmes/active_admin_editor/blob/master/app/assets/javascripts/active_admin/editor/templates/toolbar.jst.ejs
This is one of my first answers on Stackoverflow, So i hope it's a nice one. Cheers!
Upvotes: 2