@inweb/viewer-visualize
    Preparing search index...

    Interface ICommandsRegistry

    Defines the viewer commands registry interface.

    interface ICommandsRegistry {
        executeCommand(id: string, viewer: IViewer, ...args: any[]): any;
        getCommand(id: string): ICommand;
        getCommands(): ICommandsMap;
        registerCommand(
            id: string,
            handler: ICommandHandler,
            description?: ICommandDescription,
            thisArg?: any,
        ): void;
        registerCommandAlias(id: string, alias: string): void;
    }
    Index

    Methods

    • Executes the command denoted by the given command. If the command is not found, tries to set active dragger with the specified name.

      Parameters

      • id: string

        Command ID or dragger name.

      • viewer: IViewer

        Viewer instance that wants to execute the command.

      • ...args: any[]

        Parameters passed to the command handler function.

      Returns any

      Returns the result of the command handler function or new active dragger instance. Returns undefined if neither the command nor the dragger exists.

    • Returns the specified command or undefined when the command doesn't exists.

      Parameters

      • id: string

        Command ID.

      Returns ICommand

    • Binds a command ID to a handler function. Registering a command with an existing ID twice overrides the existing handler.

      Parameters

      • id: string

        Unique ID for the command.

      • handler: ICommandHandler

        Command handler function.

      • Optionaldescription: ICommandDescription

        Command description.

      • OptionalthisArg: any

        The this context used when invoking the handler function.

      Returns void

    • Registers an alias for a command.

      Parameters

      • id: string

        Unique ID for the command.

      • alias: string

        Command alias string.

      Returns void