Sha256: cd792ff11e68c5e81fb72246fe37b2788b668c392ee1130fd4eacb0668145117

Contents?: true

Size: 1.36 KB

Versions: 13

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'rails_admin/config/fields/types/text'

module RailsAdmin
  module Config
    module Fields
      module Types
        class CodeMirror < Text
          # Register field type for the type loader
          RailsAdmin::Config::Fields::Types.register(self)

          # Pass the theme and mode for Codemirror
          register_instance_option :config do
            {
              mode: 'css',
              theme: 'night',
            }
          end

          register_instance_option :version do
            '5.46.0'
          end

          # Pass the location of the theme and mode for Codemirror
          register_instance_option :assets do
            {
              mode: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/#{version}/mode/css/css.min.js",
              theme: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/#{version}/theme/night.min.css",
            }
          end

          register_instance_option :js_location do
            "https://cdnjs.cloudflare.com/ajax/libs/codemirror/#{version}/codemirror.min.js"
          end

          register_instance_option :css_location do
            "https://cdnjs.cloudflare.com/ajax/libs/codemirror/#{version}/codemirror.min.css"
          end

          register_instance_option :partial do
            :form_code_mirror
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails_admin-3.3.0 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.2.1 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.2.0 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.2.0.rc lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.2.0.beta lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.4 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.3 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.2 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.1 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.0 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.0.rc2 lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.0.rc lib/rails_admin/config/fields/types/code_mirror.rb
rails_admin-3.1.0.beta lib/rails_admin/config/fields/types/code_mirror.rb