Sha256: 72594be43df98a773ce5a164762fe217a78d36378805c1829eeb7312bd7c2afd

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module CKEditor5::Rails
  module Cdn::Concerns
    module InlinePluginsTagsBuilder
      # Includes JavaScript code for inline plugins that use CommonJS module format.
      # This helper generates script tags that initialize plugins before CKEditor loads.
      #
      # @param preset [PresetBuilder, nil] Optional preset to filter plugins from.
      #   If nil, includes plugins from all registered presets.
      # @return [ActiveSupport::SafeBuffer] HTML script tags with plugin initializers
      # @example Including CJS plugins for specific preset
      #   <%= ckeditor5_inline_plugins_tags(@my_preset) %>
      # @example Including CJS plugins from all presets
      #   <%= ckeditor5_inline_plugins_tags %>
      def ckeditor5_inline_plugins_tags(preset = nil)
        plugins = if preset
                    preset.plugins.items
                  else
                    Engine.presets.to_h.values.flat_map { |p| p.plugins.items }
                  end

        initializers = plugins.filter_map do |plugin|
          next unless plugin.is_a?(Editor::PropsInlinePlugin)

          Editor::InlinePluginWindowInitializer.new(plugin).to_html(
            nonce: content_security_policy_nonce
          )
        end

        safe_join(initializers)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/ckeditor5-1.24.9/lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.9 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.8 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.6 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.5 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.4 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.3 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.2 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.1 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb
ckeditor5-1.24.0 lib/ckeditor5/rails/cdn/concerns/inline_plugins_tags_builder.rb