Sha256: e743158275f89ef406c7aeffaf004026efde7b73d964f1a0e04acf441570207d

Contents?: true

Size: 607 Bytes

Versions: 16

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module CKEditor5::Rails::Editor
  class PropsInlinePlugin
    attr_reader :name, :code

    def initialize(name, code)
      @name = name
      @code = code
      validate_code!
    end

    def to_h
      {
        type: :inline,
        name: name,
        code: code
      }
    end

    private

    def validate_code!
      raise ArgumentError, 'Code must be a String' unless code.is_a?(String)

      return if code.include?('export default')

      raise ArgumentError,
            'Code must include `export default` that exports plugin definition!'
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ckeditor5-1.17.4 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.17.3 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.17.2 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.17.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.17.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.16.2 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.16.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.10 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.9 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.8 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.7 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.2 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.15.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.14.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.14.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb