@fluidframework/tree 2.114.0 → 2.115.0
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/CHANGELOG.md +191 -0
- package/api-report/tree.alpha.api.md +108 -39
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +110 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +47 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/entrypoints/alpha.d.ts +1 -1
- package/dist/entrypoints/alpha.d.ts.map +1 -1
- package/dist/entrypoints/alpha.js +6 -4
- package/dist/entrypoints/alpha.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +16 -13
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +5 -0
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +5 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +58 -12
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +1 -0
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -3
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +6 -7
- package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaStatics.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +20 -24
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +48 -49
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +5 -6
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNode.js +2 -4
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +20 -7
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js +4 -7
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -4
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +6 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +0 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +32 -3
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +91 -10
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +77 -0
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +17 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/text/codePointUtils.d.ts +2 -2
- package/dist/text/codePointUtils.js +2 -2
- package/dist/text/codePointUtils.js.map +1 -1
- package/dist/text/index.d.ts +3 -3
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +4 -4
- package/dist/text/index.js.map +1 -1
- package/dist/text/textDomain.d.ts +18 -18
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +8 -8
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +46 -42
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +32 -28
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/text/textDomainFormattedDefault.d.ts +18 -18
- package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
- package/dist/text/textDomainFormattedDefault.js +14 -17
- package/dist/text/textDomainFormattedDefault.js.map +1 -1
- package/dist/util/compressedIds.d.ts +22 -2
- package/dist/util/compressedIds.d.ts.map +1 -1
- package/dist/util/compressedIds.js +22 -1
- package/dist/util/compressedIds.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +110 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +46 -0
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/entrypoints/alpha.d.ts +1 -1
- package/lib/entrypoints/alpha.d.ts.map +1 -1
- package/lib/entrypoints/alpha.js +1 -1
- package/lib/entrypoints/alpha.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +16 -13
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +5 -0
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +5 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +60 -14
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +1 -0
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +6 -7
- package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaStatics.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +20 -24
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +46 -46
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts +5 -6
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNode.js +2 -4
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +20 -7
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js +4 -7
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +6 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +0 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +32 -3
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +93 -12
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +77 -0
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +18 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/text/codePointUtils.d.ts +2 -2
- package/lib/text/codePointUtils.js +2 -2
- package/lib/text/codePointUtils.js.map +1 -1
- package/lib/text/index.d.ts +3 -3
- package/lib/text/index.d.ts.map +1 -1
- package/lib/text/index.js +3 -3
- package/lib/text/index.js.map +1 -1
- package/lib/text/textDomain.d.ts +18 -18
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +7 -7
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +46 -42
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +31 -27
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/text/textDomainFormattedDefault.d.ts +18 -18
- package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
- package/lib/text/textDomainFormattedDefault.js +14 -17
- package/lib/text/textDomainFormattedDefault.js.map +1 -1
- package/lib/util/compressedIds.d.ts +22 -2
- package/lib/util/compressedIds.d.ts.map +1 -1
- package/lib/util/compressedIds.js +22 -1
- package/lib/util/compressedIds.js.map +1 -1
- package/package.json +29 -22
- package/src/core/index.ts +2 -0
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +113 -0
- package/src/entrypoints/alpha.ts +10 -6
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -14
- package/src/index.ts +7 -4
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/sharedTree.ts +6 -1
- package/src/shared-tree/treeCheckout.ts +81 -14
- package/src/shared-tree-core/branch.ts +1 -0
- package/src/shared-tree-core/sharedTreeCore.ts +1 -1
- package/src/simple-tree/api/index.ts +0 -1
- package/src/simple-tree/api/schemaStatics.ts +2 -2
- package/src/simple-tree/api/treeNodeApi.ts +64 -48
- package/src/simple-tree/core/treeNode.ts +13 -10
- package/src/simple-tree/core/withType.ts +20 -7
- package/src/simple-tree/index.ts +1 -2
- package/src/simple-tree/leafNodeSchema.ts +6 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +109 -14
- package/src/simple-tree/node-kinds/map/mapNode.ts +113 -3
- package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
- package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
- package/src/text/README.md +1 -1
- package/src/text/codePointUtils.ts +2 -2
- package/src/text/index.ts +3 -3
- package/src/text/textDomain.ts +21 -21
- package/src/text/textDomainFormatted.ts +56 -52
- package/src/text/textDomainFormattedDefault.ts +14 -23
- package/src/util/compressedIds.ts +36 -3
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
charactersFromString,
|
|
55
55
|
expensiveInternalValidationAssert,
|
|
56
56
|
processCharactersChangedDelta,
|
|
57
|
-
type
|
|
57
|
+
type PlainText,
|
|
58
58
|
} from "./textDomain.js";
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -95,7 +95,7 @@ export class StringTextAtomNode
|
|
|
95
95
|
*/
|
|
96
96
|
content: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),
|
|
97
97
|
})
|
|
98
|
-
implements
|
|
98
|
+
implements FormattedText.TextAtom
|
|
99
99
|
{
|
|
100
100
|
public static fromCharacter(value: string): StringTextAtomNode {
|
|
101
101
|
const character = oneFromIterable(charactersFromString(value));
|
|
@@ -115,16 +115,19 @@ export class StringTextAtomNode
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
|
|
118
|
+
*
|
|
118
119
|
* @remarks
|
|
119
120
|
* This is generic over formatting an embedded object/atom types.
|
|
120
|
-
*
|
|
121
|
+
*
|
|
121
122
|
* @privateRemarks
|
|
123
|
+
* See {@link FormattedTextDefault} for an example parameterization.
|
|
124
|
+
*
|
|
122
125
|
* TODO:
|
|
123
126
|
* - Add more comprehensive tests for generic parameterizations other than default.
|
|
124
127
|
* - Sort out API around overwriting subsets of formatting information.
|
|
125
|
-
* @
|
|
128
|
+
* @alpha
|
|
126
129
|
*/
|
|
127
|
-
export namespace
|
|
130
|
+
export namespace FormattedText {
|
|
128
131
|
/**
|
|
129
132
|
* Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.
|
|
130
133
|
*
|
|
@@ -133,16 +136,17 @@ export namespace FormattedTextAsTree {
|
|
|
133
136
|
* This scope is used to distinguish different usages of `createSchema` from each-other, and must be kept the same between versions for nodes to remain compatible.
|
|
134
137
|
* It must be different to distinguish different formatted text schema within the same document.
|
|
135
138
|
* @param formatSchema - Schema describing the formatting associated with each atom of text.
|
|
136
|
-
* Use an {@link NodeKind.Object|Object node} to support {@link
|
|
137
|
-
* @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link
|
|
139
|
+
* Use an {@link NodeKind.Object|Object node} to support {@link FormattedText.Members.formatRange}.
|
|
140
|
+
* @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedText.(StringTextAtom:variable)}.
|
|
138
141
|
* Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.
|
|
139
142
|
* @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs
|
|
140
|
-
* (for example {@link
|
|
141
|
-
* @returns The schema for the formatted text node, whose nodes implement {@link
|
|
142
|
-
*
|
|
143
|
-
* See {@link FormattedTextAsTreeDefault} for a default parameterization of this factory.
|
|
143
|
+
* (for example {@link FormattedText.Members.insertAt} and {@link FormattedText.Statics.fromString} when no explicit format is provided).
|
|
144
|
+
* @returns The schema for the formatted text node, whose nodes implement {@link FormattedText.Members} and whose statics implement {@link FormattedText.Statics}.
|
|
145
|
+
*
|
|
144
146
|
* @privateRemarks
|
|
145
|
-
*
|
|
147
|
+
* See {@link FormattedTextDefault} for an example parameterization of this factory.
|
|
148
|
+
*
|
|
149
|
+
* TODO: The choice to always include the built-in {@link FormattedText.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
|
|
146
150
|
*/
|
|
147
151
|
export function createSchema<
|
|
148
152
|
const TUserScope extends string,
|
|
@@ -302,7 +306,7 @@ export namespace FormattedTextAsTree {
|
|
|
302
306
|
);
|
|
303
307
|
return [key, value] as const;
|
|
304
308
|
});
|
|
305
|
-
this.#editRange(start, end, "
|
|
309
|
+
this.#editRange(start, end, "FormattedText.formatRange", (atom) => {
|
|
306
310
|
const formatNode: TreeNode | TreeValue = atom.format;
|
|
307
311
|
const atomFormatSchema = TreeStatic.schema(formatNode);
|
|
308
312
|
if (!isObjectNodeSchema(atomFormatSchema)) {
|
|
@@ -338,7 +342,7 @@ export namespace FormattedTextAsTree {
|
|
|
338
342
|
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
339
343
|
): void {
|
|
340
344
|
const node = getFormatNode(format);
|
|
341
|
-
this.#editRange(start, end, "
|
|
345
|
+
this.#editRange(start, end, "FormattedText.reformat", (atom) => {
|
|
342
346
|
atom.format = cloneFormat(node);
|
|
343
347
|
});
|
|
344
348
|
}
|
|
@@ -375,7 +379,7 @@ export namespace FormattedTextAsTree {
|
|
|
375
379
|
}
|
|
376
380
|
|
|
377
381
|
/**
|
|
378
|
-
* Returns the {@link
|
|
382
|
+
* Returns the {@link FormattedText.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
|
|
379
383
|
*/
|
|
380
384
|
private getAtomCharacterAt(index: number): string | undefined {
|
|
381
385
|
const atom = this.content[index];
|
|
@@ -384,7 +388,7 @@ export namespace FormattedTextAsTree {
|
|
|
384
388
|
}
|
|
385
389
|
|
|
386
390
|
public onCharactersChanged(
|
|
387
|
-
callback: (ops: readonly
|
|
391
|
+
callback: (ops: readonly PlainText.TextOp[] | undefined) => void,
|
|
388
392
|
): () => void {
|
|
389
393
|
return TreeAlpha.on(this.content, "nodeChanged", ({ delta }) =>
|
|
390
394
|
processCharactersChangedDelta(
|
|
@@ -396,7 +400,7 @@ export namespace FormattedTextAsTree {
|
|
|
396
400
|
}
|
|
397
401
|
|
|
398
402
|
public onContentChanged(
|
|
399
|
-
callback: (ops: readonly
|
|
403
|
+
callback: (ops: readonly PlainText.TextOp[] | undefined) => void,
|
|
400
404
|
): () => void {
|
|
401
405
|
return TreeAlpha.on(this.content, "treeChanged", ({ delta }) =>
|
|
402
406
|
processCharactersChangedDelta(
|
|
@@ -487,7 +491,7 @@ export namespace FormattedTextAsTree {
|
|
|
487
491
|
// TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.
|
|
488
492
|
// A less general optimization could just include cases for build in types with constant values
|
|
489
493
|
// (like below commented code: currently this would cause a cyclical dependency but could be refactored).
|
|
490
|
-
// case
|
|
494
|
+
// case FormattedText.StringLineAtom.identifier: {
|
|
491
495
|
// content = "\n";
|
|
492
496
|
// break;
|
|
493
497
|
// }
|
|
@@ -524,12 +528,12 @@ export namespace FormattedTextAsTree {
|
|
|
524
528
|
}
|
|
525
529
|
|
|
526
530
|
public getString(startIndex: number, endIndex: number = this.length): string {
|
|
527
|
-
validateIndexRange(startIndex, endIndex, this, "
|
|
531
|
+
validateIndexRange(startIndex, endIndex, this, "FormattedText.getString");
|
|
528
532
|
return this.getCharactersSubarray(startIndex, endIndex).join("");
|
|
529
533
|
}
|
|
530
534
|
|
|
531
535
|
public getUniformRun(startIndex: number, endIndex: number = this.length): number {
|
|
532
|
-
validateIndexRange(startIndex, endIndex, this, "
|
|
536
|
+
validateIndexRange(startIndex, endIndex, this, "FormattedText.getUniformRun");
|
|
533
537
|
if (endIndex === startIndex) {
|
|
534
538
|
throw new UsageError("endIndex must be greater than startIndex for getUniformRun.");
|
|
535
539
|
}
|
|
@@ -602,8 +606,8 @@ export namespace FormattedTextAsTree {
|
|
|
602
606
|
/**
|
|
603
607
|
* Schema for a text node.
|
|
604
608
|
* @remarks
|
|
605
|
-
* See {@link
|
|
606
|
-
* See {@link
|
|
609
|
+
* See {@link FormattedText.Members} for the API.
|
|
610
|
+
* See {@link FormattedText.Statics} for static APIs on this Schema, including construction.
|
|
607
611
|
* @privateRemarks
|
|
608
612
|
* eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.
|
|
609
613
|
* Ideally we would generate private members for non-public properties, but TypeScript does not support this.
|
|
@@ -629,7 +633,7 @@ export namespace FormattedTextAsTree {
|
|
|
629
633
|
* This is implemented {@link StringAtom}, but we avoid leaking the fact this is a TreeNode in the API surface to
|
|
630
634
|
* preserve more future flexibility.
|
|
631
635
|
* @sealed
|
|
632
|
-
* @
|
|
636
|
+
* @alpha
|
|
633
637
|
*/
|
|
634
638
|
export interface FormattedAtom<TFormat, TText> {
|
|
635
639
|
/**
|
|
@@ -648,8 +652,8 @@ export namespace FormattedTextAsTree {
|
|
|
648
652
|
* Portion of a string.
|
|
649
653
|
* @remarks
|
|
650
654
|
* Additional kinds of text atoms (also known as embedded objects) which can occur inside a string can implement this.
|
|
651
|
-
* The schema for them can then be provided to {@link
|
|
652
|
-
* @
|
|
655
|
+
* The schema for them can then be provided to {@link FormattedText.createSchema}.
|
|
656
|
+
* @alpha
|
|
653
657
|
*/
|
|
654
658
|
export interface TextAtom {
|
|
655
659
|
/**
|
|
@@ -659,14 +663,14 @@ export namespace FormattedTextAsTree {
|
|
|
659
663
|
}
|
|
660
664
|
|
|
661
665
|
/**
|
|
662
|
-
* Static factory functions for {@link
|
|
666
|
+
* Static factory functions for {@link FormattedText.(StringTextAtom:variable)}.
|
|
663
667
|
* @privateRemarks
|
|
664
668
|
* We type-erase `StringTextAtom` and only provide these static factories for construction
|
|
665
669
|
* to reduce the chance of someone accidentally creating a text atom for a string other than a single unicode code point.
|
|
666
670
|
* Other strings should work, but our intention is to provide no type-safe API which can produce them, so an application can take their lack of existence as an invariant if they want.
|
|
667
671
|
* It is still however possible to produce them, like export/import round trips with editing in the middle of the process, or collaboration with an equivalent schema which doesn't enforce this invariant.
|
|
668
672
|
* @sealed
|
|
669
|
-
* @
|
|
673
|
+
* @alpha
|
|
670
674
|
*/
|
|
671
675
|
export interface StringTextAtomStatics {
|
|
672
676
|
/**
|
|
@@ -682,18 +686,18 @@ export namespace FormattedTextAsTree {
|
|
|
682
686
|
}
|
|
683
687
|
|
|
684
688
|
/**
|
|
685
|
-
* Schema for a {@link
|
|
689
|
+
* Schema for a {@link FormattedText.(StringTextAtom:variable)} node.
|
|
686
690
|
* @sealed
|
|
687
|
-
* @
|
|
691
|
+
* @alpha
|
|
688
692
|
*/
|
|
689
693
|
export const StringTextAtom = eraseSchemaDetails<TextAtom, StringTextAtomStatics>()(
|
|
690
694
|
StringTextAtomNode,
|
|
691
695
|
);
|
|
692
696
|
|
|
693
697
|
/**
|
|
694
|
-
* Node for the {@link
|
|
698
|
+
* Node for the {@link FormattedText.(StringTextAtom:variable)} schema.
|
|
695
699
|
* @sealed
|
|
696
|
-
* @
|
|
700
|
+
* @alpha
|
|
697
701
|
*/
|
|
698
702
|
export type StringTextAtom = ErasedNode<
|
|
699
703
|
TextAtom,
|
|
@@ -703,7 +707,7 @@ export namespace FormattedTextAsTree {
|
|
|
703
707
|
/**
|
|
704
708
|
* Statics for formatted text nodes.
|
|
705
709
|
* @sealed
|
|
706
|
-
* @
|
|
710
|
+
* @alpha
|
|
707
711
|
*/
|
|
708
712
|
export interface Statics<TTree, FormatSchema extends ImplicitAllowedTypes> {
|
|
709
713
|
/**
|
|
@@ -729,23 +733,23 @@ export namespace FormattedTextAsTree {
|
|
|
729
733
|
* (which often operates on something in between unicode code points and grapheme clusters)
|
|
730
734
|
* and navigation/selection (which typically uses grapheme clusters).
|
|
731
735
|
*
|
|
732
|
-
* @see {@link
|
|
733
|
-
* @see {@link
|
|
736
|
+
* @see {@link FormattedText.Statics.fromString} for construction.
|
|
737
|
+
* @see {@link FormattedText.createSchema} for creating schemas whose nodes implement this.
|
|
734
738
|
* @sealed
|
|
735
|
-
* @
|
|
739
|
+
* @alpha
|
|
736
740
|
*/
|
|
737
741
|
export interface Members<
|
|
738
742
|
FormatSchema extends ImplicitAllowedTypes,
|
|
739
743
|
ExtraAtomsSchema extends readonly LazyItem<
|
|
740
744
|
TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>
|
|
741
745
|
>[],
|
|
742
|
-
> extends
|
|
746
|
+
> extends PlainText.Members {
|
|
743
747
|
/**
|
|
744
|
-
* {@link
|
|
748
|
+
* {@link PlainText.Members.insertAt} with optional formatting to apply to all additional characters,
|
|
745
749
|
* and allowing an array of atoms instead of a string.
|
|
746
|
-
* @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link
|
|
750
|
+
* @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedText.createSchema}) will be used.
|
|
747
751
|
* @remarks
|
|
748
|
-
* Use {@link
|
|
752
|
+
* Use {@link FormattedText.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.
|
|
749
753
|
* @override
|
|
750
754
|
*/
|
|
751
755
|
insertAt(
|
|
@@ -761,7 +765,7 @@ export namespace FormattedTextAsTree {
|
|
|
761
765
|
* @remarks
|
|
762
766
|
* This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.
|
|
763
767
|
*
|
|
764
|
-
* For more efficient access, use {@link
|
|
768
|
+
* For more efficient access, use {@link FormattedText.Members.getUniformRun} and {@link FormattedText.Members.getString} to access ranges of characters
|
|
765
769
|
* to avoid having to inspect the formatting on every atom.
|
|
766
770
|
* @privateRemarks
|
|
767
771
|
* Currently this is implemented by a node and changes with the text over time.
|
|
@@ -777,7 +781,7 @@ export namespace FormattedTextAsTree {
|
|
|
777
781
|
* Insert a range of characters into the string based on character index.
|
|
778
782
|
* @remarks
|
|
779
783
|
* See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.
|
|
780
|
-
* See {@link
|
|
784
|
+
* See {@link FormattedText.Statics.fromString} for how the `additionalCharacters` string is broken into characters.
|
|
781
785
|
* @privateRemarks
|
|
782
786
|
* If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.
|
|
783
787
|
* Doing this currently would enable insertion of text with different character boundaries than the existing text,
|
|
@@ -827,13 +831,13 @@ export namespace FormattedTextAsTree {
|
|
|
827
831
|
* @param endIndex - The ending index (exclusive) of the range to format.
|
|
828
832
|
* @param format - The formatting to replace the formatting of the indicated range with.
|
|
829
833
|
* For each atom, `format` will be cloned and assigned to the atom's format, overwriting any existing formatting.
|
|
830
|
-
* If not specified the `defaultFormat` from {@link
|
|
834
|
+
* If not specified the `defaultFormat` from {@link FormattedText.createSchema} will be used.
|
|
831
835
|
* @remarks
|
|
832
836
|
* The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.
|
|
833
837
|
*
|
|
834
838
|
* This is typically used to normalize formatting, like resetting the formatting of a range to default settings.
|
|
835
839
|
* @privateRemarks
|
|
836
|
-
* See notes on {@link
|
|
840
|
+
* See notes on {@link FormattedText.Members.formatRange} for future optimization opportunities.
|
|
837
841
|
*/
|
|
838
842
|
reformat(
|
|
839
843
|
startIndex?: number | undefined,
|
|
@@ -857,14 +861,14 @@ export namespace FormattedTextAsTree {
|
|
|
857
861
|
/**
|
|
858
862
|
* Subscribe to all content changes on this text node, including both shallow
|
|
859
863
|
* changes (inserts/removes) and deep changes (formatting updates on existing characters).
|
|
860
|
-
* @param callback - Called after each change with a sequence of {@link
|
|
864
|
+
* @param callback - Called after each change with a sequence of {@link PlainText.TextOp}s describing what changed,
|
|
861
865
|
* or `undefined` when a delta could not be computed (e.g. during a schema upgrade).
|
|
862
866
|
* @returns A cleanup function that unsubscribes the callback when called.
|
|
863
867
|
* @remarks
|
|
864
|
-
* Unlike {@link
|
|
868
|
+
* Unlike {@link PlainText.Members.onCharactersChanged} which only fires on
|
|
865
869
|
* shallow changes (inserts and removes), this method also fires on deep changes —
|
|
866
870
|
* formatting property updates on existing characters.
|
|
867
|
-
* The {@link
|
|
871
|
+
* The {@link PlainText.TextRetainOp.formattingChanged} flag on retain ops
|
|
868
872
|
* indicates which character ranges had formatting updates.
|
|
869
873
|
*
|
|
870
874
|
* All counts in the delivered ops are in Unicode code points, not UTF-16 code units.
|
|
@@ -872,14 +876,14 @@ export namespace FormattedTextAsTree {
|
|
|
872
876
|
* corresponds to two UTF-16 code units — convert before using the counts as string indices.
|
|
873
877
|
*/
|
|
874
878
|
onContentChanged(
|
|
875
|
-
callback: (ops: readonly
|
|
879
|
+
callback: (ops: readonly PlainText.TextOp[] | undefined) => void,
|
|
876
880
|
): () => void;
|
|
877
881
|
}
|
|
878
882
|
|
|
879
883
|
/**
|
|
880
|
-
* Insertable shape for a formatted text atom used by {@link
|
|
884
|
+
* Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.
|
|
881
885
|
* @input
|
|
882
|
-
* @
|
|
886
|
+
* @alpha
|
|
883
887
|
*/
|
|
884
888
|
export interface FormattedAtomInsertable<TFormat, TContent> {
|
|
885
889
|
readonly content: TContent;
|
|
@@ -890,7 +894,7 @@ export namespace FormattedTextAsTree {
|
|
|
890
894
|
* Schema identifier for the a generic formatted text schema.
|
|
891
895
|
* @privateRemarks
|
|
892
896
|
* Eventually this should probably be given a better name and/or made a system type in a system namespace.
|
|
893
|
-
* @
|
|
897
|
+
* @alpha
|
|
894
898
|
*/
|
|
895
899
|
export type FormattedTextSchemaIdentifier<TUserScope extends string> = ScopedSchemaName<
|
|
896
900
|
`com.fluidframework.text.formatted<${TUserScope}>`,
|
|
@@ -903,7 +907,7 @@ export namespace FormattedTextAsTree {
|
|
|
903
907
|
* This is just schema for the text atom {@link AllowedTypes},
|
|
904
908
|
* and does not include the actual formatting (which is higher up in the tree).
|
|
905
909
|
* @sealed
|
|
906
|
-
* @
|
|
910
|
+
* @alpha
|
|
907
911
|
*/
|
|
908
912
|
export type TextAtomSchemas<
|
|
909
913
|
ExtraAtomsSchema extends readonly LazyItem<
|
|
@@ -914,7 +918,7 @@ export namespace FormattedTextAsTree {
|
|
|
914
918
|
/**
|
|
915
919
|
* A generic type for a formatted text schema.
|
|
916
920
|
* @sealed
|
|
917
|
-
* @
|
|
921
|
+
* @alpha
|
|
918
922
|
*/
|
|
919
923
|
export type FormattedTextSchema<
|
|
920
924
|
TUserScope extends string,
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
InsertableTreeNodeFromImplicitAllowedTypes,
|
|
10
10
|
} from "../simple-tree/index.js";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { FormattedText } from "./textDomainFormatted.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Schema factory for default formatted text types which are not generic.
|
|
@@ -25,21 +25,18 @@ const defaultFormat = {
|
|
|
25
25
|
} as const;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* A default parameterization of the generic {@link
|
|
28
|
+
* A default parameterization of the generic {@link FormattedText} with hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
|
|
29
29
|
* @remarks
|
|
30
|
-
* It is unlikely this meets the needs of most users, but it can serve as an unstable example of how to use the generic {@link
|
|
30
|
+
* It is unlikely this meets the needs of most users, but it can serve as an unstable example of how to use the generic {@link FormattedText}.
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
export namespace
|
|
33
|
+
export namespace FormattedTextDefault {
|
|
34
34
|
/**
|
|
35
35
|
* Portion of a string with formatting.
|
|
36
36
|
* @sealed
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
|
-
export type FormattedAtom =
|
|
40
|
-
CharacterFormat,
|
|
41
|
-
StringAtomContent
|
|
42
|
-
>;
|
|
39
|
+
export type FormattedAtom = FormattedText.FormattedAtom<CharacterFormat, StringAtomContent>;
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* Formatting options for characters.
|
|
@@ -74,7 +71,7 @@ export namespace FormattedTextAsTreeDefault {
|
|
|
74
71
|
"codeBlock",
|
|
75
72
|
]);
|
|
76
73
|
/**
|
|
77
|
-
* {@inheritdoc
|
|
74
|
+
* {@inheritdoc FormattedTextDefault.(LineTag:variable)}
|
|
78
75
|
* @sealed
|
|
79
76
|
* @internal
|
|
80
77
|
*/
|
|
@@ -104,12 +101,9 @@ export namespace FormattedTextAsTreeDefault {
|
|
|
104
101
|
* @sealed
|
|
105
102
|
* @internal
|
|
106
103
|
*/
|
|
107
|
-
export const StringAtomContent = [
|
|
108
|
-
FormattedTextAsTree.StringTextAtom,
|
|
109
|
-
StringLineAtom,
|
|
110
|
-
] as const;
|
|
104
|
+
export const StringAtomContent = [FormattedText.StringTextAtom, StringLineAtom] as const;
|
|
111
105
|
/**
|
|
112
|
-
* {@inheritdoc
|
|
106
|
+
* {@inheritdoc FormattedTextDefault.(StringAtomContent:variable)}
|
|
113
107
|
* @sealed
|
|
114
108
|
* @internal
|
|
115
109
|
*/
|
|
@@ -120,17 +114,14 @@ export namespace FormattedTextAsTreeDefault {
|
|
|
120
114
|
* @sealed
|
|
121
115
|
* @internal
|
|
122
116
|
*/
|
|
123
|
-
export type Statics<TTree = Tree> =
|
|
124
|
-
TTree,
|
|
125
|
-
typeof CharacterFormat
|
|
126
|
-
>;
|
|
117
|
+
export type Statics<TTree = Tree> = FormattedText.Statics<TTree, typeof CharacterFormat>;
|
|
127
118
|
|
|
128
119
|
/**
|
|
129
|
-
* Insertable shape for a formatted text atom used by {@link
|
|
120
|
+
* Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.
|
|
130
121
|
* @sealed
|
|
131
122
|
* @internal
|
|
132
123
|
*/
|
|
133
|
-
export type FormattedAtomInsertable =
|
|
124
|
+
export type FormattedAtomInsertable = FormattedText.FormattedAtom<
|
|
134
125
|
InsertableTreeNodeFromImplicitAllowedTypes<typeof CharacterFormat>,
|
|
135
126
|
InsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas>
|
|
136
127
|
>;
|
|
@@ -142,15 +133,15 @@ export namespace FormattedTextAsTreeDefault {
|
|
|
142
133
|
* @sealed
|
|
143
134
|
* @internal
|
|
144
135
|
*/
|
|
145
|
-
export type TextAtomSchemas =
|
|
136
|
+
export type TextAtomSchemas = FormattedText.TextAtomSchemas<[typeof StringLineAtom]>;
|
|
146
137
|
|
|
147
138
|
/**
|
|
148
|
-
* The schema produced using {@link
|
|
139
|
+
* The schema produced using {@link FormattedText.createSchema} with hard-coded assumptions
|
|
149
140
|
* about what kind of embedded content and what kind of formatting is supported.
|
|
150
141
|
* @sealed
|
|
151
142
|
* @internal
|
|
152
143
|
*/
|
|
153
|
-
export class Tree extends
|
|
144
|
+
export class Tree extends FormattedText.createSchema(
|
|
154
145
|
sf,
|
|
155
146
|
CharacterFormat,
|
|
156
147
|
[StringLineAtom],
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { LogLevel, type ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
8
|
import type {
|
|
8
9
|
IIdCompressor,
|
|
@@ -166,6 +167,12 @@ export interface IdentifierHealingConfig {
|
|
|
166
167
|
* same session offsets.
|
|
167
168
|
*/
|
|
168
169
|
readonly sharedObjectId: string;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Optional logger used by {@link forceDecodeEncodedIdWithoutSession} to record telemetry
|
|
173
|
+
* when the heal-on-decode recovery path is taken (a non-final identifier is healed).
|
|
174
|
+
*/
|
|
175
|
+
readonly logger?: ITelemetryBaseLogger;
|
|
169
176
|
}
|
|
170
177
|
|
|
171
178
|
/**
|
|
@@ -177,6 +184,16 @@ export interface IdentifierHealingConfig {
|
|
|
177
184
|
* deterministic v5 UUID string — *not* a `StableId`, since that brand requires
|
|
178
185
|
* v4, but still a valid identifier value; the `string` arm of the return type
|
|
179
186
|
* covers this case.
|
|
187
|
+
*
|
|
188
|
+
* The recovery (heal) path only occurs because of a prior bug where non-finalized identifiers were
|
|
189
|
+
* written into summaries. When {@link IdentifierHealingConfig.logger} is supplied, a telemetry event
|
|
190
|
+
* is recorded on that path so heals can be observed in the wild. The error/throw path is intentionally
|
|
191
|
+
* not instrumented here: the thrown exception is expected to surface via the application's own error
|
|
192
|
+
* telemetry, and should never be silently swallowed.
|
|
193
|
+
*
|
|
194
|
+
* @param id - The op-space compressed ID to decode.
|
|
195
|
+
* @param idCompressor - The ID compressor used to normalize the ID.
|
|
196
|
+
* @param healing - Heal-on-decode configuration. Presence enables healing of non-final IDs.
|
|
180
197
|
*/
|
|
181
198
|
export function forceDecodeEncodedIdWithoutSession(
|
|
182
199
|
id: OpSpaceCompressedId,
|
|
@@ -189,7 +206,19 @@ export function forceDecodeEncodedIdWithoutSession(
|
|
|
189
206
|
}
|
|
190
207
|
// `id` is a non-final op-space compressed id.
|
|
191
208
|
if (healing !== undefined) {
|
|
192
|
-
|
|
209
|
+
const healed = uuidV5(`${healing.sharedObjectId}|${id}`, healingNamespace);
|
|
210
|
+
healing.logger?.send(
|
|
211
|
+
{
|
|
212
|
+
category: "generic",
|
|
213
|
+
eventName: "HealUnresolvableIdentifierOnDecode",
|
|
214
|
+
},
|
|
215
|
+
// This telemetry should be very low-volume (and possibly never happen at all),
|
|
216
|
+
// as should only occur when loading documents that were corrupted by a now fixed bug and have not been re-summarized since healing was added.
|
|
217
|
+
// It is useful for monitoring and diagnosing for this to be reported in the same cases in which the error case would be reported,
|
|
218
|
+
// which is the essential level.
|
|
219
|
+
LogLevel.essential,
|
|
220
|
+
);
|
|
221
|
+
return healed;
|
|
193
222
|
}
|
|
194
223
|
throw new Error(
|
|
195
224
|
"Summary could not be loaded due to an incorrectly encoded identifier. See SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode for mitigation.",
|
|
@@ -261,9 +290,13 @@ export interface IdDecoderOptionsWithOriginator {
|
|
|
261
290
|
*/
|
|
262
291
|
export class IdDecodingContext {
|
|
263
292
|
/**
|
|
264
|
-
*
|
|
293
|
+
* Whether this context resolves identifiers using an originator session ID.
|
|
294
|
+
* @remarks
|
|
295
|
+
* Consulted by {@link FieldBatchDecodingContext} to prevent using an originator-based
|
|
296
|
+
* decoder in incremental chunks (which may come from other sessions, making such a
|
|
297
|
+
* decoder wrong there).
|
|
265
298
|
*/
|
|
266
|
-
|
|
299
|
+
public readonly hasOriginatorSessionId: boolean;
|
|
267
300
|
|
|
268
301
|
/**
|
|
269
302
|
* Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.
|