/** * Copyright (c) Microsoft. All rights reserved. */ import { LabelerA11yStore } from '../stores/LabelerA11yStore'; import { LabelerConfigStore } from '../stores/LabelerConfigStore'; import { LabelerSelectionStore } from '../stores/LabelerSelectionStore'; import { LineStore } from '../stores/LineStore'; import { TokenStore } from '../stores/TokenStore'; import { CharToTokenMapType, ITokenStore, TargetIndex, TokenToCharMapType } from '../types/labelerTypes'; type LineDto = { lineNumber: number; tokenRangeIndices: [number, number]; }; /** * Gets the line DOM element with the given index from the * given HTML container. * * @param ref The HTML element to search in. * @param index The index of the line to get. * @returns The line HTML element. */ export declare const getLineElementByIndex: (ref: HTMLElement, index: number) => Element; /** * Breaks the text into lines based on: * - The `\n` characters in the original text. * - Each of these lines are then further broken into more lines if the number * of characters in it exceeds the maximum number of allowable characters. * * Check the unit tests for sample input/output. Also check `labeler.md` for * more information. * * @param text The text to break into lines. * @param maxCharCountPerLine The maximum number of characters allowed in each line. * @param configStore The labeler configuration store to access some configs * * @returns An array of lines - the original line number and a token range (start token index, end token index). */ export declare const getLineInfos: (text: string, maxCharCountPerLine: number, configStore: LabelerConfigStore) => LineDto[]; /** * This util method calculates all tokens in all line of the given text based * on whether the labeler is tokenized by character or word. * If tokenizationType is word, it splits the line text with spaces or `\n` so each word is a token. * If tokenizationType is character, it splits the line text into characters (the default behavior) so each character is a token. * * @param text The text of the labeler. * @param lines The line DtoS after splitting the text, to calculate tokens of each line. * @param configStore The labeler configuration store to access some configs. * @returns list of all tokens in the text. */ export declare const getTokens: (text: string, lines: LineDto[], configStore: LabelerConfigStore) => string[]; /** * This util method calculates the mappers needed to update annotation token ranges when passing to/from the labeler. * That's because there are two modes of tokenization in the labeler, character and word tokenization. * So we need to map each index in the labeler text to the corresponding token index. * and map each token index to the start and end indices of that token in the labeler text. * * @param text The text of the labeler. * @param lines The line DtoS after splitting the text. * @param configStore The labeler configuration store to access some configs * @returns index-to-token and token-to-char maps */ export declare const getCharAndTokenMapping: (text: string, lines: LineDto[], configStore: LabelerConfigStore) => { charToTokenMap: CharToTokenMapType; tokenToCharMap: TokenToCharMapType; }; /** * The handler function that handles all selection and a11y * actions fired from a line in a labeler. The event is * considered consumed and thus blocked from propagation if * any of the selection or a11y actions are fired on it. * * @param event The original key down event fired. * @param lineRef The reference to the line DOM element. * @param lineStore The backing data store for this line. * @param a11yStore The store containing a11y state for * the labeler. * @param selectionStore The store containing the selection * state for the labeler. */ export declare const onLineRendererKeyDown: ({ event, lineRef, lineStore, a11yStore, selectionStore, targetIndex }: { lineStore: LineStore; lineRef: HTMLDivElement; event: React.KeyboardEvent; a11yStore: LabelerA11yStore; selectionStore: LabelerSelectionStore; targetIndex: TargetIndex; }) => void; /** * Gets the max width of the labeler lines and x offset of the svg layer. * * @param rootRef The reference of the labeler Dom element. * @param isRtl Whether the labeler is in rtl mode or not. * @returns The max width of the labeler lines and x offset of the svg layer. */ export declare const getMaxLineWidthAndSvgXOffset: (rootRef: HTMLDivElement, isRtl: boolean) => { maxLineWidth: number; svgXOffset: number; }; export declare const getTargetIndex: (lineStores: LineStore[], index: number) => TargetIndex; export {};