@fluidframework/sequence 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
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.
- package/.eslintrc.js +9 -11
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +449 -0
- package/README.md +364 -183
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/sequence.api.md +741 -0
- package/dist/{defaultMap.js → defaultMap.cjs} +29 -22
- package/dist/defaultMap.cjs.map +1 -0
- package/dist/defaultMap.d.ts +7 -6
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.cjs +7 -0
- package/dist/defaultMapInterfaces.cjs.map +1 -0
- package/dist/defaultMapInterfaces.d.ts +44 -12
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/index.cjs +60 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +14 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/intervalCollection.cjs +1159 -0
- package/dist/intervalCollection.cjs.map +1 -0
- package/dist/intervalCollection.d.ts +461 -162
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.cjs +66 -0
- package/dist/intervalIndex/endpointInRangeIndex.cjs.map +1 -0
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +34 -0
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
- package/dist/intervalIndex/endpointIndex.cjs +47 -0
- package/dist/intervalIndex/endpointIndex.cjs.map +1 -0
- package/dist/intervalIndex/endpointIndex.d.ts +38 -0
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -0
- package/dist/intervalIndex/idIntervalIndex.cjs +44 -0
- package/dist/intervalIndex/idIntervalIndex.cjs.map +1 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts +18 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -0
- package/dist/intervalIndex/index.cjs +24 -0
- package/dist/intervalIndex/index.cjs.map +1 -0
- package/dist/intervalIndex/index.d.ts +13 -0
- package/dist/intervalIndex/index.d.ts.map +1 -0
- package/dist/{defaultMapInterfaces.js → intervalIndex/intervalIndex.cjs} +1 -1
- package/dist/intervalIndex/intervalIndex.cjs.map +1 -0
- package/dist/intervalIndex/intervalIndex.d.ts +30 -0
- package/dist/intervalIndex/intervalIndex.d.ts.map +1 -0
- package/dist/intervalIndex/intervalIndexUtils.cjs +22 -0
- package/dist/intervalIndex/intervalIndexUtils.cjs.map +1 -0
- package/dist/intervalIndex/intervalIndexUtils.d.ts +17 -0
- package/dist/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.cjs +116 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.cjs.map +1 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +44 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs +41 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs.map +1 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +11 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.cjs +7 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.cjs.map +1 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +35 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -0
- package/dist/intervalIndex/startpointInRangeIndex.cjs +66 -0
- package/dist/intervalIndex/startpointInRangeIndex.cjs.map +1 -0
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +34 -0
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
- package/dist/intervalTree.cjs +80 -0
- package/dist/intervalTree.cjs.map +1 -0
- package/dist/intervalTree.d.ts +24 -0
- package/dist/intervalTree.d.ts.map +1 -0
- package/dist/intervals/index.cjs +23 -0
- package/dist/intervals/index.cjs.map +1 -0
- package/dist/intervals/index.d.ts +8 -0
- package/dist/intervals/index.d.ts.map +1 -0
- package/dist/intervals/interval.cjs +181 -0
- package/dist/intervals/interval.cjs.map +1 -0
- package/dist/intervals/interval.d.ts +84 -0
- package/dist/intervals/interval.d.ts.map +1 -0
- package/dist/intervals/intervalUtils.cjs +83 -0
- package/dist/intervals/intervalUtils.cjs.map +1 -0
- package/dist/intervals/intervalUtils.d.ts +230 -0
- package/dist/intervals/intervalUtils.d.ts.map +1 -0
- package/dist/intervals/sequenceInterval.cjs +378 -0
- package/dist/intervals/sequenceInterval.cjs.map +1 -0
- package/dist/intervals/sequenceInterval.d.ts +137 -0
- package/dist/intervals/sequenceInterval.d.ts.map +1 -0
- package/dist/{localValues.js → localValues.cjs} +1 -1
- package/dist/localValues.cjs.map +1 -0
- package/dist/localValues.d.ts +2 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/revertibles.cjs +425 -0
- package/dist/revertibles.cjs.map +1 -0
- package/dist/revertibles.d.ts +86 -0
- package/dist/revertibles.d.ts.map +1 -0
- package/dist/sequence-alpha.d.ts +1315 -0
- package/dist/sequence-beta.d.ts +244 -0
- package/dist/sequence-public.d.ts +244 -0
- package/dist/sequence-untrimmed.d.ts +1803 -0
- package/dist/{sequence.js → sequence.cjs} +226 -156
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.ts +125 -48
- package/dist/sequence.d.ts.map +1 -1
- package/dist/{sequenceDeltaEvent.js → sequenceDeltaEvent.cjs} +18 -8
- package/dist/sequenceDeltaEvent.cjs.map +1 -0
- package/dist/sequenceDeltaEvent.d.ts +24 -7
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceFactory.cjs +55 -0
- package/dist/sequenceFactory.cjs.map +1 -0
- package/dist/sequenceFactory.d.ts +3 -89
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/{sharedIntervalCollection.js → sharedIntervalCollection.cjs} +17 -22
- package/dist/sharedIntervalCollection.cjs.map +1 -0
- package/dist/sharedIntervalCollection.d.ts +12 -12
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/{sharedSequence.js → sharedSequence.cjs} +29 -22
- package/dist/sharedSequence.cjs.map +1 -0
- package/dist/sharedSequence.d.ts +14 -2
- package/dist/sharedSequence.d.ts.map +1 -1
- package/dist/sharedString.cjs +286 -0
- package/dist/sharedString.cjs.map +1 -0
- package/dist/sharedString.d.ts +58 -22
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/{defaultMap.d.ts → defaultMap.d.mts} +7 -6
- package/lib/defaultMap.d.mts.map +1 -0
- package/lib/{defaultMap.js → defaultMap.mjs} +28 -21
- package/lib/defaultMap.mjs.map +1 -0
- package/lib/{defaultMapInterfaces.d.ts → defaultMapInterfaces.d.mts} +44 -12
- package/lib/defaultMapInterfaces.d.mts.map +1 -0
- package/lib/defaultMapInterfaces.mjs +6 -0
- package/lib/defaultMapInterfaces.mjs.map +1 -0
- package/lib/index.d.mts +17 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +16 -0
- package/lib/index.mjs.map +1 -0
- package/lib/intervalCollection.d.mts +569 -0
- package/lib/intervalCollection.d.mts.map +1 -0
- package/lib/intervalCollection.mjs +1144 -0
- package/lib/intervalCollection.mjs.map +1 -0
- package/lib/intervalIndex/endpointInRangeIndex.d.mts +34 -0
- package/lib/intervalIndex/endpointInRangeIndex.d.mts.map +1 -0
- package/lib/intervalIndex/endpointInRangeIndex.mjs +61 -0
- package/lib/intervalIndex/endpointInRangeIndex.mjs.map +1 -0
- package/lib/intervalIndex/endpointIndex.d.mts +38 -0
- package/lib/intervalIndex/endpointIndex.d.mts.map +1 -0
- package/lib/intervalIndex/endpointIndex.mjs +42 -0
- package/lib/intervalIndex/endpointIndex.mjs.map +1 -0
- package/lib/intervalIndex/idIntervalIndex.d.mts +18 -0
- package/lib/intervalIndex/idIntervalIndex.d.mts.map +1 -0
- package/lib/intervalIndex/idIntervalIndex.mjs +40 -0
- package/lib/intervalIndex/idIntervalIndex.mjs.map +1 -0
- package/lib/intervalIndex/index.d.mts +13 -0
- package/lib/intervalIndex/index.d.mts.map +1 -0
- package/lib/intervalIndex/index.mjs +11 -0
- package/lib/intervalIndex/index.mjs.map +1 -0
- package/lib/intervalIndex/intervalIndex.d.mts +30 -0
- package/lib/intervalIndex/intervalIndex.d.mts.map +1 -0
- package/lib/{defaultMapInterfaces.js → intervalIndex/intervalIndex.mjs} +1 -1
- package/lib/intervalIndex/intervalIndex.mjs.map +1 -0
- package/lib/intervalIndex/intervalIndexUtils.d.mts +17 -0
- package/lib/intervalIndex/intervalIndexUtils.d.mts.map +1 -0
- package/lib/intervalIndex/intervalIndexUtils.mjs +18 -0
- package/lib/intervalIndex/intervalIndexUtils.mjs.map +1 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.d.mts +44 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.d.mts.map +1 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.mjs +111 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.mjs.map +1 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts +11 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts.map +1 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs +37 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs.map +1 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.d.mts +35 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.d.mts.map +1 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.mjs +6 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.mjs.map +1 -0
- package/lib/intervalIndex/startpointInRangeIndex.d.mts +34 -0
- package/lib/intervalIndex/startpointInRangeIndex.d.mts.map +1 -0
- package/lib/intervalIndex/startpointInRangeIndex.mjs +61 -0
- package/lib/intervalIndex/startpointInRangeIndex.mjs.map +1 -0
- package/lib/intervalTree.d.mts +24 -0
- package/lib/intervalTree.d.mts.map +1 -0
- package/lib/intervalTree.mjs +76 -0
- package/lib/intervalTree.mjs.map +1 -0
- package/lib/intervals/index.d.mts +8 -0
- package/lib/intervals/index.d.mts.map +1 -0
- package/lib/intervals/index.mjs +8 -0
- package/lib/intervals/index.mjs.map +1 -0
- package/lib/intervals/interval.d.mts +84 -0
- package/lib/intervals/interval.d.mts.map +1 -0
- package/lib/intervals/interval.mjs +176 -0
- package/lib/intervals/interval.mjs.map +1 -0
- package/lib/intervals/intervalUtils.d.mts +230 -0
- package/lib/intervals/intervalUtils.d.mts.map +1 -0
- package/lib/intervals/intervalUtils.mjs +77 -0
- package/lib/intervals/intervalUtils.mjs.map +1 -0
- package/lib/intervals/sequenceInterval.d.mts +137 -0
- package/lib/intervals/sequenceInterval.d.mts.map +1 -0
- package/lib/intervals/sequenceInterval.mjs +370 -0
- package/lib/intervals/sequenceInterval.mjs.map +1 -0
- package/lib/{localValues.d.ts → localValues.d.mts} +3 -2
- package/lib/localValues.d.mts.map +1 -0
- package/lib/{localValues.js → localValues.mjs} +2 -2
- package/lib/localValues.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/revertibles.d.mts +86 -0
- package/lib/revertibles.d.mts.map +1 -0
- package/lib/revertibles.mjs +416 -0
- package/lib/revertibles.mjs.map +1 -0
- package/lib/sequence-alpha.d.mts +1315 -0
- package/lib/sequence-beta.d.mts +244 -0
- package/lib/sequence-public.d.mts +244 -0
- package/lib/sequence-untrimmed.d.mts +1803 -0
- package/lib/{sequence.d.ts → sequence.d.mts} +127 -50
- package/lib/sequence.d.mts.map +1 -0
- package/lib/{sequence.js → sequence.mjs} +225 -152
- package/lib/sequence.mjs.map +1 -0
- package/lib/{sequenceDeltaEvent.d.ts → sequenceDeltaEvent.d.mts} +24 -7
- package/lib/sequenceDeltaEvent.d.mts.map +1 -0
- package/lib/{sequenceDeltaEvent.js → sequenceDeltaEvent.mjs} +20 -8
- package/lib/sequenceDeltaEvent.mjs.map +1 -0
- package/lib/sequenceFactory.d.mts +22 -0
- package/lib/sequenceFactory.d.mts.map +1 -0
- package/lib/sequenceFactory.mjs +51 -0
- package/lib/sequenceFactory.mjs.map +1 -0
- package/lib/{sharedIntervalCollection.d.ts → sharedIntervalCollection.d.mts} +12 -12
- package/lib/sharedIntervalCollection.d.mts.map +1 -0
- package/lib/{sharedIntervalCollection.js → sharedIntervalCollection.mjs} +16 -21
- package/lib/sharedIntervalCollection.mjs.map +1 -0
- package/lib/{sharedSequence.d.ts → sharedSequence.d.mts} +15 -3
- package/lib/sharedSequence.d.mts.map +1 -0
- package/lib/{sharedSequence.js → sharedSequence.mjs} +30 -23
- package/lib/sharedSequence.mjs.map +1 -0
- package/lib/{sharedString.d.ts → sharedString.d.mts} +60 -24
- package/lib/sharedString.d.mts.map +1 -0
- package/lib/sharedString.mjs +281 -0
- package/lib/sharedString.mjs.map +1 -0
- package/package.json +146 -75
- package/prettier.config.cjs +8 -0
- package/sequence.test-files.tar +0 -0
- package/src/defaultMap.ts +417 -403
- package/src/defaultMapInterfaces.ts +157 -117
- package/src/index.ts +86 -26
- package/src/intervalCollection.ts +2043 -1563
- package/src/intervalIndex/endpointInRangeIndex.ts +116 -0
- package/src/intervalIndex/endpointIndex.ts +91 -0
- package/src/intervalIndex/idIntervalIndex.ts +64 -0
- package/src/intervalIndex/index.ts +25 -0
- package/src/intervalIndex/intervalIndex.ts +32 -0
- package/src/intervalIndex/intervalIndexUtils.ts +27 -0
- package/src/intervalIndex/overlappingIntervalsIndex.ts +187 -0
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +80 -0
- package/src/intervalIndex/sequenceIntervalIndexes.ts +34 -0
- package/src/intervalIndex/startpointInRangeIndex.ts +114 -0
- package/src/intervalTree.ts +98 -0
- package/src/intervals/index.ts +25 -0
- package/src/intervals/interval.ts +238 -0
- package/src/intervals/intervalUtils.ts +288 -0
- package/src/intervals/sequenceInterval.ts +616 -0
- package/src/localValues.ts +68 -73
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +693 -0
- package/src/sequence.ts +845 -690
- package/src/sequenceDeltaEvent.ts +164 -131
- package/src/sequenceFactory.ts +58 -214
- package/src/sharedIntervalCollection.ts +161 -152
- package/src/sharedSequence.ts +181 -167
- package/src/sharedString.ts +390 -234
- package/tsc-multi.test.json +10 -0
- package/tsconfig.json +11 -13
- package/.editorconfig +0 -7
- package/.vscode/launch.json +0 -15
- package/dist/defaultMap.js.map +0 -1
- package/dist/defaultMapInterfaces.js.map +0 -1
- package/dist/index.js +0 -44
- package/dist/index.js.map +0 -1
- package/dist/intervalCollection.js +0 -1250
- package/dist/intervalCollection.js.map +0 -1
- package/dist/localValues.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/sequence.js.map +0 -1
- package/dist/sequenceDeltaEvent.js.map +0 -1
- package/dist/sequenceFactory.js +0 -192
- package/dist/sequenceFactory.js.map +0 -1
- package/dist/sharedIntervalCollection.js.map +0 -1
- package/dist/sharedNumberSequence.d.ts +0 -50
- package/dist/sharedNumberSequence.d.ts.map +0 -1
- package/dist/sharedNumberSequence.js +0 -61
- package/dist/sharedNumberSequence.js.map +0 -1
- package/dist/sharedObjectSequence.d.ts +0 -50
- package/dist/sharedObjectSequence.d.ts.map +0 -1
- package/dist/sharedObjectSequence.js +0 -61
- package/dist/sharedObjectSequence.js.map +0 -1
- package/dist/sharedSequence.js.map +0 -1
- package/dist/sharedString.js +0 -187
- package/dist/sharedString.js.map +0 -1
- package/dist/sparsematrix.d.ts +0 -139
- package/dist/sparsematrix.d.ts.map +0 -1
- package/dist/sparsematrix.js +0 -332
- package/dist/sparsematrix.js.map +0 -1
- package/lib/defaultMap.d.ts.map +0 -1
- package/lib/defaultMap.js.map +0 -1
- package/lib/defaultMapInterfaces.d.ts.map +0 -1
- package/lib/defaultMapInterfaces.js.map +0 -1
- package/lib/index.d.ts +0 -27
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +0 -1
- package/lib/intervalCollection.d.ts +0 -270
- package/lib/intervalCollection.d.ts.map +0 -1
- package/lib/intervalCollection.js +0 -1238
- package/lib/intervalCollection.js.map +0 -1
- package/lib/localValues.d.ts.map +0 -1
- package/lib/localValues.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/sequence.d.ts.map +0 -1
- package/lib/sequence.js.map +0 -1
- package/lib/sequenceDeltaEvent.d.ts.map +0 -1
- package/lib/sequenceDeltaEvent.js.map +0 -1
- package/lib/sequenceFactory.d.ts +0 -108
- package/lib/sequenceFactory.d.ts.map +0 -1
- package/lib/sequenceFactory.js +0 -186
- package/lib/sequenceFactory.js.map +0 -1
- package/lib/sharedIntervalCollection.d.ts.map +0 -1
- package/lib/sharedIntervalCollection.js.map +0 -1
- package/lib/sharedNumberSequence.d.ts +0 -50
- package/lib/sharedNumberSequence.d.ts.map +0 -1
- package/lib/sharedNumberSequence.js +0 -57
- package/lib/sharedNumberSequence.js.map +0 -1
- package/lib/sharedObjectSequence.d.ts +0 -50
- package/lib/sharedObjectSequence.d.ts.map +0 -1
- package/lib/sharedObjectSequence.js +0 -57
- package/lib/sharedObjectSequence.js.map +0 -1
- package/lib/sharedSequence.d.ts.map +0 -1
- package/lib/sharedSequence.js.map +0 -1
- package/lib/sharedString.d.ts.map +0 -1
- package/lib/sharedString.js +0 -183
- package/lib/sharedString.js.map +0 -1
- package/lib/sparsematrix.d.ts +0 -139
- package/lib/sparsematrix.d.ts.map +0 -1
- package/lib/sparsematrix.js +0 -323
- package/lib/sparsematrix.js.map +0 -1
- package/src/sharedNumberSequence.ts +0 -62
- package/src/sharedObjectSequence.ts +0 -62
- package/src/sparsematrix.ts +0 -421
- package/tsconfig.esnext.json +0 -7
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getTextAndMarkers = exports.SharedString = void 0;
|
|
8
|
+
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
9
|
+
const sequence_1 = require("./sequence.cjs");
|
|
10
|
+
const sequenceFactory_1 = require("./sequenceFactory.cjs");
|
|
11
|
+
/**
|
|
12
|
+
* The Shared String is a specialized data structure for handling collaborative
|
|
13
|
+
* text. It is based on a more general Sequence data structure but has
|
|
14
|
+
* additional features that make working with text easier.
|
|
15
|
+
*
|
|
16
|
+
* In addition to text, a Shared String can also contain markers. Markers can be
|
|
17
|
+
* used to store metadata at positions within the text, like the details of an
|
|
18
|
+
* image or Fluid object that should be rendered with the text.
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
21
|
+
class SharedString extends sequence_1.SharedSegmentSequence {
|
|
22
|
+
/**
|
|
23
|
+
* Create a new shared string.
|
|
24
|
+
* @param runtime - data store runtime the new shared string belongs to
|
|
25
|
+
* @param id - optional name of the shared string
|
|
26
|
+
* @returns newly create shared string (but not attached yet)
|
|
27
|
+
*/
|
|
28
|
+
static create(runtime, id) {
|
|
29
|
+
return runtime.createChannel(id, sequenceFactory_1.SharedStringFactory.Type);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get a factory for SharedString to register with the data store.
|
|
33
|
+
* @returns a factory that creates and load SharedString
|
|
34
|
+
*/
|
|
35
|
+
static getFactory() {
|
|
36
|
+
return new sequenceFactory_1.SharedStringFactory();
|
|
37
|
+
}
|
|
38
|
+
get ISharedString() {
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
constructor(document, id, attributes) {
|
|
42
|
+
super(document, id, attributes, sequenceFactory_1.SharedStringFactory.segmentFromSpec);
|
|
43
|
+
this.id = id;
|
|
44
|
+
this.mergeTreeTextHelper = this.client.createTextHelper();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Inserts a marker at a relative position.
|
|
48
|
+
* @param relativePos1 - The relative position to insert the marker at
|
|
49
|
+
* @param refType - The reference type of the marker
|
|
50
|
+
* @param props - The properties of the marker
|
|
51
|
+
*/
|
|
52
|
+
insertMarkerRelative(relativePos1, refType, props) {
|
|
53
|
+
const segment = new merge_tree_1.Marker(refType);
|
|
54
|
+
if (props) {
|
|
55
|
+
segment.addProperties(props);
|
|
56
|
+
}
|
|
57
|
+
const pos = this.posFromRelativePos(relativePos1);
|
|
58
|
+
this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* {@inheritDoc ISharedString.insertMarker}
|
|
62
|
+
*/
|
|
63
|
+
insertMarker(pos, refType, props) {
|
|
64
|
+
const segment = new merge_tree_1.Marker(refType);
|
|
65
|
+
if (props) {
|
|
66
|
+
segment.addProperties(props);
|
|
67
|
+
}
|
|
68
|
+
this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Inserts the text at the position.
|
|
72
|
+
* @param relativePos1 - The relative position to insert the text at
|
|
73
|
+
* @param text - The text to insert
|
|
74
|
+
* @param props - The properties of text
|
|
75
|
+
*/
|
|
76
|
+
insertTextRelative(relativePos1, text, props) {
|
|
77
|
+
const segment = new merge_tree_1.TextSegment(text);
|
|
78
|
+
if (props) {
|
|
79
|
+
segment.addProperties(props);
|
|
80
|
+
}
|
|
81
|
+
const pos = this.posFromRelativePos(relativePos1);
|
|
82
|
+
this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* {@inheritDoc ISharedString.insertText}
|
|
86
|
+
*/
|
|
87
|
+
insertText(pos, text, props) {
|
|
88
|
+
const segment = new merge_tree_1.TextSegment(text);
|
|
89
|
+
if (props) {
|
|
90
|
+
segment.addProperties(props);
|
|
91
|
+
}
|
|
92
|
+
this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Replaces a range with the provided text.
|
|
96
|
+
* @param start - The inclusive start of the range to replace
|
|
97
|
+
* @param end - The exclusive end of the range to replace
|
|
98
|
+
* @param text - The text to replace the range with
|
|
99
|
+
* @param props - Optional. The properties of the replacement text
|
|
100
|
+
*/
|
|
101
|
+
replaceText(start, end, text, props) {
|
|
102
|
+
this.replaceRange(start, end, merge_tree_1.TextSegment.make(text, props));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Removes the text in the given range.
|
|
106
|
+
* @param start - The inclusive start of the range to remove
|
|
107
|
+
* @param end - The exclusive end of the range to replace
|
|
108
|
+
* @returns the message sent.
|
|
109
|
+
*/
|
|
110
|
+
removeText(start, end) {
|
|
111
|
+
this.removeRange(start, end);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Annotates the marker with the provided properties.
|
|
115
|
+
* @param marker - The marker to annotate
|
|
116
|
+
* @param props - The properties to annotate the marker with
|
|
117
|
+
*/
|
|
118
|
+
annotateMarker(marker, props) {
|
|
119
|
+
this.guardReentrancy(() => this.client.annotateMarker(marker, props));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
|
|
123
|
+
* Note that Markers receive `ReferenceType.Tile` by default.
|
|
124
|
+
* @deprecated Use `searchForMarker` instead.
|
|
125
|
+
* @param startPos - Position at which to start the search
|
|
126
|
+
* @param clientId - clientId dictating the perspective to search from
|
|
127
|
+
* @param tileLabel - Label of the tile to search for
|
|
128
|
+
* @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
|
|
129
|
+
*/
|
|
130
|
+
findTile(startPos, tileLabel, preceding = true) {
|
|
131
|
+
return this.client.findTile(startPos ?? 0, tileLabel, preceding);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Searches a string for the nearest marker in either direction to a given start position.
|
|
135
|
+
* The search will include the start position, so markers at the start position are valid
|
|
136
|
+
* results of the search.
|
|
137
|
+
* @param startPos - Position at which to start the search
|
|
138
|
+
* @param markerLabel - Label of the marker to search for
|
|
139
|
+
* @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
|
|
140
|
+
*/
|
|
141
|
+
searchForMarker(startPos, markerLabel, forwards = true) {
|
|
142
|
+
return this.client.searchForMarker(startPos, markerLabel, forwards);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Retrieve text from the SharedString in string format.
|
|
146
|
+
* @param start - The starting index of the text to retrieve, or 0 if omitted.
|
|
147
|
+
* @param end - The ending index of the text to retrieve, or the end of the string if omitted
|
|
148
|
+
* @returns The requested text content as a string.
|
|
149
|
+
*/
|
|
150
|
+
getText(start, end) {
|
|
151
|
+
const segmentWindow = this.client.getCollabWindow();
|
|
152
|
+
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "", start, end);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
156
|
+
*/
|
|
157
|
+
getTextWithPlaceholders(start, end) {
|
|
158
|
+
const segmentWindow = this.client.getCollabWindow();
|
|
159
|
+
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
|
|
160
|
+
}
|
|
161
|
+
getTextRangeWithMarkers(start, end) {
|
|
162
|
+
const segmentWindow = this.client.getCollabWindow();
|
|
163
|
+
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "*", start, end);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
|
|
167
|
+
* id in this `SharedString`.
|
|
168
|
+
*/
|
|
169
|
+
getMarkerFromId(id) {
|
|
170
|
+
return this.client.getMarkerFromId(id);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Revert an op
|
|
174
|
+
*/
|
|
175
|
+
rollback(content, localOpMetadata) {
|
|
176
|
+
if (this.client.rollback !== undefined) {
|
|
177
|
+
this.client.rollback(content, localOpMetadata);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
super.rollback(content, localOpMetadata);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.SharedString = SharedString;
|
|
185
|
+
/**
|
|
186
|
+
* Splits the text into regions ending with markers with the given `label`.
|
|
187
|
+
* @param sharedString - String to retrieve text and markers from
|
|
188
|
+
* @param label - label to split on
|
|
189
|
+
* @returns Two parallel lists of text and markers, split by markers with the provided `label`.
|
|
190
|
+
* For example:
|
|
191
|
+
* ```typescript
|
|
192
|
+
* // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
|
|
193
|
+
* const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
|
|
194
|
+
* // parallelText === ["hello", "world"]
|
|
195
|
+
* // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
|
|
196
|
+
* // Note parallelText does not include "missing".
|
|
197
|
+
* ```
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
function getTextAndMarkers(sharedString, label, start, end) {
|
|
201
|
+
const accum = {
|
|
202
|
+
parallelMarkerLabel: label,
|
|
203
|
+
parallelMarkers: [],
|
|
204
|
+
parallelText: [],
|
|
205
|
+
tagsInProgress: [],
|
|
206
|
+
textSegment: new merge_tree_1.TextSegment(""),
|
|
207
|
+
};
|
|
208
|
+
sharedString.walkSegments(gatherTextAndMarkers, start, end, accum);
|
|
209
|
+
return { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };
|
|
210
|
+
}
|
|
211
|
+
exports.getTextAndMarkers = getTextAndMarkers;
|
|
212
|
+
const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumText) => {
|
|
213
|
+
const { placeholder, tagsInProgress, textSegment } = accumText;
|
|
214
|
+
if (merge_tree_1.TextSegment.is(segment)) {
|
|
215
|
+
let beginTags = "";
|
|
216
|
+
let endTags = "";
|
|
217
|
+
// TODO: let clients pass in function to get tag
|
|
218
|
+
const tags = [];
|
|
219
|
+
const initTags = [];
|
|
220
|
+
if (segment.properties?.["font-weight"]) {
|
|
221
|
+
tags.push("b");
|
|
222
|
+
}
|
|
223
|
+
if (segment.properties?.["text-decoration"]) {
|
|
224
|
+
tags.push("u");
|
|
225
|
+
}
|
|
226
|
+
const remTags = [];
|
|
227
|
+
if (tags.length > 0) {
|
|
228
|
+
for (const tag of tags) {
|
|
229
|
+
if (!tagsInProgress.includes(tag)) {
|
|
230
|
+
beginTags += `<${tag}>`;
|
|
231
|
+
initTags.push(tag);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (const accumTag of tagsInProgress) {
|
|
235
|
+
if (!tags.includes(accumTag)) {
|
|
236
|
+
endTags += `</${accumTag}>`;
|
|
237
|
+
remTags.push(accumTag);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
for (const initTag of initTags.reverse()) {
|
|
241
|
+
tagsInProgress.push(initTag);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
for (const accumTag of tagsInProgress) {
|
|
246
|
+
endTags += `</${accumTag}>`;
|
|
247
|
+
remTags.push(accumTag);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
for (const remTag of remTags) {
|
|
251
|
+
const remdex = tagsInProgress.indexOf(remTag);
|
|
252
|
+
if (remdex >= 0) {
|
|
253
|
+
tagsInProgress.splice(remdex, 1);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
textSegment.text += endTags;
|
|
257
|
+
textSegment.text += beginTags;
|
|
258
|
+
if (start <= 0 && end >= segment.text.length) {
|
|
259
|
+
textSegment.text += segment.text;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const seglen = segment.text.length;
|
|
263
|
+
const _start = start < 0 ? 0 : start;
|
|
264
|
+
const _end = end >= seglen ? undefined : end;
|
|
265
|
+
textSegment.text += segment.text.substring(_start, _end);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
if (placeholder && placeholder.length > 0) {
|
|
270
|
+
const placeholderText =
|
|
271
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
272
|
+
placeholder === "*" ? `\n${segment}` : placeholder.repeat(segment.cachedLength);
|
|
273
|
+
textSegment.text += placeholderText;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
const marker = segment;
|
|
277
|
+
if ((0, merge_tree_1.refHasTileLabel)(marker, accumText.parallelMarkerLabel)) {
|
|
278
|
+
accumText.parallelMarkers.push(marker);
|
|
279
|
+
accumText.parallelText.push(textSegment.text);
|
|
280
|
+
textSegment.text = "";
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=sharedString.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedString.cjs","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAWoC;AAEpC,6CAAmD;AACnD,2DAAwD;AAkCxD;;;;;;;;;GASG;AACH,MAAa,YACZ,SAAQ,gCAA0C;IAGlD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,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;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n * @alpha\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\n/**\n * @alpha\n */\nexport type SharedStringSegment = TextSegment | Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n * @alpha\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): void {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(\n\t\trelativePos1: IRelativePosition,\n\t\ttext: string,\n\t\tprops?: PropertySet,\n\t): void {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet): void {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet): void {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): void {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props));\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @deprecated Use `searchForMarker` instead.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Searches a string for the nearest marker in either direction to a given start position.\n\t * The search will include the start position, so markers at the start position are valid\n\t * results of the search.\n\t * @param startPos - Position at which to start the search\n\t * @param markerLabel - Label of the marker to search for\n\t * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`\n\t */\n\tpublic searchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): Marker | undefined {\n\t\treturn this.client.searchForMarker(startPos, markerLabel, forwards);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n * @internal\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\tplaceholder === \"*\" ? `\\n${segment}` : placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
|
package/dist/sharedString.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { IRelativePosition, ISegment, Marker, PropertySet, ReferencePosition, ReferenceType, TextSegment } from "@fluidframework/merge-tree";
|
|
6
6
|
import { IFluidDataStoreRuntime, IChannelAttributes } from "@fluidframework/datastore-definitions";
|
|
7
7
|
import { SharedSegmentSequence } from "./sequence";
|
|
8
8
|
import { SharedStringFactory } from "./sequenceFactory";
|
|
9
9
|
/**
|
|
10
10
|
* Fluid object interface describing access methods on a SharedString
|
|
11
|
+
* @alpha
|
|
11
12
|
*/
|
|
12
13
|
export interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
|
|
13
14
|
/**
|
|
@@ -23,13 +24,16 @@ export interface ISharedString extends SharedSegmentSequence<SharedStringSegment
|
|
|
23
24
|
* @param refType - The reference type of the marker
|
|
24
25
|
* @param props - The properties of the marker
|
|
25
26
|
*/
|
|
26
|
-
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet):
|
|
27
|
+
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
|
|
27
28
|
/**
|
|
28
29
|
* {@inheritDoc SharedSegmentSequence.posFromRelativePos}
|
|
29
30
|
*/
|
|
30
31
|
posFromRelativePos(relativePos: IRelativePosition): number;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export type SharedStringSegment = TextSegment | Marker;
|
|
33
37
|
/**
|
|
34
38
|
* The Shared String is a specialized data structure for handling collaborative
|
|
35
39
|
* text. It is based on a more general Sequence data structure but has
|
|
@@ -38,7 +42,7 @@ export declare type SharedStringSegment = TextSegment | Marker;
|
|
|
38
42
|
* In addition to text, a Shared String can also contain markers. Markers can be
|
|
39
43
|
* used to store metadata at positions within the text, like the details of an
|
|
40
44
|
* image or Fluid object that should be rendered with the text.
|
|
41
|
-
*
|
|
45
|
+
* @alpha
|
|
42
46
|
*/
|
|
43
47
|
export declare class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
|
|
44
48
|
id: string;
|
|
@@ -67,7 +71,7 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
67
71
|
/**
|
|
68
72
|
* {@inheritDoc ISharedString.insertMarker}
|
|
69
73
|
*/
|
|
70
|
-
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet):
|
|
74
|
+
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
|
|
71
75
|
/**
|
|
72
76
|
* Inserts the text at the position.
|
|
73
77
|
* @param relativePos1 - The relative position to insert the text at
|
|
@@ -93,29 +97,35 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
93
97
|
* @param end - The exclusive end of the range to replace
|
|
94
98
|
* @returns the message sent.
|
|
95
99
|
*/
|
|
96
|
-
removeText(start: number, end: number):
|
|
100
|
+
removeText(start: number, end: number): void;
|
|
97
101
|
/**
|
|
98
|
-
* Annotates the marker with the provided properties
|
|
102
|
+
* Annotates the marker with the provided properties.
|
|
99
103
|
* @param marker - The marker to annotate
|
|
100
104
|
* @param props - The properties to annotate the marker with
|
|
101
|
-
* @param consensusCallback - The callback called when consensus is reached
|
|
102
105
|
*/
|
|
103
|
-
|
|
106
|
+
annotateMarker(marker: Marker, props: PropertySet): void;
|
|
104
107
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @
|
|
108
|
-
* @param
|
|
108
|
+
* Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
|
|
109
|
+
* Note that Markers receive `ReferenceType.Tile` by default.
|
|
110
|
+
* @deprecated Use `searchForMarker` instead.
|
|
111
|
+
* @param startPos - Position at which to start the search
|
|
112
|
+
* @param clientId - clientId dictating the perspective to search from
|
|
113
|
+
* @param tileLabel - Label of the tile to search for
|
|
114
|
+
* @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
|
|
109
115
|
*/
|
|
110
|
-
annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): void;
|
|
111
116
|
findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
|
|
112
117
|
tile: ReferencePosition;
|
|
113
118
|
pos: number;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
} | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Searches a string for the nearest marker in either direction to a given start position.
|
|
122
|
+
* The search will include the start position, so markers at the start position are valid
|
|
123
|
+
* results of the search.
|
|
124
|
+
* @param startPos - Position at which to start the search
|
|
125
|
+
* @param markerLabel - Label of the marker to search for
|
|
126
|
+
* @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
|
|
127
|
+
*/
|
|
128
|
+
searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
|
|
119
129
|
/**
|
|
120
130
|
* Retrieve text from the SharedString in string format.
|
|
121
131
|
* @param start - The starting index of the text to retrieve, or 0 if omitted.
|
|
@@ -126,9 +136,35 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
126
136
|
/**
|
|
127
137
|
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
128
138
|
*/
|
|
129
|
-
getTextWithPlaceholders(): string;
|
|
130
|
-
getTextRangeWithPlaceholders(start: number, end: number): string;
|
|
139
|
+
getTextWithPlaceholders(start?: number, end?: number): string;
|
|
131
140
|
getTextRangeWithMarkers(start: number, end: number): string;
|
|
132
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
|
|
143
|
+
* id in this `SharedString`.
|
|
144
|
+
*/
|
|
145
|
+
getMarkerFromId(id: string): ISegment | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Revert an op
|
|
148
|
+
*/
|
|
149
|
+
protected rollback(content: any, localOpMetadata: unknown): void;
|
|
133
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Splits the text into regions ending with markers with the given `label`.
|
|
153
|
+
* @param sharedString - String to retrieve text and markers from
|
|
154
|
+
* @param label - label to split on
|
|
155
|
+
* @returns Two parallel lists of text and markers, split by markers with the provided `label`.
|
|
156
|
+
* For example:
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
|
|
159
|
+
* const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
|
|
160
|
+
* // parallelText === ["hello", "world"]
|
|
161
|
+
* // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
|
|
162
|
+
* // Note parallelText does not include "missing".
|
|
163
|
+
* ```
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
export declare function getTextAndMarkers(sharedString: SharedString, label: string, start?: number, end?: number): {
|
|
167
|
+
parallelText: string[];
|
|
168
|
+
parallelMarkers: Marker[];
|
|
169
|
+
};
|
|
134
170
|
//# sourceMappingURL=sharedString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src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,EAAE,GAAG,CAAC,EAAE,MAAM;IAW3C;;OAEG;IACI,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAWpD,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAWzD;;;OAGG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIxD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAOhE;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,GACV;IACF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAWA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.38.3"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
8
|
-
import { TypedEventEmitter } from "@
|
|
9
|
-
import { ISerializableValue, ISerializedValue, IValueType, IValueTypeOperationValue, ISharedDefaultMapEvents, IMapMessageLocalMetadata } from "./defaultMapInterfaces";
|
|
8
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
9
|
+
import { ISerializableValue, ISerializedValue, IValueType, IValueTypeOperationValue, ISharedDefaultMapEvents, IMapMessageLocalMetadata, SequenceOptions } from "./defaultMapInterfaces.mjs";
|
|
10
10
|
/**
|
|
11
11
|
* Describes an operation specific to a value type.
|
|
12
12
|
*/
|
|
@@ -28,7 +28,7 @@ export interface IMapValueTypeOperation {
|
|
|
28
28
|
/**
|
|
29
29
|
* Description of a map delta operation
|
|
30
30
|
*/
|
|
31
|
-
export
|
|
31
|
+
export type IMapOperation = IMapValueTypeOperation;
|
|
32
32
|
/**
|
|
33
33
|
* Defines the in-memory object structure to be used for the conversion to/from serialized.
|
|
34
34
|
* Directly used in JSON.stringify, direct result from JSON.parse
|
|
@@ -51,6 +51,7 @@ export declare class DefaultMap<T> {
|
|
|
51
51
|
private readonly handle;
|
|
52
52
|
private readonly submitMessage;
|
|
53
53
|
private readonly type;
|
|
54
|
+
private readonly options?;
|
|
54
55
|
readonly eventEmitter: TypedEventEmitter<ISharedDefaultMapEvents>;
|
|
55
56
|
/**
|
|
56
57
|
* The number of key/value pairs stored in the map.
|
|
@@ -72,7 +73,7 @@ export declare class DefaultMap<T> {
|
|
|
72
73
|
* @param type - The value type to create at values of this map
|
|
73
74
|
* @param eventEmitter - The object that will emit map events
|
|
74
75
|
*/
|
|
75
|
-
constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op:
|
|
76
|
+
constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => void, type: IValueType<T>, options?: Partial<SequenceOptions> | undefined, eventEmitter?: TypedEventEmitter<ISharedDefaultMapEvents>);
|
|
76
77
|
/**
|
|
77
78
|
* Get an iterator over the keys in this map.
|
|
78
79
|
* @returns The iterator
|
|
@@ -130,8 +131,8 @@ export declare class DefaultMap<T> {
|
|
|
130
131
|
* also sent if we are asked to resubmit the message.
|
|
131
132
|
* @returns True if the operation was submitted, false otherwise.
|
|
132
133
|
*/
|
|
133
|
-
tryResubmitMessage(op:
|
|
134
|
-
tryGetStashedOpLocalMetadata(op:
|
|
134
|
+
tryResubmitMessage(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): boolean;
|
|
135
|
+
tryGetStashedOpLocalMetadata(op: IMapOperation): unknown;
|
|
135
136
|
/**
|
|
136
137
|
* Process the given op if a handler is registered.
|
|
137
138
|
* @param message - The message to process
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultMap.d.ts","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,YAAY,EAAE,MAAM,iCAAiC;OACvD,EAAE,yBAAyB,EAAE,MAAM,sCAAsC;OACzE,EACN,gBAAgB,EAIhB,MAAM,oCAAoC;OACpC,EAAE,iBAAiB,EAAE,MAAM,8BAA8B;OAGzD,EACN,kBAAkB,EAClB,gBAAgB,EAIhB,UAAU,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf;AAiCD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,KAAK,EAAE,wBAAwB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAChC;AAED;;;;;;GAMG;AACH,qBAAa,UAAU,CAAC,CAAC;IA2BvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OA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