Sha256: e0224a530e03ff457f1806bf64c65344bd991450cea9b84a118f492ebfcc0532

Contents?: true

Size: 664 Bytes

Versions: 4

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true

module CKEditor5::Rails::Editor
  class PropsPlugin
    delegate :to_h, to: :import_meta

    def initialize(name, premium: false)
      @name = name
      @premium = premium
    end

    def self.normalize(plugin)
      case plugin
      when String, Symbol then new(plugin)
      when PropsPlugin then plugin
      else raise ArgumentError, "Invalid plugin: #{plugin}"
      end
    end

    private

    attr_reader :name, :premium

    def import_meta
      ::CKEditor5::Rails::Assets::JSImportMeta.new(
        import_as: name,
        import_name: premium ? 'ckeditor5-premium-features' : 'ckeditor5'
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ckeditor5-1.0.3 lib/ckeditor5/rails/editor/props_plugin.rb
ckeditor5-1.0.2 lib/ckeditor5/rails/editor/props_plugin.rb
ckeditor5-1.0.1 lib/ckeditor5/rails/editor/props_plugin.rb
ckeditor5-1.0.0 lib/ckeditor5/rails/editor/props_plugin.rb