Resortable - v2.0.0-alpha.1
    Preparing search index...

    Class PluginSystem

    Plugin system for managing Sortable plugins

    The PluginSystem manages the lifecycle of plugins, providing registration, installation, and cleanup functionality. It ensures plugins are properly installed and uninstalled from Sortable instances.

    import { PluginSystem, AutoScrollPlugin } from 'resortable';

    // Register a plugin globally
    PluginSystem.register(AutoScrollPlugin);

    // Install on a sortable instance
    const sortable = new Sortable(element);
    PluginSystem.install(sortable, 'AutoScroll');
    Index

    Constructors

    Methods

    • Register a plugin globally

      Parameters

      • plugin: SortablePlugin

        The plugin to register

      • options: { overwrite?: boolean } = {}

        Registration options

        • Optionaloverwrite?: boolean

          If true, overwrite existing plugin instead of throwing error

      Returns void

      Error if plugin name conflicts with existing plugin and overwrite is false

      PluginSystem.register(new MyCustomPlugin());
      // Or to overwrite existing:
      PluginSystem.register(new MyCustomPlugin(), { overwrite: true });
    • Unregister a plugin globally

      Parameters

      • name: string

        Name of the plugin to unregister

      Returns boolean

      true if plugin was found and removed, false otherwise

      PluginSystem.unregister('MyPlugin');
      
    • Get a registered plugin by name

      Parameters

      • name: string

        Name of the plugin to retrieve

      Returns undefined | SortablePlugin

      The plugin instance or undefined if not found

      const plugin = PluginSystem.get('AutoScroll');
      if (plugin) {
      console.log('Plugin version:', plugin.version);
      }
    • Get all registered plugin names

      Returns string[]

      Array of plugin names

      const pluginNames = PluginSystem.list();
      console.log('Available plugins:', pluginNames);
    • Install a plugin on a Sortable instance

      Parameters

      • instance: SortableInstance

        The Sortable instance to install the plugin on

      • name: string

        Name of the plugin to install

      Returns void

      Error if plugin is not registered or already installed

      const sortable = new Sortable(element);
      PluginSystem.install(sortable, 'AutoScroll');
    • Uninstall a plugin from a Sortable instance

      Parameters

      • instance: SortableInstance

        The Sortable instance to uninstall the plugin from

      • name: string

        Name of the plugin to uninstall

      Returns boolean

      true if plugin was found and uninstalled, false otherwise

      PluginSystem.uninstall(sortable, 'AutoScroll');
      
    • Uninstall all plugins from a Sortable instance

      Parameters

      Returns void

      // Clean up all plugins when destroying sortable
      PluginSystem.uninstallAll(sortable);
      sortable.destroy();
    • Check if a plugin is installed on an instance

      Parameters

      • instance: SortableInstance

        The Sortable instance to check

      • name: string

        Name of the plugin to check

      Returns boolean

      true if plugin is installed, false otherwise

      if (PluginSystem.isInstalled(sortable, 'AutoScroll')) {
      console.log('AutoScroll is active');
      }
    • Get all installed plugin names for an instance

      Parameters

      Returns string[]

      Array of installed plugin names

      const installedPlugins = PluginSystem.getInstalled(sortable);
      console.log('Installed plugins:', installedPlugins);
    • Install multiple plugins at once

      Parameters

      • instance: SortableInstance

        The Sortable instance to install plugins on

      • names: string[]

        Array of plugin names to install

      Returns void

      PluginSystem.installMany(sortable, ['AutoScroll', 'Swap']);
      
    • Uninstall multiple plugins at once

      Parameters

      • instance: SortableInstance

        The Sortable instance to uninstall plugins from

      • names: string[]

        Array of plugin names to uninstall

      Returns void

      PluginSystem.uninstallMany(sortable, ['AutoScroll', 'Swap']);