Sha256: 0d2af7bb4846af4c5c573982a0fa1f643d809428f79121701ec04a0836f9ec82

Contents?: true

Size: 656 Bytes

Versions: 19

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

require_relative 'props_base_plugin'

module CKEditor5::Rails::Editor
  class PropsInlinePlugin < PropsBasePlugin
    attr_reader :code

    def initialize(name, code)
      super(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

19 entries across 19 versions & 1 rubygems

Version Path
ckeditor5-1.23.5 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.23.4 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.23.2 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.23.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.23.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.22.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.21.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.20.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.20.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.19.5 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.19.4 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.19.3 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.19.2 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.19.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.19.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.18.3 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.18.1 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.18.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb
ckeditor5-1.16.0 lib/ckeditor5/rails/editor/props_inline_plugin.rb