module ActiveScaffold::Bridges::TinyMce::Helpers::FormColumnHelpers

Public Instance Methods

active_scaffold_input_text_editor(column, options, ui_options: column.options) click to toggle source

The two column options that can be set specifically for the text_editor input is :tinymce, which overrides single values in the tinymce config. E.g. column.options = {theme: ‘other’} will change the theme but not the plugins, toolbars etc. The other one is :tinymce_config, which selects the config to use from tinymce.yml. See the tinymce-rails gem documentation for usage.

# File lib/active_scaffold/bridges/tiny_mce/helpers.rb, line 17
def active_scaffold_input_text_editor(column, options, ui_options: column.options)
  options[:class] = "#{options[:class]} mceEditor #{ui_options[:class]}".strip

  settings = tinymce_configuration(ui_options[:tinymce_config] || :default).options
                                                                           .reject { |k, _v| k == 'selector' }
                                                                           .merge(ui_options[:tinymce] || {})
  options['data-tinymce'] = settings.to_json if ActiveScaffold.js_framework != :prototype

  html = []
  html << send(override_input(:textarea), column, options, ui_options: ui_options)
  if ActiveScaffold.js_framework == :prototype && (request.xhr? || params[:iframe])
    html << javascript_tag("tinyMCE.settings = #{settings.to_json}; tinyMCE.execCommand('mceAddEditor', false, '#{options[:id]}');")
  end
  safe_join html
end
active_scaffold_input_tinymce(column, options, ui_options: column.options)

The implementation is very tinymce specific, so it makes sense allowing :form_ui to be :tinymce as well