Sha256: 4711305e2af901f0897ae8c82819cafeaca68723e2f64f6aee6b2e4e51613024

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'rails/engine'

require_relative 'presets/manager'
require_relative 'hooks/form'

module CKEditor5::Rails
  class Engine < ::Rails::Engine
    config.ckeditor5 = ActiveSupport::OrderedOptions.new
    config.ckeditor5.presets = Presets::Manager.new

    initializer 'helper' do
      ActiveSupport.on_load(:action_view) { include Helpers }
    end

    initializer 'ckeditor5.simple_form', if: -> { defined?(::SimpleForm) } do
      require_relative 'hooks/simple_form'
      ::SimpleForm::FormBuilder.map_type :ckeditor5, to: Hooks::SimpleForm::CKEditor5Input
    end

    initializer 'ckeditor5.form_builder' do
      require_relative 'hooks/form'
      ActionView::Helpers::FormBuilder.include(Hooks::Form::FormBuilderExtension)
    end

    class << self
      def base
        config.ckeditor5
      end

      def default_preset
        config.ckeditor5.presets.default
      end

      def configure
        yield config.ckeditor5
      end
    end
  end

  def self.configure(&block)
    Engine.configure(&block)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ckeditor5-1.4.0 lib/ckeditor5/rails/engine.rb
ckeditor5-1.3.0 lib/ckeditor5/rails/engine.rb
ckeditor5-1.2.0 lib/ckeditor5/rails/engine.rb
ckeditor5-1.1.7 lib/ckeditor5/rails/engine.rb