UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

52 lines (51 loc) 2.32 kB
import { TBlock } from "../components/canvas/blocks/Block"; import { Graph } from "../graph"; import { TGraphColors, TGraphConstants } from "../graphConfig"; import { TBlockId } from "../store/block/Block"; import { TConnection, TConnectionId } from "../store/connection/ConnectionState"; import { TGraphSettingsConfig } from "../store/settings"; import { TRect } from "../utils/types/shapes"; import { ESelectionStrategy } from "../utils/types/types"; export type ZoomConfig = { transition?: number; padding?: number; }; export declare class PublicGraphApi { graph: Graph; constructor(graph: Graph); zoomToBlocks(blockIds: TBlockId[], zoomConfig?: ZoomConfig): void; /** * Zooms to fit all blocks in the viewport. This method is asynchronous and waits * for the usableRect to be ready before performing the zoom operation. * * @param zoomConfig - Configuration for zoom transition and padding * @returns Promise that resolves when zoom operation is complete */ zoomToViewPort(zoomConfig?: ZoomConfig): void; zoomToRect(rect: TRect, zoomConfig?: ZoomConfig): void; getGraphColors(): TGraphColors; updateGraphColors(colors: TGraphColors): void; getGraphConstants(): TGraphConstants; updateGraphConstants(constants: TGraphConstants): void; isGraphEmpty(): boolean; setSetting(flagPath: keyof TGraphSettingsConfig, value: boolean | number): void; setCurrentConfigurationName(newName: string): void; deleteSelected(): void; selectBlocks(blockIds: TBlockId[], selected: boolean, strategy?: ESelectionStrategy): void; updateBlock(block: { id: TBlockId; } & Partial<Omit<TBlock, "id">>): void; addBlock(block: Omit<TBlock, "id"> & { id?: TBlockId; }, selectionOptions?: { selected?: boolean; strategy?: ESelectionStrategy; }): TBlockId; setAnchorSelection(blockId: TBlockId, anchorId: string, selected: boolean): void; selectConnections(connectionIds: TConnectionId[], selected: boolean, strategy?: ESelectionStrategy): void; updateConnection(id: TConnectionId, connection: Partial<TConnection>): void; addConnection(connection: TConnection): TConnectionId; getBlockById(blockId: TBlockId): TBlock; getUsableRect(): TRect; unsetSelection(): void; }