Skip to main content

SynchronizedString Interface

The value returned by useTreeSynchronizedString(tree, initialSelection).

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.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
export interface SynchronizedString

Properties

PropertyAlertsModifiersTypeDescription
selectionAlphareadonlyTextSelection | undefinedA selection range tracked across edits, or undefined when no selection is being tracked.
textAlphareadonlystringThe tree's current text.

Property Details

selection

A selection range tracked across edits, or undefined when no selection is being tracked.

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 selection: TextSelection | undefined;

Type: TextSelection | undefined

Remarks

Seeded from the initialSelection passed to useTreeSynchronizedString(tree, initialSelection) and adjusted as the tree's characters change so it follows the same logical position across edits.

Tracking is best-effort: in rare cases the selection may be dropped (become undefined) when it cannot be mapped reliably across a change.

This is not a live caret: the hook does not observe the user's actual cursor, so a consumer that needs the real caret position must read it from the rendered element itself.

text

The tree's current text.

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 text: string;

Type: string