Sha256: 2a8f5f508f100581edf8c46dbe6ffbb4daf0f2696fb65108b2920a9731068bd7

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module CKEditor5::Rails
  module Presets
    module Concerns
      module PluginMethods
        private

        def register_plugin(plugin_obj)
          config[:plugins] << plugin_obj
          plugin_obj
        end

        public

        def external_plugin(name, **kwargs)
          register_plugin(Editor::PropsExternalPlugin.new(name, **kwargs))
        end

        def inline_plugin(name, code)
          register_plugin(Editor::PropsInlinePlugin.new(name, code))
        end

        def plugin(name, **kwargs)
          premium(true) if kwargs[:premium] && respond_to?(:premium)
          register_plugin(PluginsBuilder.create_plugin(name, **kwargs))
        end

        def plugins(*names, **kwargs, &block)
          config[:plugins] ||= []

          names.each { |name| plugin(name, **kwargs) } unless names.empty?

          builder = PluginsBuilder.new(config[:plugins])
          builder.instance_eval(&block) if block_given?
          builder
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ckeditor5-1.19.5 lib/ckeditor5/rails/presets/concerns/plugin_methods.rb
ckeditor5-1.19.4 lib/ckeditor5/rails/presets/concerns/plugin_methods.rb
ckeditor5-1.19.3 lib/ckeditor5/rails/presets/concerns/plugin_methods.rb
ckeditor5-1.19.2 lib/ckeditor5/rails/presets/concerns/plugin_methods.rb
ckeditor5-1.19.1 lib/ckeditor5/rails/presets/concerns/plugin_methods.rb
ckeditor5-1.19.0 lib/ckeditor5/rails/presets/concerns/plugin_methods.rb