class CKEditor5::Rails::Presets::PluginsBuilder

def self.create_plugin(name, **kwargs)

Returns:
  • (Editor::PropsBasePlugin) - Plugin instance

Parameters:
  • kwargs (Hash) -- Additional plugin configuration
  • name (Symbol, Editor::PropsBasePlugin) -- Plugin name or instance
def self.create_plugin(name, **kwargs)
  if name.is_a?(Editor::PropsBasePlugin)
    name
  else
    Editor::PropsPlugin.new(name, **kwargs)
  end
end

def append(*names, after: nil, **kwargs)

Other tags:
    Example: Append plugins to configuration -

Raises:
  • (ArgumentError) - When the specified 'after' plugin is not found

Parameters:
  • kwargs (Hash) -- Additional plugin configuration
  • after (Symbol, nil) -- Optional plugin name after which to insert new plugins
  • names (Array) -- Names of plugins to append
def append(*names, after: nil, **kwargs)
  new_plugins = names.map { |name| self.class.create_plugin(name, **kwargs) }
  if after
    index = items.index { |p| p.name == after }
    raise ArgumentError, "Plugin '#{after}' not found" unless index
    items.insert(index + 1, *new_plugins)
  else
    items.push(*new_plugins)
  end
end

def initialize(plugins)

def initialize(plugins)
  @items = plugins
end

def prepend(*names, before: nil, **kwargs)

Other tags:
    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

def remove(*names)

Other tags:
    Example: Remove plugins from configuration -

Parameters:
  • names (Array) -- Names of plugins to remove
def remove(*names)
  names.each { |name| items.delete_if { |plugin| plugin.name == name } }
end