Sha256: 40ad117f8fec3a7e0dd6cb009bd6cc1a178129cf9e7d959f21b23dc33da04de3

Contents?: true

Size: 1.27 KB

Versions: 116

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

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

116 entries across 116 versions & 1 rubygems

Version Path
effective_bootstrap-1.19.13 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.12 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.11 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.10 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.9 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.8 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.7 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.6 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.5 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.4 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.3 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.2 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.1 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.19.0 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.18.7 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.18.4 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.18.3 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.18.2 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.18.1 app/models/effective/form_inputs/ck_editor.rb
effective_bootstrap-1.18.0 app/models/effective/form_inputs/ck_editor.rb