/** * Copyright (c) Microsoft. All rights reserved. */ import { LabelerA11yStore } from '../stores/LabelerA11yStore'; import { LineStore } from '../stores/LineStore'; import { AnnotationData, AnnotationDomData, ITokenStore } from '../types/labelerTypes'; export declare const getAnnotationElementByKey: (ref: HTMLElement, annotationKey: string) => Element; export declare const getAnnotationElementsByTokenIndex: (ref: HTMLElement, tokenIndex: number) => Element[]; export declare const sortAnnotations: (order: 'ascending' | 'descending') => (a: AnnotationData, b: AnnotationData) => number; export declare const isAnnotationWithinIndices: (a: AnnotationDomData, startLine: number, endLine: number) => boolean; /** * Gets an array of the unique annotations per line which * is gathered by aggregating the annotations per token * for each token in the line. * * @param lineStore The line store to get the annotations for. * @param annotationsPerTokenMap The annotations per token map. * @returns An array of annotations per line. */ export declare const getUniqueAnnotationsPerLine: (lineStore: LineStore, annotationsPerTokenMap: Map) => AnnotationData[]; /** * Reveres the given annotation by swapping its start and * end tokens, and setting the reversed flag to true. This * is useful for annotations that have a start index that * is larger than the end index, since our labeler is built * under the assumption of having always having the start * index smaller than the end index. * * @param a The annotation to reverse. * @returns The annotation with reversed start and end tokens * and the reverse flag set. */ export declare const reverseAnnotation: (a: AnnotationData) => AnnotationData; /** * Converts the given annotation data to data augmented * with DOM specific data that is essential for renderers * to render the final SVG shape for the annotation. * * Read more about the flow of data in `labeler.md`. * * @param param0.data The annotation to get the DOM data for. * @param param0.lineStores The current line stores in the document. * @param param0.onRenderAnnotationColor A factory function that * generates a color for the annotation. */ export declare const annotationDataToAnnotationDomData: ({ annotation, lineStores, onRenderAnnotationColor }: { annotation: AnnotationData; lineStores: LineStore[]; onRenderAnnotationColor?: (data: AnnotationData) => string; }) => AnnotationDomData; /** * A handler function for when an annotation is focused and * a key is pressed. * * @param event The event fired when the user pressed a key. * @param a11yStore The store that controls the state for * a11y focus. */ export declare const onAnnotationKeyDown: ({ event, a11yStore }: { a11yStore: LabelerA11yStore; event: React.KeyboardEvent; }) => void; /** * Get the new token range of an annotation after resizing. * * @param annotation The resized annotation. * @param knob The position of the dragged knob. * @param tokenIndex The index of the last token after dragging. * @returns The new token range: startIndex and endIndex, and the new knob position. */ export declare const getAnnotationTokenRangeAfterResizing: (annotation: AnnotationData, knob: 'start' | 'end', tokenIndex: number) => { endIndex: number; startIndex: number; knob: 'start' | 'end'; };