Skip to content

Commit

Permalink
refactor: add default plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
sheikalthaf committed Feb 20, 2024
1 parent bf5100d commit cb2ff60
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
5 changes: 5 additions & 0 deletions projects/flow/src/lib/flow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
ArrowPathFn,
} from './flow-interface';
import { FlowConfig, FlowPlugin } from './plugins/plugin';
import { Connections } from './plugins/connections';

const BASE_SCALE_AMOUNT = 0.05;

Expand Down Expand Up @@ -137,6 +138,7 @@ export class FlowComponent
@ViewChild('guideLines') guideLines: ElementRef<SVGGElement>;
initialX = 0;
initialY = 0;
defaultPlugins = [new Connections()];

constructor(
public el: ElementRef<HTMLElement>,
Expand Down Expand Up @@ -171,6 +173,9 @@ export class FlowComponent
}

private runPlugin(callback: (e: FlowPlugin) => void) {
for (const plug of this.defaultPlugins) {
callback(plug);
}
for (const key in this.config.Plugins) {
if (Object.prototype.hasOwnProperty.call(this.config.Plugins, key)) {
const element = this.config.Plugins[key];
Expand Down
1 change: 0 additions & 1 deletion projects/flow/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ export * from './lib/svg';
export { FitToWindow } from './lib/plugins/fit-to-window';
export { ScrollIntoView } from './lib/plugins/scroll-into-view';
export { Arrangements } from './lib/plugins/arrangements';
export { Connections } from './lib/plugins/connections';
export { FlowConfig, FlowPlugin } from './lib/plugins/plugin';
2 changes: 0 additions & 2 deletions src/app/demo/demo-one.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
FitToWindow,
ScrollIntoView,
Arrangements,
Connections,
} from '@ngu/flow';
import { EditorComponent } from '../editor.component';
import { ToolbarComponent } from './toolbar.component';
Expand Down Expand Up @@ -91,7 +90,6 @@ export class DemoOneComponent implements AfterViewInit {
scroll: new ScrollIntoView('1'),
fitWindow: new FitToWindow(true),
arrange: new Arrangements(),
connections: new Connections(),
};
config: FlowConfig = {
Arrows: true,
Expand Down
2 changes: 0 additions & 2 deletions src/app/demo/demo-two.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
ScrollIntoView,
FitToWindow,
Arrangements,
Connections,
} from '@ngu/flow';
import { EditorComponent } from '../editor.component';
import { ToolbarComponent } from './toolbar.component';
Expand Down Expand Up @@ -101,7 +100,6 @@ export class DemoTwoComponent implements AfterViewInit {
scroll: new ScrollIntoView('1'),
fitWindow: new FitToWindow(false),
arrange: new Arrangements(),
connections: new Connections(),
};
config: FlowConfig = {
Arrows: true,
Expand Down

0 comments on commit cb2ff60

Please sign in to comment.