class CKEditor5::Rails::Presets::PluginsBuilder
def prepend(*names, before: nil, **kwargs)
- Example: Prepend plugins to configuration -
Raises:
-
(ArgumentError)
- When the specified 'before' plugin is not found
Parameters:
-
kwargs
(Hash
) -- Additional plugin configuration -
before
(Symbol, nil
) -- Optional plugin name before which to insert new plugins -
names
(Array
) -- Names of plugins to prepend
def prepend(*names, before: nil, **kwargs) new_plugins = names.map { |name| self.class.create_plugin(name, **kwargs) } if before index = items.index { |p| p.name == before } raise ArgumentError, "Plugin '#{before}' not found" unless index items.insert(index, *new_plugins) else items.insert(0, *new_plugins) end end