Sha256: 1a0b327d134ee63535f2b92d0f43d60a4f5e3608427e4704b00ed8516399a098

Contents?: true

Size: 793 Bytes

Versions: 51

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module CKEditor5::Rails::Hooks
  module SimpleForm
    class CKEditor5Input < ::SimpleForm::Inputs::Base
      def input(wrapper_options = nil)
        merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
        @builder.template.ckeditor5_editor(**editor_options(merged_input_options))
      end

      private

      def editor_options(merged_input_options)
        {
          preset: input_options.fetch(:preset, :default),
          type: input_options.fetch(:type, :classic),
          config: input_options[:config],
          initial_data: object.try(attribute_name) || input_options[:initial_data],
          name: "#{object_name}[#{attribute_name}]",
          **merged_input_options
        }
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
ckeditor5-1.19.5 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.19.4 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.19.3 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.19.2 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.19.1 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.19.0 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.18.3 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.18.1 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.18.0 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.17.4 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.17.3 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.17.2 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.17.1 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.17.0 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.16.2 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.16.1 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.16.0 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.15.10 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.15.9 lib/ckeditor5/rails/hooks/simple_form.rb
ckeditor5-1.15.8 lib/ckeditor5/rails/hooks/simple_form.rb