apphouse
Version:
Component library for React that uses observable state management and theme-able components.
43 lines (42 loc) • 1.42 kB
TypeScript
/**
* A class to help with text selection and manipulation of textareas and inputs
*/
export declare class TextSelection {
elm: HTMLTextAreaElement;
start: number;
end: number;
value: string;
constructor(elm: HTMLTextAreaElement);
/**
* Sets the position of the text selection within an element.
*
* @param {number} [start] - The start position of the selection.
* @param {number} [end] - The end position of the selection.
* @returns {Object} - Returns the instance of the object.
*/
position(start?: number, end?: number): this;
/**
* Inserts text at the current cursor position
* @param text the text to insert
* @returns the TextSelection instance
*/
insertText(text: string): this;
/**
* Gets the selected text value from a textarea / input
* @param start number start index
* @param end number end index
* @returns the selected text
*/
getSelectedValue(start?: number, end?: number): string;
/**
* Gets the start index of the current line where the text is selected
* @returns the start index of the current line
*/
getLineStartNumber(): number;
/** Indent on new lines */
getIndentText(): string;
lineStarInsert(text: string): this;
lineStarRemove(text: string): void;
/** Notify any possible listeners of the change */
notifyChange(): void;
}