@chayns-components/emoji-input
Version:
Input field that supports HTML elements and emojis
27 lines (26 loc) • 1.25 kB
TypeScript
interface InsertTextAtCursorPositionOptions {
editorElement: HTMLDivElement;
text: string;
shouldUseSavedSelection?: boolean;
}
/**
* This function inserts the passed text at the correct position in the editor element. If the
* element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
* will be appended to the back of the input field content.
*
* In addition, this function also sets the cursor to the correct position when the input field
* has the focus. For this purpose, the current position of the cursor or a selection is read to
* calculate the cursor position after inserting the text.
*
* @param {Object} options - Object with element and text to insert
* @param {HTMLDivElement} options.editorElement - Element to insert text into
* @param {string} options.text - Text to insert into element
*/
export declare const insertTextAtCursorPosition: ({ editorElement, text, shouldUseSavedSelection, }: InsertTextAtCursorPositionOptions) => void;
export interface ReplaceTextOptions {
editorElement: HTMLDivElement;
searchText: string;
pasteText: string;
}
export declare const replaceText: ({ editorElement, searchText, pasteText }: ReplaceTextOptions) => void;
export {};