trix-extensions icon indicating copy to clipboard operation
trix-extensions copied to clipboard

Basic Documentation on how to use this in a Rails app

Open Kinselan opened this issue 4 years ago • 8 comments

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.

Kinselan avatar Dec 24 '20 04:12 Kinselan

It is basically download repository and extract it to your rails project and add require("richtext") to /javascript/packs/application.js

lazaronixon avatar Dec 24 '20 17:12 lazaronixon

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

r-obeen avatar Feb 23 '21 01:02 r-obeen

You should extract it on root directory

lazaronixon avatar Feb 23 '21 02:02 lazaronixon

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

r-obeen avatar Feb 23 '21 02:02 r-obeen

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

r-obeen avatar Feb 23 '21 07:02 r-obeen

Agreed. This needs "how-to" text to be generally useful. I'll see if I can figure it out.

Merovex avatar Mar 06 '21 14:03 Merovex

@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

iagopuccini avatar Apr 01 '21 18:04 iagopuccini

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! :)

matt-riemer avatar Apr 09 '21 05:04 matt-riemer