Morrigan Editor for Ruby on Rails
Installation
- Add it to your
Gemfile
:
gem 'morrigan_editor_rails'
- Add to
routes.rb
:
mount MorriganEditorRails::Engine => "/morrigan_editor_rails"
- Create table for editor's uploaded images:
rake morrigan_editor_rails:install:migrations
rake db:migrate
- Add to
application.js
:
//= require 'morrigan_editor_rails/application'
- Add to 'application.css':
*= require 'morrigan_editor_rails/application.css'
Usage
Add to your HTML:
<div morrigan-editor="true" id="editor" editor-width="100%" editor-height="300px" editor-bound-textarea="#textarea"></div>
where editor-bound-textarea
attribute is contains of selector of bound textarea (generated in editor html code will be passed in this textarea before form submit).
Custom stylesheet
To add custom stylesheet to editor:
- Add initializer
morrigan_editor.rb
with next code:
module MorriganEditorRails
class Engine < Rails::Engine
config.iframe_css_file_name = 'your_file_name.css'
end
end
- Add initializer
assets.rb
with next code (or add next code to this file if it is exists):
Rails.application.config.assets.precompile += %w( your_file_name.css )
Custom uploader
You can use your uploader by put it in initializers with MorriganEditorImageUploader
class name:
class MorriganEditorImageUploader < CarrierWave::Uploader::Base
# your code here
end
Sanitization
MorriganEditorRails::Editor.sanitize(html)
License
© 2014 Sergey Sokolov. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.