@samatawy/diagrams
    Preparing search index...

    Class NodeRegistry

    NodeRegistry is a central registry for managing different types of node handlers. It allows for registering, retrieving, and unregistering node handlers based on their type. This enables the diagram system to support various node types and their associated behaviors in a modular way.

    Handlers should be registered with a unique type string that identifies the kind of node they handle. The registry can then be queried to retrieve the appropriate handler for a given node type when needed. This design promotes extensibility and separation of concerns within the diagram system.

    Example usage: const rectangleHandler = new RectangleHandler(); rectangleHandler.register(); // Registers the handler with the NodeRegistry

    const handler = NodeRegistry.get('rectangle'); // Retrieves the handler for 'rectangle' nodes if (handler) { handler.render(node, context); // Uses the handler to render a node }

    Index

    Constructors

    Methods

    • Retrieves the node handler for a given type.

      Parameters

      • type: string

        The type of the node to retrieve the handler for.

      Returns INodeAdapter | undefined

      The node handler for the specified type, or undefined if no handler is registered for that type.

    • Unregisters a node handler for a specific type.

      Parameters

      • type: string

        The type of the node to unregister the handler for.

      Returns void

    • Retrieves a list of all registered node types in the registry.

      Returns string[]

      An array of strings representing the registered node types.

    • Checks if the node type represents a connection.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type is a connection, false otherwise.

    • Checks if the node type represents a container.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type is a container, false otherwise.

    • Checks if the node type has text.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type has text, false otherwise.

    • Checks if the node type supports single-line text rendering.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type supports single-line text rendering, false otherwise.

    • Checks if the node type requires a multistep creation process.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type requires multistep creation, false otherwise.

    • Checks if the node type supports drag creation.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type supports drag creation, false otherwise.

    • Checks if the node type can be rotated.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type can be rotated, false otherwise.

    • Checks if the node type can snap to a grid or guides.

      Parameters

      • type: string

        The type of the node.

      Returns boolean

      True if the node type can snap to a grid or guides, false otherwise.

    • Checks if the specified node can connect from/to the given handle.

      Parameters

      • node: INode

        The node instance.

      • handle: NodeHandle

        The connection handle.

      • direction: "from" | "to" | "any"

        The direction of the connection ('from' or 'to').

      • Optionaltarget: Partial<INode>

      Returns boolean

      True if the node can connect from/to the handle, false otherwise.

    • Invokes the afterResize method of the node handler for the specified node type. This method is called after a node has been resized to allow the handler to perform any necessary adjustments or updates.

      Parameters

      • node: INode

        The node instance that was resized.

      • handle: NodeHandle

        The handle that was used to resize the node.

      Returns void