Sha256: 88b8678716569fb134f35f61e67ed64bb4174c9bccac2fd622afa186c58b7581

Contents?: true

Size: 1.1 KB

Versions: 16

Compression:

Stored size: 1.1 KB

Contents

module Headmin
  module Form
    class RedactorxView < ViewModel
      def options
        default_options.deep_merge(to_h)
      end

      private

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

      def control
        @control || (hybrid ? true : nil)
      end

      def context
        @context || (hybrid ? true : nil)
      end

      def toolbar
        @toolbar || (hybrid ? false : nil)
      end

      def addbar
        @addbar || %w[paragraph image embed table quote pre line]
      end

      def plugins
        @plugins || %w[shortcut]
      end

      attr_reader :topbar

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

      def default_redactor_options
        {
          control: control,
          context: context,
          toolbar: toolbar,
          buttons: {
            addbar: addbar,
            plugins: plugins,
            topbar: topbar
          }
        }.delete_if { |k, v| v.nil? }
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
headmin-0.6.3 app/models/headmin/form/redactorx_view.rb
headmin-0.6.2 app/models/headmin/form/redactorx_view.rb
headmin-0.6.1 app/models/headmin/form/redactorx_view.rb
headmin-0.6.0 app/models/headmin/form/redactorx_view.rb
headmin-0.5.9 app/models/headmin/form/redactorx_view.rb
headmin-0.5.8 app/models/headmin/form/redactorx_view.rb
headmin-0.5.7 app/models/headmin/form/redactorx_view.rb
headmin-0.5.6 app/models/headmin/form/redactorx_view.rb
headmin-0.5.5 app/models/headmin/form/redactorx_view.rb
headmin-0.5.4 app/models/headmin/form/redactorx_view.rb
headmin-0.5.3 app/models/headmin/form/redactorx_view.rb
headmin-0.5.2 app/models/headmin/form/redactorx_view.rb
headmin-0.5.1 app/models/headmin/form/redactorx_view.rb
headmin-0.5.0 app/models/headmin/form/redactorx_view.rb
headmin-0.4.2 app/models/headmin/form/redactorx_view.rb
headmin-0.4.1 app/models/headmin/form/redactorx_view.rb