Sha256: 7483927a8df76828183d5931d578a8bc624609212da8044aae552f3cb2e6aeb8

Contents?: true

Size: 1.24 KB

Versions: 121

Compression:

Stored size: 1.24 KB

Contents

module Effective
  module FormInputs
    class CkEditor < Effective::FormInput

      def build_input(&block)
        content = value.presence || (capture(&block) if block_given?)
        @builder.super_text_area(name, (options[:input] || {}).merge(autocomplete: 'off'))
      end

      def input_html_options
        { class: 'effective_ck_editor form-control', id: unique_id }
      end

      def input_js_options
        {
          effective_ckeditor_js_path: asset_path('effective_ckeditor.js'),
          effective_ckeditor_css_path: asset_path('effective_ckeditor.css'),
          contentsCss: contentsCss,
          toolbar: toolbar,
          height: height,
          width: width
        }.compact
      end

      def contentsCss
        @contents_css ||= case (obj = options.delete(:contentsCss))
        when :bootstrap
          'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css'
        when false then nil
        else obj || asset_path('application.css')
        end
      end

      def toolbar
        @toolbar ||= (options.delete(:toolbar) || :full)
      end

      def height
        @height ||= options.delete(:height)
      end

      def width
        @width ||= options.delete(:width)
      end

    end
  end
end

Version data entries

121 entries across 121 versions & 1 rubygems

Version Path
effective_bootstrap-0.9.47 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.46 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.45 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.44 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.43 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.42 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.41 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.40 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.39 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.38 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.37 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.36 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.35 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.34 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.33 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.32 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.31 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.30 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.29 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-0.9.28 app/models/effective/form_inputs/ck_editor.rb