Class CKEditorPluginDependencies

java.lang.Object
com.wontlost.ckeditor.CKEditorPluginDependencies

public final class CKEditorPluginDependencies extends Object
Plugin dependencies management for CKEditor 5.

This class manages the dependency relationships between CKEditor 5 plugins, ensuring that when a plugin is added, all its required dependencies are also included. Dependencies are gathered from the official CKEditor 5 documentation.

Usage example:

Set<CKEditorPlugin> plugins = new HashSet<>();
plugins.add(CKEditorPlugin.IMAGE_CAPTION);
plugins.add(CKEditorPlugin.TABLE_TOOLBAR);

// Automatically resolve all dependencies
Set<CKEditorPlugin> resolvedPlugins = CKEditorPluginDependencies.resolve(plugins);
// resolvedPlugins now includes IMAGE, TABLE, ESSENTIALS, PARAGRAPH, etc.
See Also:
  • Method Details

    • getDependencies

      public static Set<CKEditorPlugin> getDependencies(CKEditorPlugin plugin)
      Get the direct dependencies for a plugin.
      Parameters:
      plugin - the plugin to get dependencies for
      Returns:
      set of direct dependencies (never null, may be empty)
    • getRecommended

      public static Set<CKEditorPlugin> getRecommended(CKEditorPlugin plugin)
      Get the recommended plugins for a plugin. These are not required but enhance the functionality.
      Parameters:
      plugin - the plugin to get recommendations for
      Returns:
      set of recommended plugins (never null, may be empty)
    • hasDependencies

      public static boolean hasDependencies(CKEditorPlugin plugin)
      Check if a plugin has dependencies.
      Parameters:
      plugin - the plugin to check
      Returns:
      true if the plugin has dependencies
    • resolve

      public static Set<CKEditorPlugin> resolve(Set<CKEditorPlugin> plugins)
      Resolve all dependencies for a set of plugins. This method transitively resolves all dependencies, ensuring that if plugin A depends on B, and B depends on C, all three are included.

      Core plugins (ESSENTIALS and PARAGRAPH) are always included.

      Parameters:
      plugins - the initial set of plugins
      Returns:
      a new set containing all plugins with their dependencies resolved
    • resolve

      public static Set<CKEditorPlugin> resolve(Set<CKEditorPlugin> plugins, boolean includeCorePlugins)
      Resolve all dependencies for a set of plugins.
      Parameters:
      plugins - the initial set of plugins
      includeCorePlugins - whether to automatically include ESSENTIALS and PARAGRAPH
      Returns:
      a new set containing all plugins with their dependencies resolved
    • resolveWithRecommended

      public static Set<CKEditorPlugin> resolveWithRecommended(Set<CKEditorPlugin> plugins)
      Resolve all dependencies including recommended plugins.
      Parameters:
      plugins - the initial set of plugins
      Returns:
      a new set containing all plugins with dependencies and recommendations
    • getDependents

      public static Set<CKEditorPlugin> getDependents(CKEditorPlugin plugin)
      Get all plugins that depend on the specified plugin.
      Parameters:
      plugin - the plugin to find dependents for
      Returns:
      set of plugins that depend on the given plugin
    • checkRemovalImpact

      public static Set<CKEditorPlugin> checkRemovalImpact(CKEditorPlugin plugin, Set<CKEditorPlugin> currentPlugins)
      Check if removing a plugin would break any dependencies.
      Parameters:
      plugin - the plugin to check
      currentPlugins - the current set of plugins
      Returns:
      set of plugins that would be broken if the plugin is removed
    • validateDependencies

      public static Map<CKEditorPlugin, Set<CKEditorPlugin>> validateDependencies(Set<CKEditorPlugin> plugins)
      Validate that all dependencies are satisfied for a set of plugins.
      Parameters:
      plugins - the plugins to validate
      Returns:
      map of plugins to their missing dependencies (empty if all satisfied)
    • topologicalSort

      public static List<CKEditorPlugin> topologicalSort(Set<CKEditorPlugin> plugins)
      Get a topologically sorted list of plugins. Dependencies are listed before the plugins that depend on them.
      Parameters:
      plugins - the plugins to sort
      Returns:
      list of plugins in dependency order
    • getDependencyTree

      public static String getDependencyTree(CKEditorPlugin plugin)
      Get a human-readable dependency tree for a plugin.
      Parameters:
      plugin - the plugin to get the tree for
      Returns:
      formatted string showing the dependency tree
    • getLoadOrder

      public static List<CKEditorPlugin> getLoadOrder(Set<CKEditorPlugin> plugins)
      Get all plugins in dependency order suitable for loading. This is a convenience method that resolves and sorts plugins.
      Parameters:
      plugins - the plugins to process
      Returns:
      list of all required plugins in load order