import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ViewChild } from '@angular/core'; import { FCanvasComponent, FCreateConnectionEvent, FFlowModule, FZoomDirective } from '@foblex/flow'; import { ExampleToolbar } from '@foblex/portal-ui'; @Component({ selector: 'auto-snap', styleUrls: [ './example.scss' ], templateUrl: './example.html', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ FFlowModule, FZoomDirective, ExampleToolbar ] }) export class Example { @ViewChild(FCanvasComponent, { static: true }) public fCanvas!: FCanvasComponent; public connections: { outputId: string, inputId: string }[] = []; constructor( private changeDetectorRef: ChangeDetectorRef ) { } public addConnection(event: FCreateConnectionEvent): void { if(!event.fInputId) { return; } this.connections.push({ outputId: event.fOutputId, inputId: event.fInputId }); this.changeDetectorRef.detectChanges(); } public onLoaded(): void { this.fCanvas.resetScaleAndCenter(false); } public onDeleteConnections(): void { this.connections = []; this.changeDetectorRef.detectChanges(); } }