export interface SnTextObject { prop: { qInfo: { qType: 'sn-text'; }; seedData: { type: string; data: string; }; }; } export interface SnImageObject { prop: { qInfo: { qType: 'sn-image'; }; image: { mode: 'media'; mediaUrl: { qStaticContentUrlDef: { qUrl: string; }; }; fit: 'original'; }; }; } export type ClipboardPasteResult = SnTextObject | SnImageObject | Record | null; export interface PasteImageContent { data: ArrayBuffer; type: string; } export interface ExtractedImageData { data: ArrayBuffer | null; /** * Mime type of the extracted image, or `'unsupported'` when the clipboard * contained a file that is not a supported image. */ type: string; } export interface ClipboardContentsParameters { pasteData?: PasteImageContent; clipboardItems?: ClipboardItem[]; } export interface CopyPasteToast { type: 'warning' | 'error' | 'success' | 'info'; message: string | string[]; header?: string; } /** * Minimal structural subset of the QMFE embed core apis required by copy-paste. * A full `QmfeEmbedCoreApis`/`CoreApis` object structurally satisfies this * interface, so consumers can pass their apis object directly without coupling * this package to `@qlik-trial/qmfe-*`. */ export interface CopyPasteApis { translate: (key: string, ...args: (string | number | (string | number)[])[]) => string; getBooleanFlag: (flag: string, defaultValue: boolean) => boolean; showToast: (toast: CopyPasteToast) => void; platform: { isCloud: boolean; }; } /** * Uploads an image blob and resolves to the uploaded file path (or `null` on * failure). When omitted, image paste is disabled but text/HTML/Qlik-object * paste keeps working. */ export type UploadImageBlob = (blob: Blob, imageType: string) => Promise; export interface CopyPasteConfig { apis: CopyPasteApis; uploadImageBlob?: UploadImageBlob; } export interface CopyPaste { copyToClipboard(title: string, object: T, callbackFn: (val: T) => Promise): Promise; getClipboardContents(params?: ClipboardContentsParameters): Promise; extractImageData(event: ClipboardEvent): Promise; uploadPastedImage(event: ClipboardEvent): Promise; hasValidClipboardContent(): Promise; showToastOnInvalidClipboardData(): void; }