29 lines
812 B
TypeScript
29 lines
812 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Subject } from 'rxjs';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ContextMenuService {
|
|
private contextMenuVisibility = new Subject<boolean>();
|
|
private contextMenuPosition = new Subject<{ x: number; y: number }>();
|
|
private menuOptions = new Subject<any[]>();
|
|
|
|
contextMenuVisibility$ = this.contextMenuVisibility.asObservable();
|
|
contextMenuPosition$ = this.contextMenuPosition.asObservable();
|
|
menuOptions$ = this.menuOptions.asObservable();
|
|
|
|
showContextMenu(position: { x: number; y: number }) {
|
|
this.contextMenuPosition.next(position);
|
|
this.contextMenuVisibility.next(true);
|
|
}
|
|
|
|
hideContextMenu() {
|
|
this.contextMenuVisibility.next(false);
|
|
}
|
|
|
|
setMenuOptions(options: any[]) {
|
|
this.menuOptions.next(options);
|
|
}
|
|
}
|