UNPKG

textchecker-element

Version:
62 lines (61 loc) 4.59 kB
export function createCaretCoordinatesDiv(options: any): HTMLElement; /** * In some environments, a font-zoom my be active, e.g. on Android accessibility settings * may increase the font-size, so that applying the measured font-size will actually be * zoomed (again). * * This function tests, if the applied font-size is equal to the measured/computed one and * returns the factor, i.e. * 1: not zoomed * < 1: decreased font-size (zoom-out) * > 1: increased font-size (zoom-in) * * @returns {number} the zoom-factor for font-size */ export function measureFontZoom(): number; export function styleCaretCoordinatesDiv(element: any, position: any, div: any, options: any): void; export function resetStyleCaretCoordinatesDiv(): void; export function updateCaretCoordinates(element: any, position: any, div: any, options: any): { top: number; left: number; height: number; }; /** * @param {HTMLInput | HTMLTextArea} element * the HTML text control for which to determine the coordinates * @param {Number} position * the index of the character (within the text of the text-control) where the caret should appear * @param {PlainObject} [options] OPTIONAL * options for calculating the caret coordinates: * options.reuse BOOLEAN: reuse shadow DIV that is used for calculating the caret coordinates (DEFAULT: false) * options.returnDiv BOOLEAN: if reuse was enabled, returns the shadow DIV in the coordinates-object in property <code>_div</code> (DEFAULT: false) * options.returnHeight BOOLEAN: returns the caret height in the returned coordinates-object in property <code>height</code> (DEFAULT: false) * options.id STRING: the id attribute for the shadow DIV (DEFAULT: "input-textarea-caret-position-mirror-div") * options.guessIfUpdateStyle BOOLEAN | FUNCTION: if TRUE, styling of the shadow DIV is not updated, if the current target element has the same type (Tag Name) as the previous one. * If function: a callback for determining, if the shadow DIV's style should be updated (return TRUE, if it should get updated): callback(shadowDiv) : boolean * NOTE this option is only relevant, if "reuse" is TRUE. * (DEFAULT: false) * options.forceUpdateStyle BOOLEAN: force updating the style of the shadow DIV; only relevant, if "reuse" is TRUE (DEFAULT: false) * options.forceClearFauxStyle BOOLEAN: force faux span to use "cleared" style (e.g. in case SPAN is globally styled) (DEFAULT: false) * options.fauxId STRING: use ID for faux span (e.g. for styling faux span) (DEFAULT: undefined) * options.fontZoom NUMBER | BOOLEAN: apply zoom factor to font-size. * If <code>true</code> (boolean) the zoom factor will be calculated using measureFontZoom(), and the option-value * (<code>true</code>) will be replaced with the measured zoom factor. * (DEFAULT: undefined) * * options.allowInputWrap BOOLEAN: if TRUE, allows text-wrapping for INPUT elements (note: the W3C specifically states that text in INPUT will not be wrapped, even if styles would "request" it, like "word-wrap: break-word" or "word-break: break-all | break-word" or similar) * (DEFAULT: false) * options.additionalStyles ARRAY<STRING>: transfers additional styles properties from the target element to the shadow DIV * options.additionalAttributes ARRAY<STRING>: transfers additional (node) attributes from the target element to the shadow DIV * * * options.text STRING | FUNCTION: the text value that should be used for the calculation. * If function: a callback which's return value is used as the text: <code>callback(element, options) : string</code> * */ declare function getCaretCoordinates(element: HTMLInput | HTMLTextArea, position: number, options?: PlainObject): { top: number; left: number; height: number; }; export { getCaretCoordinates as getCoordinates };