Skip to main content
Version: v2

TextSelection Interface

A text selection or cursor range expressed as UTF-16 code-unit offsets.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/react/alpha.

For more information about our API support guarantees, see here.

Input

This type is "input," meaning that code outside of the library defining it should not read from it. Future versions of this type may add optional members or make typing of members more general.

Signature​

export interface TextSelection

Remarks​

These match the selectionStart / selectionEnd properties of an HTML <input> / <textarea>, and the offsets used to index into a JavaScript string. A collapsed cursor has start === end.

Properties​

PropertyAlertsModifiersTypeDescription
endAlphareadonlynumberUTF-16 offset of the end of the selection.
startAlphareadonlynumberUTF-16 offset of the start of the selection.

Property Details​

end​

UTF-16 offset of the end of the selection.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

readonly end: number;

Type: number

start​

UTF-16 offset of the start of the selection.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

readonly start: number;

Type: number