ISharedString Interface
Fluid object interface describing access methods on a SharedString
To use, import via fluid-framework/legacy
.
For more information about our API support guarantees, see here.
Signature
export interface ISharedString extends ISharedSegmentSequence<SharedStringSegment>
Extends: ISharedSegmentSequence<SharedStringSegment>
Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
annotateMarker(marker, props) | Alpha |
void | Annotates the marker with the provided properties. |
getMarkerFromId(id) | Alpha |
ISegment | undefined | Looks up and returns a Marker using its id. Returns undefined if there is no marker with the provided id in this SharedString . |
getText(start, end) | Alpha |
string | Retrieve text from the SharedString in string format. |
getTextRangeWithMarkers(start, end) | Alpha |
string | |
getTextWithPlaceholders(start, end) | Alpha |
string | Adds spaces for markers and handles, so that position calculations account for them. |
insertMarker(pos, refType, props) | Alpha |
void | Inserts a marker at the position. |
insertMarkerRelative(relativePos1, refType, props) | Alpha |
void | Inserts a marker at a relative position. |
insertText(pos, text, props) | Alpha |
void | Inserts the text at the position. |
insertTextRelative(relativePos1, text, props) | Alpha |
void | Inserts the text at the position. |
removeText(start, end) | Alpha |
void | Removes the text in the given range. |
replaceText(start, end, text, props) | Alpha |
void | Replaces a range with the provided text. |
searchForMarker(startPos, markerLabel, forwards) | Alpha |
Marker | undefined | Searches a string for the nearest marker in either direction to a given start position. The search will include the start position, so markers at the start position are valid results of the search. |
Method Details
annotateMarker
Annotates the marker with the provided properties.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
annotateMarker(marker: Marker, props: PropertySet): void;
Parameters
Parameter | Type | Description |
---|---|---|
marker | Marker | The marker to annotate |
props | PropertySet | The properties to annotate the marker with |
getMarkerFromId
Looks up and returns a Marker
using its id. Returns undefined
if there is no marker with the provided id in this SharedString
.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
getMarkerFromId(id: string): ISegment | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
id | string |
Returns
Return type: ISegment | undefined
getText
Retrieve text from the SharedString in string format.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
getText(start?: number, end?: number): string;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
start | optional | number | The starting index of the text to retrieve, or 0 if omitted. |
end | optional | number | The ending index of the text to retrieve, or the end of the string if omitted |
Returns
The requested text content as a string.
Return type: string
getTextRangeWithMarkers
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
getTextRangeWithMarkers(start: number, end: number): string;
Parameters
Parameter | Type | Description |
---|---|---|
start | number | |
end | number |
Returns
Return type: string
getTextWithPlaceholders
Adds spaces for markers and handles, so that position calculations account for them.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
getTextWithPlaceholders(start?: number, end?: number): string;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
start | optional | number | |
end | optional | number |
Returns
Return type: string
insertMarker
Inserts a marker at the position.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
pos | number | The position to insert the marker at | |
refType | ReferenceType | The reference type of the marker | |
props | optional | PropertySet | The properties of the marker |
insertMarkerRelative
Inserts a marker at a relative position.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
insertMarkerRelative(relativePos1: IRelativePosition, refType: ReferenceType, props?: PropertySet): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
relativePos1 | IRelativePosition | The relative position to insert the marker at | |
refType | ReferenceType | The reference type of the marker | |
props | optional | PropertySet | The properties of the marker |
insertText
Inserts the text at the position.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
insertText(pos: number, text: string, props?: PropertySet): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
pos | number | The position to insert the text at | |
text | string | The text to insert | |
props | optional | PropertySet | The properties of the text |
insertTextRelative
Inserts the text at the position.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
relativePos1 | IRelativePosition | The relative position to insert the text at | |
text | string | The text to insert | |
props | optional | PropertySet | The properties of text |
removeText
Removes the text in the given range.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
removeText(start: number, end: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The inclusive start of the range to remove |
end | number | The exclusive end of the range to replace |
Returns
the message sent.
replaceText
Replaces a range with the provided text.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
replaceText(start: number, end: number, text: string, props?: PropertySet): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
start | number | The inclusive start of the range to replace | |
end | number | The exclusive end of the range to replace | |
text | string | The text to replace the range with | |
props | optional | PropertySet | Optional. The properties of the replacement text |
searchForMarker
Searches a string for the nearest marker in either direction to a given start position. The search will include the start position, so markers at the start position are valid results of the search.
To use, import via fluid-framework/alpha
.
For more information about our API support guarantees, see here.
Signature
searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
startPos | number | Position at which to start the search | |
markerLabel | string | Label of the marker to search for | |
forwards | optional | boolean | Whether the desired marker comes before (false) or after (true) startPos . Default true. |
Returns
Return type: Marker | undefined