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.
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 |
---|---|---|---|
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
For more information about our API support guarantees, see here.
Signature
properties?: PropertySet;
Type: PropertySet
refType
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
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.
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.
For more information about our API support guarantees, see here.
Signature
getSegment(): ISegment | undefined;
Returns
Return type: ISegment | undefined
isLeaf
For more information about our API support guarantees, see here.
Signature
isLeaf(): this is ISegment;
Returns
Return type: this is ISegment