@fluidframework/sequence 0.48.2 → 0.49.0-39313

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,25 @@ import { SharedStringFactory } from "./sequenceFactory";
14
14
  * Fluid object interface describing access methods on a SharedString
15
15
  */
16
16
  export interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
17
+ /**
18
+ * Inserts the text at the position.
19
+ * @param pos - The position to insert the text at
20
+ * @param text - The text to insert
21
+ * @param props - The properties of text
22
+ */
17
23
  insertText(pos: number, text: string, props?: MergeTree.PropertySet);
18
24
 
25
+ /**
26
+ * Inserts a marker at the position.
27
+ * @param pos - The position to insert the marker at
28
+ * @param refType - The reference type of the marker
29
+ * @param props - The properties of the marker
30
+ */
19
31
  insertMarker(pos: number, refType: MergeTree.ReferenceType, props?: MergeTree.PropertySet);
20
32
 
33
+ /**
34
+ * {@inheritDoc SharedSegmentSequence.posFromRelativePos}
35
+ */
21
36
  posFromRelativePos(relativePos: MergeTree.IRelativePosition);
22
37
  }
23
38
 
@@ -25,7 +40,7 @@ export type SharedStringSegment = MergeTree.TextSegment | MergeTree.Marker;
25
40
 
26
41
  /**
27
42
  * The Shared String is a specialized data structure for handling collaborative
28
- * text. It is based on a more general Sequence data structure but has
43
+ * text. It is based on a more general Sequence data structure but has
29
44
  * additional features that make working with text easier.
30
45
  *
31
46
  * In addition to text, a Shared String can also contain markers. Markers can be
@@ -35,8 +50,7 @@ export type SharedStringSegment = MergeTree.TextSegment | MergeTree.Marker;
35
50
  */
36
51
  export class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
37
52
  /**
38
- * Create a new shared string
39
- *
53
+ * Create a new shared string.
40
54
  * @param runtime - data store runtime the new shared string belongs to
41
55
  * @param id - optional name of the shared string
42
56
  * @returns newly create shared string (but not attached yet)
@@ -47,7 +61,6 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
47
61
 
48
62
  /**
49
63
  * Get a factory for SharedString to register with the data store.
50
- *
51
64
  * @returns a factory that creates and load SharedString
52
65
  */
53
66
  public static getFactory() {
@@ -66,9 +79,8 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
66
79
  }
67
80
 
68
81
  /**
69
- * Inserts a marker at a relative postition
70
- *
71
- * @param relativePos1 - The relative postition to insert the marker at
82
+ * Inserts a marker at a relative position.
83
+ * @param relativePos1 - The relative position to insert the marker at
72
84
  * @param refType - The reference type of the marker
73
85
  * @param props - The properties of the marker
74
86
  */
@@ -89,11 +101,7 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
89
101
  }
90
102
 
91
103
  /**
92
- * Inserts a marker at the postition
93
- *
94
- * @param pos - The postition to insert the marker at
95
- * @param refType - The reference type of the marker
96
- * @param props - The properties of the marker
104
+ * {@inheritDoc ISharedString.insertMarker}
97
105
  */
98
106
  public insertMarker(
99
107
  pos: number,
@@ -112,9 +120,8 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
112
120
  }
113
121
 
114
122
  /**
115
- * Inserts the text at the postition
116
- *
117
- * @param relativePos1 - The relative postition to insert the text at
123
+ * Inserts the text at the position.
124
+ * @param relativePos1 - The relative position to insert the text at
118
125
  * @param text - The text to insert
119
126
  * @param props - The properties of text
120
127
  */
@@ -132,11 +139,7 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
132
139
  }
133
140
 
134
141
  /**
135
- * Inserts the text at the postition
136
- *
137
- * @param pos - The postition to insert the text at
138
- * @param text - The text to insert
139
- * @param props - The properties of text
142
+ * {@inheritDoc ISharedString.insertText}
140
143
  */
141
144
  public insertText(pos: number, text: string, props?: MergeTree.PropertySet) {
142
145
  const segment = new MergeTree.TextSegment(text);
@@ -149,9 +152,9 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
149
152
  this.submitSequenceMessage(insertOp);
150
153
  }
151
154
  }
155
+
152
156
  /**
153
157
  * Replaces a range with the provided text.
154
- *
155
158
  * @param start - The inclusive start of the range to replace
156
159
  * @param end - The exclusive end of the range to replace
157
160
  * @param text - The text to replace the range with
@@ -161,14 +164,18 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
161
164
  this.replaceRange(start, end, MergeTree.TextSegment.make(text, props));
162
165
  }
163
166
 
167
+ /**
168
+ * Removes the text in the given range.
169
+ * @param start - The inclusive start of the range to remove
170
+ * @param end - The exclusive end of the range to replace
171
+ * @returns the message sent.
172
+ */
164
173
  public removeText(start: number, end: number) {
165
174
  return this.removeRange(start, end);
166
175
  }
167
176
 
168
177
  /**
169
- * Annotates the marker with the provided properties
170
- * and calls the callback on concensus.
171
- *
178
+ * Annotates the marker with the provided properties and calls the callback on consensus.
172
179
  * @param marker - The marker to annotate
173
180
  * @param props - The properties to annotate the marker with
174
181
  * @param consensusCallback - The callback called when consensus is reached
@@ -184,8 +191,7 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
184
191
  }
185
192
 
186
193
  /**
187
- * Annotates the marker with the provided properties
188
- *
194
+ * Annotates the marker with the provided properties.
189
195
  * @param marker - The marker to annotate
190
196
  * @param props - The properties to annotate the marker with
191
197
  * @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
@@ -208,21 +214,31 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
208
214
  const segmentWindow = this.client.getCollabWindow();
209
215
  return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);
210
216
  }
217
+
218
+ /**
219
+ * Retrieve text from the SharedString in string format.
220
+ * @param start - The starting index of the text to retrieve, or 0 if omitted.
221
+ * @param end - The ending index of the text to retrieve, or the end of the string if omitted
222
+ * @returns The requested text content as a string.
223
+ */
211
224
  public getText(start?: number, end?: number) {
212
225
  const segmentWindow = this.client.getCollabWindow();
213
226
  return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "", start, end);
214
227
  }
228
+
215
229
  /**
216
- * Adds spaces for markers and handles, so that position calculations account for them
230
+ * Adds spaces for markers and handles, so that position calculations account for them.
217
231
  */
218
232
  public getTextWithPlaceholders() {
219
233
  const segmentWindow = this.client.getCollabWindow();
220
234
  return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ");
221
235
  }
236
+
222
237
  public getTextRangeWithPlaceholders(start: number, end: number) {
223
238
  const segmentWindow = this.client.getCollabWindow();
224
239
  return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
225
240
  }
241
+
226
242
  public getTextRangeWithMarkers(start: number, end: number) {
227
243
  const segmentWindow = this.client.getCollabWindow();
228
244
  return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "*", start, end);