Skip to main content

ReferencePosition Interface

Represents a reference to a place within a merge tree. This place conceptually remains stable over time by referring to a particular segment and offset within that segment. Thus, this reference's character position changes as the tree is edited.

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/merge-tree/legacy.

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

Signature

export interface ReferencePosition

Properties

PropertyAlertsModifiersTypeDescription
propertiesBetaoptionalPropertySetProperties associated with this reference
refTypeBetaReferenceType
slidingPreferenceBetaoptionalSlidingPreference

The direction for this reference position to slide when the segment it points to is removed. See SlidingPreference for additional context.

Defaults to SlidingPreference.Forward

Methods

MethodAlertsReturn TypeDescription
getOffset()BetanumberGets the offset for this reference position within its associated segment.
getSegment()BetaISegment | undefinedGets the segment that this reference position is semantically associated with. Returns undefined iff the reference became detached from the string.
isLeaf()Betathis is ISegment

Property Details

properties

Properties associated with this reference

This API is provided for existing users, but is not recommended for new users.

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

Signature

properties?: PropertySet;

Type: PropertySet

refType

This API is provided for existing users, but is not recommended for new users.

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

Signature

refType: ReferenceType;

Type: ReferenceType

slidingPreference

The direction for this reference position to slide when the segment it points to is removed. See SlidingPreference for additional context.

Defaults to SlidingPreference.Forward

This API is provided for existing users, but is not recommended for new users.

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

Signature

slidingPreference?: SlidingPreference;

Type: SlidingPreference

Method Details

getOffset

Gets the offset for this reference position within its associated segment.

This API is provided for existing users, but is not recommended for new users.

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

Signature

getOffset(): number;

Example

If a merge-tree has 3 leaf segments ["hello", " ", "world"] and a ReferencePosition refers to the "l" in "world", that reference's offset would be 3 as "l" is the character at index 3 within "world".

Returns

Return type: number

getSegment

Gets the segment that this reference position is semantically associated with. Returns undefined iff the reference became detached from the string.

This API is provided for existing users, but is not recommended for new users.

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

Signature

getSegment(): ISegment | undefined;

Returns

Return type: ISegment | undefined

isLeaf

This API is provided for existing users, but is not recommended for new users.

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

Signature

isLeaf(): this is ISegment;

Returns

Return type: this is ISegment