/** * AnnotationController * * Manages annotations including user annotations, external annotations, * annotation interactions (hover, select), and search functionality. */ import type { ViewerStateStores } from "../viewerState"; import type { ViewerDerivedStores } from "../viewerDerived"; import type { ResolvedAnnotation } from "../../../iiif/annotationResolver"; import type { ViewBox } from "../../../core/types/viewer"; import type { ViewerEventEmitter } from "../../../core/types/events"; import type { CanonicalStylesheet } from "@mango-iiif/w3c-parser"; /** Extra context an edit needs that the patch itself cannot carry. */ export type AnnotationPatchOptions = { /** Replaces the annotation's stylesheet, for a layer recolour. */ stylesheet?: CanonicalStylesheet | null; language?: string; bodyPurpose?: string; textDirection?: string; /** Canonical body to patch when an annotation has parallel translations. */ bodyPath?: string; /** Add a parallel TextualBody instead of replacing the display projection. */ createBody?: boolean; }; export type AnnotationControllerConfig = { state: ViewerStateStores; derived: ViewerDerivedStores; emitEvent: ViewerEventEmitter; emitStateChange: () => void; getCanvasId: () => string | null; getCanvasIndex: () => number; setCanvasById: (canvasId: string) => void; setPendingViewBox: (viewBox: ViewBox | null) => void; applyViewBox: (viewBox: ViewBox) => void; }; export type AnnotationController = { addAnnotation: (annotation: unknown) => Promise; updateAnnotation: (annotationId: string, patch: Partial, options?: AnnotationPatchOptions) => Promise; removeAnnotation: (annotationId: string) => Promise; /** Replaces an annotation wholesale. For undo and redo. */ replaceAnnotation: (annotationId: string, annotation: ResolvedAnnotation) => Promise; /** Commits the edits already applied to an annotation as one save. */ commitAnnotation: (annotationId: string) => Promise; setAnnotationMode: (mode: "edit" | "create") => void; setSearchQuery: (value: string) => void; handleSearchResultClick: (annotation: ResolvedAnnotation) => void; }; export declare const createAnnotationController: ({ state, derived: derivedStores, emitEvent, emitStateChange, getCanvasId, getCanvasIndex, setCanvasById, setPendingViewBox, applyViewBox, }: AnnotationControllerConfig) => AnnotationController;