ejholmes / active_admin_editor

Rich text editor for Active Admin using wysihtml5.
MIT License
184 stars 134 forks source link

Allow Tags configuration via initializer #27

Closed chipairon closed 11 years ago

chipairon commented 11 years ago

Hello,

I want to be able to emmed youtube videos using the iframe youtube provides, but in app/assets/javascripts/active_admin/editor/parser_rules.js, the iframe tag is set to 'remove=1'

If I understand it correctly, I need to make a fork of your project just to change that rule and possibly getting out of sync :( (If there is another way to insert videos, plese tell me)

I think it would be a great addition to be able to modify the tags section of the parser via the initializer used to set S3 options.

Could you enlighten me a bit about this issue, please?

Thanks

chipairon commented 11 years ago

I have decided to take a non-obtrusive approach... but feels hacky:

$(document).ready(function() {
  // customize wysihtml5 editor
  try {
    window.AA.editor_config.parserRules['tags']['iframe'] = {
      remove: 0,
      check_attributes: {
        src: 'url',
        width: 'numbers',
        height: 'numbers'
      }
    }
  }catch(e) {}
}
ejholmes commented 11 years ago

I'd like to eventually move the parser rules into the config as a hash, then just .to_json it in the javascript, that way you could do:

ActiveAdmin::Editor.configure do |config|
  config.parser_rules['tags']['iframe'] = {
    remove: 0,
    check_attributes: {
      src: 'url',
      width: 'numbers',
      height: 'numbers'
    }
  }
end
ejholmes commented 11 years ago

Added in #28 and released a new gem (1.1.0).