Trix Scientific
A modified version of Basecamp's Trix editor for use in scientific applications.
Modifications include:
- Superscript tags
- Subscript tags
- Text underlining
- Common notation symbols
- Registration/Copyright/Trademark symbols
- greek Alpha and Beta symbols
- Removal of quote and code blocks
Installation
Add this line to your application's Gemfile:
gem 'trix-scientific'
And then execute:
$ bundle
Or install it yourself as:
$ gem install trix-scientific
Usage
Import Trix styles in app/assets/stylesheets/application.css
:
*= require trix
Require Trix Javascript magic in app/assets/javascripts/application.js
:
//= require trix
Update your sanitizer to allow the style attribute to persist (for underlining). If you are using the default Rails sanitizer you can add the following line to config/application.rb
:
Rails::Html::WhiteListSanitizer.allowed_attributes.merge(["style"])
Finally, any place where you would like to use the Trix editor in your
forms, just use the trix_editor
helper:
f.trix_editor :body
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/DRBragg/trix_scientific. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Trix Scientific project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Credits
This project is a direct modification of Basecamp's Trix WYSIWYG editor. Without their time and effort this wouldn't exist.
The idea to port the custom trix build into a gem for easier use came from Jon Moss's trix gem. I pulled heavily from his repo when setting up this gem.
A huge thanks to my employer Cello Health Communications for not only being super supportive of open source projects and giving me the time and support to work on this project, but also for constantly pushing me to be better and continue to learn and grow.