Sha256: c65151ceede24f3997b5e6db91b3af4d6172cb21b19113db99be695ba00c8a46

Contents?: true

Size: 858 Bytes

Versions: 26

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

module CKEditor5::Rails::Presets
  class ToolbarBuilder
    attr_reader :items

    def initialize(items)
      @items = items
    end

    def remove(*removed_items)
      removed_items.each { |item| items.delete(item) }
    end

    def prepend(*prepended_items, before: nil)
      if before
        index = items.index(before)
        raise ArgumentError, "Item '#{before}' not found in array" unless index

        items.insert(index, *prepended_items)
      else
        items.insert(0, *prepended_items)
      end
    end

    def append(*appended_items, after: nil)
      if after
        index = items.index(after)
        raise ArgumentError, "Item '#{after}' not found in array" unless index

        items.insert(index + 1, *appended_items)
      else
        items.push(*appended_items)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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