Sha256: 51f282423c69d649451db88cc0fb7ada36f34594c0f9b40c3877ba752a986882

Contents?: true

Size: 1.39 KB

Versions: 4

Compression:

Stored size: 1.39 KB

Contents

module Formstrap
  class RedactorView < ViewModel
    def options
      default_options.deep_merge(to_h)
    end

    private

    def default_options
      {
        data: {
          controller: "redactor",
          "redactor-options": redactor_options
        }
      }
    end

    def redactor_options
      default_redactor_options.deep_merge(redactor || {})
    end

    def default_redactor_options
      {
        lang: I18n.locale,
        # button to control a block/line in the editor
        control: false,
        minHeight: '57px',
        theme: "light",
        # Popup when highlighting text
        context: false,
        popups: {
          # Options in addbar popup (press + button)
          addbar: %w[format bold italic deleted list table link embed],
          # Options in block/line popup
          control: [],
          # Options in format popup
          format: %w[text h1 h2 h3 h4],
        },
        block: {
          # Outline block/line in the editor
          outline: false,
        },
        buttons: {
          # Options when highlighting text
          context: %w[bold underline italic],
          # Options in toolbar on the right
          extrabar: %w[],
          # Options in toolbar on the left
          toolbar: %w[format bold italic deleted list table link html],
        },
        plugins: %w[emoji linkstyles],
      }.delete_if { |k, v| v.nil? }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
formstrap-0.4.5 app/models/formstrap/redactor_view.rb
formstrap-0.4.4 app/models/formstrap/redactor_view.rb
formstrap-0.4.3 app/models/formstrap/redactor_view.rb
formstrap-0.4.2 app/models/formstrap/redactor_view.rb