UNPKG

@chayns-components/emoji-input

Version:
46 lines (45 loc) 2.31 kB
import type { KeyboardEvent, RefObject } from 'react'; interface SaveSelectionOptions { shouldIgnoreEmptyTextNodes?: boolean; } export declare const saveSelection: (element: HTMLDivElement, { shouldIgnoreEmptyTextNodes }?: SaveSelectionOptions) => void; export declare const restoreSelection: (element: HTMLDivElement) => void; export declare const insertInvisibleCursorMarker: () => void; export declare const insertPseudoMarker: () => void; export declare const insertCursorAtMarker: (ref: RefObject<HTMLDivElement>) => void; export declare const moveSelectionOffset: (distance: number) => void; export declare const setChildIndex: (index: number) => void; /** * This function returns the code of the character that will be removed by the KeyDown event in the * next step, if the "Backspace" or "Delete" key was pressed and there is no selection of multiple * characters. * * @param event - Keyboard event from "onKeyDown" */ export declare const getCharCodeThatWillBeDeleted: (event: KeyboardEvent<HTMLDivElement>) => number | null | undefined; export type ReplaceTextOptions = { shouldReplaceNearCursor?: boolean; }; interface FindAndSelectTextOptions { editorElement: HTMLDivElement; searchText: string; options?: ReplaceTextOptions; } export interface SetCursorPositionByAbsIndexOptions { editorElement: HTMLDivElement; position: number; } export declare const findAndSelectText: ({ editorElement, searchText, options, }: FindAndSelectTextOptions) => Range | null; export declare const getCurrentCursorPosition: (editorElement: HTMLDivElement | null) => number | null; export declare const setCursorPositionByAbsIndex: ({ editorElement, position, }: SetCursorPositionByAbsIndexOptions) => void; /** * Unwraps any no-emoji-convert span that contains the cursor. * This removes the span element but keeps its text content, preventing the cursor from getting stuck. */ export declare const unwrapIgnoreEmojiSpanAtCursor: (editorElement: HTMLDivElement | null) => void; /** * Moves the cursor outside of any no-emoji-convert span if it's currently inside one. * This prevents the cursor from getting "stuck" inside the protection span when typing. */ export declare const moveCursorOutOfIgnoreEmojiSpan: (editorElement: HTMLDivElement | null) => void; export {};