import { Injectable } from '@angular/core'; export type FeedbackKind = 'bug' | 'idea' | 'other'; export interface FeedbackRequest { /** Which kind the form starts on (it keeps the last one chosen when left out). */ kind?: FeedbackKind; /** Text the message box starts with, such as the error the page showed. */ prefill?: string; /** * The line under a prefilled message, in place of the usual warning that * it holds the page's error (which may name the file). */ prefillHint?: string; /** The tool's path, such as "video-cutter"; the current page's when left out. */ tool?: string; } /** * Opens the one feedback form (FeedbackHostComponent, in the app shell) from * anywhere: the button under each tool, the Feedback tab and the prompts. */ @Injectable({ providedIn: 'root' }) export class FeedbackService { private opener: ((req: FeedbackRequest) => void) | null = null; /** Called by the host once its form is in the page. */ register(opener: ((req: FeedbackRequest) => void) | null): void { this.opener = opener; } open(req: FeedbackRequest = {}): void { this.opener?.(req); } }