trix-extensions
trix-extensions copied to clipboard
Basic Documentation on how to use this in a Rails app
It would be really helpful to see a few lines of documentation to describe how to use this tool in a Rails app with rich text trix editor. Without any documentation, it's really not useful even though the plugin looks great.
It is basically download repository and extract it to your rails project and add require("richtext")
to /javascript/packs/application.js
Hello @lazaronixon,
Thank you for your work on this extension ! Where exactly should we extract the repository in our project ? Anywhere in the repo ? Or somewhere like /javascript/packs/
? I can't figure it out but I need your extension so badly !
Thanks
You should extract it on root directory
You should extract it on root directory
Okay, just did it... But I'm getting this error Module not found: Error: Can't resolve 'richtext' in '/Users/robeen/dev/tourcrib/app/javascript/packs'
any idea what's wrong ?
Here is my file structure :
tourcrib
...
trix-extensions
app
assets
etc...
...
Thanks for your help
Okay, I kinda managed to make it work... My only issue now is that when I save, the trix editor strips the <h2-6>
tags as well as the style=""
attributes. Even tho I added :
Rails.application.config.after_initialize do
ActionText::ContentHelper.allowed_attributes.add 'style'
ActionText::ContentHelper.allowed_tags.add 'h2'
...
end
Do you have any idea what's up ? It's so frustrating, I've been trying to figure it out for like 4 hours now... Action text is so unflexible by nature right now... It's sad
Agreed. This needs "how-to" text to be generally useful. I'll see if I can figure it out.
@r-obeen
if you just use it does not work? In my case, it worked very well.
Rails.application.config.after_initialize do
ActionText :: ContentHelper.allowed_attributes << 'style'
end
Hey, I can confirm that this after_initialize
does not work in Rails 6.1.3.1
If I just do ActionText::ContentHelper.allowed_attributes << 'style'
in a config/initializers/action_text.rb
(or wherever) it works.
But if I use the after_initialize do ... end
it does not work! :)