ReferencePosition Interface

Packages > @fluidframework/merge-tree > ReferencePosition

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

Property Alerts Modifiers Type Description
properties Alpha optional PropertySet Properties associated with this reference
refType Alpha ReferenceType
slidingPreference Alpha optional 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

Methods

Method Alerts Return Type Description
addProperties(newProps) Deprecated, Alpha void
getOffset() Alpha number Gets the offset for this reference position within its associated segment.
getSegment() Alpha ISegment | undefined Gets the segment that this reference position is semantically associated with. Returns undefined iff the reference became detached from the string.
isLeaf() Alpha this is ISegment

Property Details

properties

Properties associated with this reference

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

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

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

Signature

properties?: PropertySet;

Type: PropertySet

refType

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

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

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 as an alpha preview and may change without notice.

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

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

Signature

slidingPreference?: SlidingPreference;

Type: SlidingPreference

Method Details

addProperties

This API is deprecated and will be removed in a future release.

  • This function should not be used externally and will be removed in a subsequent release.

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

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

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

Signature

addProperties(newProps: PropertySet): void;

Remarks

Note that merge-tree does not broadcast changes to other clients. It is up to the consumer to ensure broadcast happens if that is desired.

Parameters

Parameter Type Description
newProps PropertySet Properties to add to this reference.

getOffset

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

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

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

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 as an alpha preview and may change without notice.

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

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

Signature

getSegment(): ISegment | undefined;

Returns

Return type: ISegment | undefined

isLeaf

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

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

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

Signature

isLeaf(): this is ISegment;

Returns

Return type: this is ISegment