import { type Ref } from 'vue'; import { type AnnotationPluginApi } from '@vue-pdf-viewer/shared'; import type { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist/types/src/display/api'; /** * Set the global annotation plugin API reference * Called from usePlugins when the plugin is registered */ export declare const setGlobalAnnotationPluginApi: (api: AnnotationPluginApi | null) => void; /** * Annotation Storage Composable with Automatic Save Support * * This composable provides a centralized way to manage PDF annotations with automatic * saving capabilities. It tracks modifications and can automatically save annotations * to the PDF document before operations like print and download. * * Key Features: * - Tracks annotation modifications automatically * - Provides methods to save annotations before print/download * - Supports batch updates for better performance * - Maintains reactivity across components * - Returns updated PDF data for download operations * * Usage: * ```typescript * const { * annotationStorage, * hasModifications, * saveAnnotationsToDocument, * setAnnotationValue, * batchUpdate * } = useAnnotationStorage() * * // Set individual annotation * setAnnotationValue('annotationId', { color: [255, 0, 0], noView: true }) * * // Batch update multiple annotations * batchUpdate([ * { key: 'id1', value: { color: [255, 0, 0] } }, * { key: 'id2', value: { noView: true } } * ]) * * // Save before print/download (returns updated PDF data) * if (hasModifications()) { * const updatedPdfData = await saveAnnotationsToDocument(pdfDocument) * // Use updatedPdfData for download operations * } * ``` */ export interface UseAnnotationStorageReturn { annotationStorage: Ref; annotationEditorStorageMap: Ref>; setStorage: (documentProxy: PDFDocumentProxy) => any; batchUpdate: (updates: Array<{ key: string; value: any; }>) => void; setAnnotationValue: (key: string, value: any, serialized?: boolean) => void; hasModifications: () => boolean; /** Save all annotations including underline/strikethrough (main entry point) */ saveAnnotationsToDocument: (documentProxy: PDFDocumentProxy) => Promise; /** Save only regular PDF.js annotations (Highlight, FreeText, Stamp, Widget) */ saveAnnotationsToDocumentSimplified: (documentProxy: PDFDocumentProxy) => Promise; cleanAnnotationStorage: () => void; validateAnnotationData: (annotationData: any) => boolean; renderTrigger: Ref; canvasRenderTrigger: Ref; cancelBatchUpdate: () => void; ensureStorageInitialized: () => boolean; getEditorKey: () => string; getAnnotationById: (id: string) => any; findEditorAnnotationKey: (annotationId: string) => string | undefined; } export declare const getGlobalStorageEntries: () => unknown[]; /** * Pre-set noView flag for Underline/StrikeOut annotations before canvas rendering. * This prevents race condition where canvas renders these annotations before * LayerAnnotationEditor has a chance to hide them. * * Why this is needed: * - Highlight annotations are supported by PDF.js for editing, so they respond to isEditing flag * - Underline (type 10) and StrikeOut (type 12) are NOT supported by PDF.js for editing * - PDF.js renders them on canvas but does NOT respond to isEditing flag * - We need to set noView: true BEFORE canvas rendering starts */ export declare function prepareTextMarkupAnnotationsForCanvas(pageProxy: PDFPageProxy, isTextSelectionActive: boolean): Promise; /** * Creates a serializable version of the annotation data * @param value - The annotation data to serialize * @returns A serializable version of the annotation data */ export declare function createSerializableAnnotation(value: any): Promise; export default function useAnnotationStorage(): UseAnnotationStorageReturn;