Sha256: 4865cfb86a68dc97efe3173cff580982d14be9f2b7a49e23cec344ca48dbebd7

Contents?: true

Size: 879 Bytes

Versions: 7

Compression:

Stored size: 879 Bytes

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}..." }
      end

      def toolbar
        [
          [{ 'header': [1, 2, 3, 4, false] }],
          ['bold', 'italic', 'underline'],
          ['link', 'image', 'video', 'code-block'],
          [{ 'list': 'ordered'}, { 'list': 'bullet' }],
          [{ 'align': [] }, 'clean'],
        ]
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_bootstrap-0.0.27 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.0.26 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.0.25 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.0.24 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.0.23 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.0.22 app/models/effective/form_inputs/editor.rb
effective_bootstrap-0.0.21 app/models/effective/form_inputs/editor.rb