Sha256: 73ea04e500d855610b277c103bdef191f4d21436037e48b451551443943e3685

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

module Effective
  module FormInputs
    class Editor < Effective::FormInput

      def build_input(&block)
        content = value.presence || (capture(&block) if block_given?)

        @builder.super_text_field(name, options[:input]) +
        content_tag(:div, '', class: 'ql-effective', id: unique_id + '_editor')
      end

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

      def input_js_options
        { modules: { toolbar: toolbar }, theme: 'snow', placeholder: "Add #{name.to_s.pluralize}...", delta: delta? }
      end

      # Commented out 'Full' toolbar options because currently we don't want headers / source / code options
      def toolbar
        [
          # [{'header': [1, 2, 3, 4, false] }],
          ['bold', 'italic', 'underline'],
          ['link', 'image', 'video'], # also 'code-block'
          [{'list': 'ordered'}, { 'list': 'bullet' }],
          [{'align': [] }, 'clean'],
        ]
      end

      def delta? # default false
        return @delta unless @delta.nil?

        if options.key?(:html)
          @delta = (options.delete(:html) == false)
        else
          @delta = (options.delete(:delta) || false)
        end
      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
effective_bootstrap-0.2.1 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.2.0 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.12 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.11 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.10 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.9 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.8 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.7 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.6 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.5 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.4 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.3 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.2 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.1 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.1.0 app/models/effective/form_inputs/editor.rb