Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Documentation on how to use this in a Rails app #8

Open
Kinselan opened this issue Dec 24, 2020 · 8 comments
Open

Basic Documentation on how to use this in a Rails app #8

Kinselan opened this issue Dec 24, 2020 · 8 comments

Comments

@Kinselan
Copy link

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.

@lazaronixon
Copy link
Owner

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

@r-obeen
Copy link

r-obeen commented Feb 23, 2021

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

@lazaronixon
Copy link
Owner

You should extract it on root directory

@r-obeen
Copy link

r-obeen commented Feb 23, 2021

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
Copy link

r-obeen commented Feb 23, 2021

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

@Merovex
Copy link

Merovex commented Mar 6, 2021

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

@iagopuccini
Copy link

@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

@matt-riemer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants