Sha256: d243af38491c0d56583f09e93ba8adf6b93c7b14a65a61914b902e45b33dd720

Contents?: true

Size: 1.54 KB

Versions: 18

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require "rails"
require "action_controller/railtie"
require "active_record/railtie"
require "active_storage/engine"

require "action_text"

module ActionText
  class Engine < Rails::Engine
    isolate_namespace ActionText
    config.eager_load_namespaces << ActionText

    initializer "action_text.attribute" do
      ActiveSupport.on_load(:active_record) do
        include ActionText::Attribute
      end
    end

    initializer "action_text.attachable" do
      ActiveSupport.on_load(:active_storage_blob) do
        include ActionText::Attachable

        def previewable_attachable?
          representable?
        end

        def attachable_plain_text_representation(caption = nil)
          "[#{caption || filename}]"
        end

        def to_trix_content_attachment_partial_path
          nil
        end
      end
    end

    initializer "action_text.helper" do
      ActiveSupport.on_load(:action_controller_base) do
        helper ActionText::Engine.helpers
      end
    end

    initializer "action_text.renderer" do |app|
      app.executor.to_run      { ActionText::Content.renderer = ApplicationController.renderer }
      app.executor.to_complete { ActionText::Content.renderer = ApplicationController.renderer }

      ActiveSupport.on_load(:action_text_content) do
        self.renderer = ApplicationController.renderer
      end

      ActiveSupport.on_load(:action_controller_base) do
        before_action { ActionText::Content.renderer = ApplicationController.renderer.new(request.env) }
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
actiontext-6.0.4.8 lib/action_text/engine.rb
actiontext-6.0.4.7 lib/action_text/engine.rb
actiontext-6.0.4.6 lib/action_text/engine.rb
actiontext-6.0.4.5 lib/action_text/engine.rb
actiontext-6.0.4.4 lib/action_text/engine.rb
actiontext-6.0.4.3 lib/action_text/engine.rb
actiontext-6.0.4.2 lib/action_text/engine.rb
actiontext-6.0.4.1 lib/action_text/engine.rb
actiontext-6.0.4 lib/action_text/engine.rb
actiontext-6.0.3.7 lib/action_text/engine.rb
actiontext-6.0.3.6 lib/action_text/engine.rb
actiontext-6.0.3.5 lib/action_text/engine.rb
actiontext-6.0.3.4 lib/action_text/engine.rb
actiontext-6.0.3.3 lib/action_text/engine.rb
actiontext-6.0.3.2 lib/action_text/engine.rb
actiontext-6.0.3.1 lib/action_text/engine.rb
actiontext-6.0.3 lib/action_text/engine.rb
actiontext-6.0.3.rc1 lib/action_text/engine.rb