Sha256: d2bbdd94e3a70926a95ba163ce3aec24402b7b2b2df7ff867e00b5749294004d
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
# frozen_string_literal: true module CKEditor5::Rails class ToolbarBuilder def initialize(toolbar_config) @toolbar_config = toolbar_config end def items @toolbar_config[: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 toolbar" 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 toolbar" unless index items.insert(index + 1, *appended_items) else items.push(*appended_items) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ckeditor5-1.1.6 | lib/ckeditor5/rails/toolbar_builder.rb |