@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.
Files changed (240) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/api-report/tree.alpha.api.md +108 -39
  3. package/dist/core/index.d.ts +1 -1
  4. package/dist/core/index.d.ts.map +1 -1
  5. package/dist/core/index.js +3 -2
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/rebase/index.d.ts +1 -1
  8. package/dist/core/rebase/index.d.ts.map +1 -1
  9. package/dist/core/rebase/index.js +2 -1
  10. package/dist/core/rebase/index.js.map +1 -1
  11. package/dist/core/rebase/types.d.ts +110 -0
  12. package/dist/core/rebase/types.d.ts.map +1 -1
  13. package/dist/core/rebase/types.js +47 -1
  14. package/dist/core/rebase/types.js.map +1 -1
  15. package/dist/entrypoints/alpha.d.ts +1 -1
  16. package/dist/entrypoints/alpha.d.ts.map +1 -1
  17. package/dist/entrypoints/alpha.js +6 -4
  18. package/dist/entrypoints/alpha.js.map +1 -1
  19. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
  20. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  21. package/dist/feature-libraries/chunked-forest/codec/codecs.js +16 -13
  22. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +6 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/packageVersion.d.ts +1 -1
  28. package/dist/packageVersion.js +1 -1
  29. package/dist/packageVersion.js.map +1 -1
  30. package/dist/shared-tree/sharedTree.d.ts +5 -0
  31. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  32. package/dist/shared-tree/sharedTree.js +1 -1
  33. package/dist/shared-tree/sharedTree.js.map +1 -1
  34. package/dist/shared-tree/treeCheckout.d.ts +5 -0
  35. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  36. package/dist/shared-tree/treeCheckout.js +58 -12
  37. package/dist/shared-tree/treeCheckout.js.map +1 -1
  38. package/dist/shared-tree-core/branch.d.ts +1 -0
  39. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  40. package/dist/shared-tree-core/branch.js.map +1 -1
  41. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  42. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  43. package/dist/simple-tree/api/index.d.ts +1 -1
  44. package/dist/simple-tree/api/index.d.ts.map +1 -1
  45. package/dist/simple-tree/api/index.js +2 -3
  46. package/dist/simple-tree/api/index.js.map +1 -1
  47. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
  48. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  49. package/dist/simple-tree/api/schemaStatics.d.ts +6 -7
  50. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  51. package/dist/simple-tree/api/schemaStatics.js.map +1 -1
  52. package/dist/simple-tree/api/treeNodeApi.d.ts +20 -24
  53. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  54. package/dist/simple-tree/api/treeNodeApi.js +48 -49
  55. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  56. package/dist/simple-tree/core/treeNode.d.ts +5 -6
  57. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  58. package/dist/simple-tree/core/treeNode.js +2 -4
  59. package/dist/simple-tree/core/treeNode.js.map +1 -1
  60. package/dist/simple-tree/core/withType.d.ts +20 -7
  61. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  62. package/dist/simple-tree/core/withType.js +4 -7
  63. package/dist/simple-tree/core/withType.js.map +1 -1
  64. package/dist/simple-tree/index.d.ts +2 -2
  65. package/dist/simple-tree/index.d.ts.map +1 -1
  66. package/dist/simple-tree/index.js +3 -4
  67. package/dist/simple-tree/index.js.map +1 -1
  68. package/dist/simple-tree/leafNodeSchema.d.ts +6 -1
  69. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  70. package/dist/simple-tree/leafNodeSchema.js +0 -1
  71. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  72. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +32 -3
  73. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  74. package/dist/simple-tree/node-kinds/array/arrayNode.js +91 -10
  75. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  76. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +77 -0
  77. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  78. package/dist/simple-tree/node-kinds/map/mapNode.js +17 -1
  79. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  80. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
  81. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  82. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
  83. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  84. package/dist/text/codePointUtils.d.ts +2 -2
  85. package/dist/text/codePointUtils.js +2 -2
  86. package/dist/text/codePointUtils.js.map +1 -1
  87. package/dist/text/index.d.ts +3 -3
  88. package/dist/text/index.d.ts.map +1 -1
  89. package/dist/text/index.js +4 -4
  90. package/dist/text/index.js.map +1 -1
  91. package/dist/text/textDomain.d.ts +18 -18
  92. package/dist/text/textDomain.d.ts.map +1 -1
  93. package/dist/text/textDomain.js +8 -8
  94. package/dist/text/textDomain.js.map +1 -1
  95. package/dist/text/textDomainFormatted.d.ts +46 -42
  96. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  97. package/dist/text/textDomainFormatted.js +32 -28
  98. package/dist/text/textDomainFormatted.js.map +1 -1
  99. package/dist/text/textDomainFormattedDefault.d.ts +18 -18
  100. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
  101. package/dist/text/textDomainFormattedDefault.js +14 -17
  102. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  103. package/dist/util/compressedIds.d.ts +22 -2
  104. package/dist/util/compressedIds.d.ts.map +1 -1
  105. package/dist/util/compressedIds.js +22 -1
  106. package/dist/util/compressedIds.js.map +1 -1
  107. package/lib/core/index.d.ts +1 -1
  108. package/lib/core/index.d.ts.map +1 -1
  109. package/lib/core/index.js +1 -1
  110. package/lib/core/index.js.map +1 -1
  111. package/lib/core/rebase/index.d.ts +1 -1
  112. package/lib/core/rebase/index.d.ts.map +1 -1
  113. package/lib/core/rebase/index.js +1 -1
  114. package/lib/core/rebase/index.js.map +1 -1
  115. package/lib/core/rebase/types.d.ts +110 -0
  116. package/lib/core/rebase/types.d.ts.map +1 -1
  117. package/lib/core/rebase/types.js +46 -0
  118. package/lib/core/rebase/types.js.map +1 -1
  119. package/lib/entrypoints/alpha.d.ts +1 -1
  120. package/lib/entrypoints/alpha.d.ts.map +1 -1
  121. package/lib/entrypoints/alpha.js +1 -1
  122. package/lib/entrypoints/alpha.js.map +1 -1
  123. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
  124. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  125. package/lib/feature-libraries/chunked-forest/codec/codecs.js +16 -13
  126. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  127. package/lib/index.d.ts +3 -3
  128. package/lib/index.d.ts.map +1 -1
  129. package/lib/index.js +2 -2
  130. package/lib/index.js.map +1 -1
  131. package/lib/packageVersion.d.ts +1 -1
  132. package/lib/packageVersion.js +1 -1
  133. package/lib/packageVersion.js.map +1 -1
  134. package/lib/shared-tree/sharedTree.d.ts +5 -0
  135. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  136. package/lib/shared-tree/sharedTree.js +1 -1
  137. package/lib/shared-tree/sharedTree.js.map +1 -1
  138. package/lib/shared-tree/treeCheckout.d.ts +5 -0
  139. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  140. package/lib/shared-tree/treeCheckout.js +60 -14
  141. package/lib/shared-tree/treeCheckout.js.map +1 -1
  142. package/lib/shared-tree-core/branch.d.ts +1 -0
  143. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  144. package/lib/shared-tree-core/branch.js.map +1 -1
  145. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  146. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  147. package/lib/simple-tree/api/index.d.ts +1 -1
  148. package/lib/simple-tree/api/index.d.ts.map +1 -1
  149. package/lib/simple-tree/api/index.js +1 -1
  150. package/lib/simple-tree/api/index.js.map +1 -1
  151. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
  152. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  153. package/lib/simple-tree/api/schemaStatics.d.ts +6 -7
  154. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  155. package/lib/simple-tree/api/schemaStatics.js.map +1 -1
  156. package/lib/simple-tree/api/treeNodeApi.d.ts +20 -24
  157. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  158. package/lib/simple-tree/api/treeNodeApi.js +46 -46
  159. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  160. package/lib/simple-tree/core/treeNode.d.ts +5 -6
  161. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  162. package/lib/simple-tree/core/treeNode.js +2 -4
  163. package/lib/simple-tree/core/treeNode.js.map +1 -1
  164. package/lib/simple-tree/core/withType.d.ts +20 -7
  165. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  166. package/lib/simple-tree/core/withType.js +4 -7
  167. package/lib/simple-tree/core/withType.js.map +1 -1
  168. package/lib/simple-tree/index.d.ts +2 -2
  169. package/lib/simple-tree/index.d.ts.map +1 -1
  170. package/lib/simple-tree/index.js +1 -1
  171. package/lib/simple-tree/index.js.map +1 -1
  172. package/lib/simple-tree/leafNodeSchema.d.ts +6 -1
  173. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  174. package/lib/simple-tree/leafNodeSchema.js +0 -1
  175. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  176. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +32 -3
  177. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  178. package/lib/simple-tree/node-kinds/array/arrayNode.js +93 -12
  179. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  180. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +77 -0
  181. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  182. package/lib/simple-tree/node-kinds/map/mapNode.js +18 -2
  183. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  184. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
  185. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  186. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
  187. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  188. package/lib/text/codePointUtils.d.ts +2 -2
  189. package/lib/text/codePointUtils.js +2 -2
  190. package/lib/text/codePointUtils.js.map +1 -1
  191. package/lib/text/index.d.ts +3 -3
  192. package/lib/text/index.d.ts.map +1 -1
  193. package/lib/text/index.js +3 -3
  194. package/lib/text/index.js.map +1 -1
  195. package/lib/text/textDomain.d.ts +18 -18
  196. package/lib/text/textDomain.d.ts.map +1 -1
  197. package/lib/text/textDomain.js +7 -7
  198. package/lib/text/textDomain.js.map +1 -1
  199. package/lib/text/textDomainFormatted.d.ts +46 -42
  200. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  201. package/lib/text/textDomainFormatted.js +31 -27
  202. package/lib/text/textDomainFormatted.js.map +1 -1
  203. package/lib/text/textDomainFormattedDefault.d.ts +18 -18
  204. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
  205. package/lib/text/textDomainFormattedDefault.js +14 -17
  206. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  207. package/lib/util/compressedIds.d.ts +22 -2
  208. package/lib/util/compressedIds.d.ts.map +1 -1
  209. package/lib/util/compressedIds.js +22 -1
  210. package/lib/util/compressedIds.js.map +1 -1
  211. package/package.json +29 -22
  212. package/src/core/index.ts +2 -0
  213. package/src/core/rebase/index.ts +2 -0
  214. package/src/core/rebase/types.ts +113 -0
  215. package/src/entrypoints/alpha.ts +10 -6
  216. package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -14
  217. package/src/index.ts +7 -4
  218. package/src/packageVersion.ts +1 -1
  219. package/src/shared-tree/sharedTree.ts +6 -1
  220. package/src/shared-tree/treeCheckout.ts +81 -14
  221. package/src/shared-tree-core/branch.ts +1 -0
  222. package/src/shared-tree-core/sharedTreeCore.ts +1 -1
  223. package/src/simple-tree/api/index.ts +0 -1
  224. package/src/simple-tree/api/schemaStatics.ts +2 -2
  225. package/src/simple-tree/api/treeNodeApi.ts +64 -48
  226. package/src/simple-tree/core/treeNode.ts +13 -10
  227. package/src/simple-tree/core/withType.ts +20 -7
  228. package/src/simple-tree/index.ts +1 -2
  229. package/src/simple-tree/leafNodeSchema.ts +6 -1
  230. package/src/simple-tree/node-kinds/array/arrayNode.ts +109 -14
  231. package/src/simple-tree/node-kinds/map/mapNode.ts +113 -3
  232. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
  233. package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
  234. package/src/text/README.md +1 -1
  235. package/src/text/codePointUtils.ts +2 -2
  236. package/src/text/index.ts +3 -3
  237. package/src/text/textDomain.ts +21 -21
  238. package/src/text/textDomainFormatted.ts +56 -52
  239. package/src/text/textDomainFormattedDefault.ts +14 -23
  240. package/src/util/compressedIds.ts +36 -3
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FormattedTextAsTree = exports.StringTextAtomNode = void 0;
7
+ exports.FormattedText = exports.StringTextAtomNode = void 0;
8
8
  const tslib_1 = require("tslib");
9
9
  const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
@@ -60,17 +60,20 @@ class StringTextAtomNode extends sfStatic.object("StringTextAtom", {
60
60
  exports.StringTextAtomNode = StringTextAtomNode;
61
61
  /**
62
62
  * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
63
+ *
63
64
  * @remarks
64
65
  * This is generic over formatting an embedded object/atom types.
65
- * See {@link FormattedTextAsTreeDefault} for a default parameterization.
66
+ *
66
67
  * @privateRemarks
68
+ * See {@link FormattedTextDefault} for an example parameterization.
69
+ *
67
70
  * TODO:
68
71
  * - Add more comprehensive tests for generic parameterizations other than default.
69
72
  * - Sort out API around overwriting subsets of formatting information.
70
- * @internal
73
+ * @alpha
71
74
  */
72
- var FormattedTextAsTree;
73
- (function (FormattedTextAsTree) {
75
+ var FormattedText;
76
+ (function (FormattedText) {
74
77
  /**
75
78
  * Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.
76
79
  *
@@ -79,20 +82,21 @@ var FormattedTextAsTree;
79
82
  * 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.
80
83
  * It must be different to distinguish different formatted text schema within the same document.
81
84
  * @param formatSchema - Schema describing the formatting associated with each atom of text.
82
- * Use an {@link NodeKind.Object|Object node} to support {@link FormattedTextAsTree.Members.formatRange}.
83
- * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)}.
85
+ * Use an {@link NodeKind.Object|Object node} to support {@link FormattedText.Members.formatRange}.
86
+ * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedText.(StringTextAtom:variable)}.
84
87
  * Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.
85
88
  * @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs
86
- * (for example {@link FormattedTextAsTree.Members.insertAt} and {@link FormattedTextAsTree.Statics.fromString} when no explicit format is provided).
87
- * @returns The schema for the formatted text node, whose nodes implement {@link FormattedTextAsTree.Members} and whose statics implement {@link FormattedTextAsTree.Statics}.
88
- * @remarks
89
- * See {@link FormattedTextAsTreeDefault} for a default parameterization of this factory.
89
+ * (for example {@link FormattedText.Members.insertAt} and {@link FormattedText.Statics.fromString} when no explicit format is provided).
90
+ * @returns The schema for the formatted text node, whose nodes implement {@link FormattedText.Members} and whose statics implement {@link FormattedText.Statics}.
91
+ *
90
92
  * @privateRemarks
91
- * TODO: The choice to always include the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
93
+ * See {@link FormattedTextDefault} for an example parameterization of this factory.
94
+ *
95
+ * TODO: The choice to always include the built-in {@link FormattedText.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
92
96
  */
93
97
  function createSchema(inputSchemaFactory, formatSchema, extraAtoms, defaultFormatInsertable) {
94
98
  var _TextNode_instances, _TextNode_fullString_reference, _TextNode_charactersCopy_reference, _TextNode_editRange;
95
- const atoms = [FormattedTextAsTree.StringTextAtom, ...extraAtoms];
99
+ const atoms = [FormattedText.StringTextAtom, ...extraAtoms];
96
100
  const sf = createFormattedScopedFactory(inputSchemaFactory);
97
101
  const defaultFormat = index_js_4.TreeBeta.create(formatSchema, defaultFormatInsertable);
98
102
  /**
@@ -170,7 +174,7 @@ var FormattedTextAsTree;
170
174
  (0, internal_1.assert)(typeof key === "string", 0xcc8 /* Object.entries returned a non-string key. */);
171
175
  return [key, value];
172
176
  });
173
- tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_editRange).call(this, start, end, "FormattedTextAsTree.formatRange", (atom) => {
177
+ tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_editRange).call(this, start, end, "FormattedText.formatRange", (atom) => {
174
178
  const formatNode = atom.format;
175
179
  const atomFormatSchema = index_js_3.Tree.schema(formatNode);
176
180
  if (!(0, index_js_4.isObjectNodeSchema)(atomFormatSchema)) {
@@ -190,12 +194,12 @@ var FormattedTextAsTree;
190
194
  }
191
195
  reformat(start, end, format) {
192
196
  const node = getFormatNode(format);
193
- tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_editRange).call(this, start, end, "FormattedTextAsTree.reformat", (atom) => {
197
+ tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_editRange).call(this, start, end, "FormattedText.reformat", (atom) => {
194
198
  atom.format = cloneFormat(node);
195
199
  });
196
200
  }
197
201
  /**
198
- * Returns the {@link FormattedTextAsTree.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
202
+ * Returns the {@link FormattedText.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
199
203
  */
200
204
  getAtomCharacterAt(index) {
201
205
  const atom = this.content[index];
@@ -237,7 +241,7 @@ var FormattedTextAsTree;
237
241
  function stringTextAtomsFromString(value) {
238
242
  // TypeScript can't prove in this Generic context that StringTextAtom is assignable to TextAtomNode, so we have to cast.
239
243
  // Since TextAtomSchemas unconditionally includes StringTextAtom, this cast is safe.
240
- return FormattedTextAsTree.StringTextAtom.fromString(value);
244
+ return FormattedText.StringTextAtom.fromString(value);
241
245
  }
242
246
  function stringAtomsFromTextAtoms(value, format) {
243
247
  const result = (0, index_js_5.mapIterable)(value, (content) => {
@@ -276,7 +280,7 @@ var FormattedTextAsTree;
276
280
  cursor.enterNode(0);
277
281
  let content;
278
282
  switch (cursor.type) {
279
- case FormattedTextAsTree.StringTextAtom.identifier: {
283
+ case FormattedText.StringTextAtom.identifier: {
280
284
  cursor.enterField(index_js_1.EmptyKey);
281
285
  cursor.enterNode(0);
282
286
  content = cursor.value;
@@ -288,7 +292,7 @@ var FormattedTextAsTree;
288
292
  // TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.
289
293
  // A less general optimization could just include cases for build in types with constant values
290
294
  // (like below commented code: currently this would cause a cyclical dependency but could be refactored).
291
- // case FormattedTextAsTree.StringLineAtom.identifier: {
295
+ // case FormattedText.StringLineAtom.identifier: {
292
296
  // content = "\n";
293
297
  // break;
294
298
  // }
@@ -317,11 +321,11 @@ var FormattedTextAsTree;
317
321
  return this.charactersCopy().join("");
318
322
  }
319
323
  getString(startIndex, endIndex = this.length) {
320
- (0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "FormattedTextAsTree.getString");
324
+ (0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "FormattedText.getString");
321
325
  return this.getCharactersSubarray(startIndex, endIndex).join("");
322
326
  }
323
327
  getUniformRun(startIndex, endIndex = this.length) {
324
- (0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "FormattedTextAsTree.getUniformRun");
328
+ (0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "FormattedText.getUniformRun");
325
329
  if (endIndex === startIndex) {
326
330
  throw new internal_2.UsageError("endIndex must be greater than startIndex for getUniformRun.");
327
331
  }
@@ -380,8 +384,8 @@ var FormattedTextAsTree;
380
384
  /**
381
385
  * Schema for a text node.
382
386
  * @remarks
383
- * See {@link FormattedTextAsTree.Members} for the API.
384
- * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.
387
+ * See {@link FormattedText.Members} for the API.
388
+ * See {@link FormattedText.Statics} for static APIs on this Schema, including construction.
385
389
  * @privateRemarks
386
390
  * eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.
387
391
  * Ideally we would generate private members for non-public properties, but TypeScript does not support this.
@@ -392,12 +396,12 @@ var FormattedTextAsTree;
392
396
  const Tree = (0, index_js_4.eraseSchemaDetailsSubclassable)()(TextNode);
393
397
  return Tree;
394
398
  }
395
- FormattedTextAsTree.createSchema = createSchema;
399
+ FormattedText.createSchema = createSchema;
396
400
  /**
397
- * Schema for a {@link FormattedTextAsTree.(StringTextAtom:variable)} node.
401
+ * Schema for a {@link FormattedText.(StringTextAtom:variable)} node.
398
402
  * @sealed
399
- * @internal
403
+ * @alpha
400
404
  */
401
- FormattedTextAsTree.StringTextAtom = (0, index_js_4.eraseSchemaDetails)()(StringTextAtomNode);
402
- })(FormattedTextAsTree || (exports.FormattedTextAsTree = FormattedTextAsTree = {}));
405
+ FormattedText.StringTextAtom = (0, index_js_4.eraseSchemaDetails)()(StringTextAtomNode);
406
+ })(FormattedText || (exports.FormattedText = FormattedText = {}));
403
407
  //# sourceMappingURL=textDomainFormatted.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAA+F;AAC/F,uEAAsE;AAEtE,+CAM0B;AAC1B,4DAAqF;AACrF,sDAAwE;AACxE,sDAUiC;AAiBjC,+CAM0B;AAE1B,mDAKyB;AAEzB;;;GAGG;AACH,2HAA2H;AAC3H,SAAS,4BAA4B,CACpC,kBAAiD;IAEjD,OAAO,IAAA,sDAA2C,EAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAI,6BAAkB,CAAC,mCAAmC,CAAC,CAAC;AAE7E,MAAM,SAAS,GAAa,IAAA,gBAAK,EAAC,QAAQ,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAa,kBACZ,SAAQ,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE;IACzC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,wBAAa,CAAC,QAAQ,CAAC,CAAC,wBAAa,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;CAC1E,CAAC;IAGK,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,SAAS,GAAG,IAAA,0BAAe,EAAC,IAAA,oCAAoB,EAAC,KAAK,CAAC,CAAC,CAAC;QAC/D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,qBAAU,CAAC,mDAAmD,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,IAAI,kBAAkB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC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OAAO,IAAI,CAAC;IACb,CAAC;IA7de,gCAAY,eA6d3B,CAAA;IA4DD;;;;OAIG;IACU,kCAAc,GAAG,IAAA,6BAAkB,GAAmC,CAClF,kBAAkB,CAClB,CAAC;AAqPH,CAAC,EAzyBgB,mBAAmB,mCAAnB,mBAAmB,QAyyBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachNodeSubsequence,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeValue,\n} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha, Tree as TreeStatic } from \"../shared-tree/index.js\";\nimport {\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n\tcreateCustomizedFluidFrameworkScopedFactory,\n\teraseSchemaDetails,\n\tisObjectNodeSchema,\n\teraseSchemaDetailsSubclassable,\n} from \"../simple-tree/index.js\";\nimport type {\n\tTreeNodeSchema,\n\tLazyItem,\n\tImplicitAllowedTypes,\n\tTreeFieldFromImplicitField,\n\tInsertableTypedNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeFieldFromImplicitField,\n\tNodeKind,\n\tTreeNode,\n\tScopedSchemaName,\n\tErasedSchemaSubclassable,\n\tErasedNode,\n\tSchemaFactoryBeta,\n} from \"../simple-tree/index.js\";\nimport {\n\tbrand,\n\tmapIterable,\n\toneFromIterable,\n\tvalidateIndex,\n\tvalidateIndexRange,\n} from \"../util/index.js\";\n\nimport {\n\tcharactersFromString,\n\texpensiveInternalValidationAssert,\n\tprocessCharactersChangedDelta,\n\ttype TextAsTree,\n} from \"./textDomain.js\";\n\n/**\n * Sets up scope for formatted text schema built-in types.\n * @remarks User-provided factory scoping will be applied as `com.fluidframework.text.formatted<user-scope>`.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Inferring is the most practical option here\nfunction createFormattedScopedFactory<TUserScope extends string>(\n\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n) {\n\treturn createCustomizedFluidFrameworkScopedFactory(inputSchemaFactory, \"text.formatted\");\n}\n\n/**\n * Schema factory for formatted text types which are not generic.\n */\nconst sfStatic = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nconst formatKey: FieldKey = brand(\"format\");\n\n/**\n * Atom in the string containing a single character.\n * @privateRemarks\n * This is outside the namespace so it can be exported for testing, but not package exported.\n */\nexport class StringTextAtomNode\n\textends sfStatic.object(\"StringTextAtom\", {\n\t\t/**\n\t\t * The underlying text content of this atom.\n\t\t * @remarks\n\t\t * This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.\n\t\t * Longer strings are still valid. For example, users might store whole grapheme clusters here, or even longer sections of text.\n\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t * Instead, atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t * @privateRemarks\n\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t */\n\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t})\n\timplements FormattedTextAsTree.TextAtom\n{\n\tpublic static fromCharacter(value: string): StringTextAtomNode {\n\t\tconst character = oneFromIterable(charactersFromString(value));\n\t\tif (character === undefined) {\n\t\t\tthrow new UsageError(\"value must contain exactly one Unicode character.\");\n\t\t}\n\t\treturn new StringTextAtomNode({ content: character });\n\t}\n\n\tpublic static fromString(value: string): StringTextAtomNode[] {\n\t\treturn Array.from(\n\t\t\tcharactersFromString(value),\n\t\t\t(character) => new StringTextAtomNode({ content: character }),\n\t\t);\n\t}\n}\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n * @remarks\n * This is generic over formatting an embedded object/atom types.\n * See {@link FormattedTextAsTreeDefault} for a default parameterization.\n * @privateRemarks\n * TODO:\n * - Add more comprehensive tests for generic parameterizations other than default.\n * - Sort out API around overwriting subsets of formatting information.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.\n\t *\n\t * @param inputSchemaFactory - The {@link SchemaFactoryBeta} used to scope the generated schema.\n\t * The generated types are scoped under `com.fluidframework.text.formatted<TUserScope>`, where `TUserScope` is the scope of this factory.\n\t * 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.\n\t * It must be different to distinguish different formatted text schema within the same document.\n\t * @param formatSchema - Schema describing the formatting associated with each atom of text.\n\t * Use an {@link NodeKind.Object|Object node} to support {@link FormattedTextAsTree.Members.formatRange}.\n\t * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)}.\n\t * Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.\n\t * @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs\n\t * (for example {@link FormattedTextAsTree.Members.insertAt} and {@link FormattedTextAsTree.Statics.fromString} when no explicit format is provided).\n\t * @returns The schema for the formatted text node, whose nodes implement {@link FormattedTextAsTree.Members} and whose statics implement {@link FormattedTextAsTree.Statics}.\n\t * @remarks\n\t * See {@link FormattedTextAsTreeDefault} for a default parameterization of this factory.\n\t * @privateRemarks\n\t * TODO: The choice to always include the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.\n\t */\n\texport function createSchema<\n\t\tconst TUserScope extends string,\n\t\tconst FormatSchema extends ImplicitAllowedTypes,\n\t\tconst ExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n\t\tformatSchema: FormatSchema,\n\t\textraAtoms: ExtraAtomsSchema,\n\t\tdefaultFormatInsertable: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t): FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema> {\n\t\tconst atoms = [StringTextAtom, ...extraAtoms] as const;\n\t\t/**\n\t\t * The type of a text atom node, which goes in a StringAtom.\n\t\t */\n\t\ttype TextAtomNode = TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>;\n\n\t\tconst sf = createFormattedScopedFactory(inputSchemaFactory);\n\n\t\tconst defaultFormat: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\tTreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable);\n\n\t\t/**\n\t\t * Gets a format node, which must be cloned before being inserted.\n\t\t */\n\t\tfunction getFormatNode(\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): TreeFieldFromImplicitField<FormatSchema> {\n\t\t\t// Note we cannot use the `format ?? defaultFormat` syntax as format is allowed to be `null`.\n\t\t\treturn format === undefined\n\t\t\t\t? defaultFormat\n\t\t\t\t: TreeBeta.create<FormatSchema>(formatSchema, format);\n\t\t}\n\n\t\tfunction cloneFormat(\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): TreeFieldFromImplicitField<FormatSchema> &\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema> {\n\t\t\tconst clone: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\t\tTreeBeta.clone<FormatSchema>(format);\n\t\t\t// TypeScript fails to prove that cloning a node gives a node, and not possible undefined (like cloning a empty field could).\n\t\t\t// This cast helps users of this function get the types they need.\n\t\t\treturn clone as typeof clone & TreeNodeFromImplicitAllowedTypes<FormatSchema>;\n\t\t}\n\n\t\tclass TextNode\n\t\t\textends sf.object(\"Text\", {\n\t\t\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t\t\t})\n\t\t\timplements Members<FormatSchema, ExtraAtomsSchema>\n\t\t{\n\t\t\tpublic insertAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters:\n\t\t\t\t\t| string\n\t\t\t\t\t| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): void {\n\t\t\t\tconst newAtoms: Iterable<TextAtomNode> =\n\t\t\t\t\ttypeof additionalCharacters === \"string\"\n\t\t\t\t\t\t? stringTextAtomsFromString(additionalCharacters)\n\t\t\t\t\t\t: additionalCharacters;\n\t\t\t\tconst formatNode = getFormatNode(format);\n\t\t\t\tthis.content.insertAt(\n\t\t\t\t\tindex,\n\t\t\t\t\tTreeArrayNode.spread(stringAtomsFromTextAtoms(newAtoms, formatNode)),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\t\t\tthis.content.removeRange(index, end);\n\t\t\t}\n\n\t\t\tpublic characters(): Iterable<string> {\n\t\t\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\tconst result = this.content.charactersCopy();\n\t\t\t\texpensiveInternalValidationAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcompareArrays(result, this.#charactersCopy_reference()) ||\n\t\t\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic characterCount(): number {\n\t\t\t\treturn this.content.length;\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\tconst result = this.content.fullString();\n\t\t\t\texpensiveInternalValidationAssert(\n\t\t\t\t\t() => result === this.#fullString_reference() || \"invalid fullString optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A non-optimized reference implementation of fullString.\n\t\t\t */\n\t\t\t#fullString_reference(): string {\n\t\t\t\treturn [...this.characters()].join(\"\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Unoptimized trivially correct implementation of charactersCopy.\n\t\t\t */\n\t\t\t#charactersCopy_reference(): string[] {\n\t\t\t\treturn [...this.characters()];\n\t\t\t}\n\n\t\t\tpublic static fromString(\n\t\t\t\tvalue: string,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): TextNode {\n\t\t\t\tconst formatNode = getFormatNode(format);\n\t\t\t\t// Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.\n\t\t\t\treturn new this({\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t\t\t\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t\t\t\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\t\t\t\t\t...textAtomsFromString(value, formatNode),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic charactersWithFormatting(): readonly StringAtom[] {\n\t\t\t\treturn this.content;\n\t\t\t}\n\t\t\tpublic insertWithFormattingAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t\t): void {\n\t\t\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t\t\t}\n\n\t\t\tpublic formatRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t\t): void {\n\t\t\t\tconst fieldFormatsRaw = Object.entries(format) as [\n\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tunknown,\n\t\t\t\t][];\n\t\t\t\tconst fieldFormats = fieldFormatsRaw.map(([key, value]) => {\n\t\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\t\tassert(\n\t\t\t\t\t\ttypeof key === \"string\",\n\t\t\t\t\t\t0xcc8 /* Object.entries returned a non-string key. */,\n\t\t\t\t\t);\n\t\t\t\t\treturn [key, value] as const;\n\t\t\t\t});\n\t\t\t\tthis.#editRange(start, end, \"FormattedTextAsTree.formatRange\", (atom) => {\n\t\t\t\t\tconst formatNode: TreeNode | TreeValue = atom.format;\n\t\t\t\t\tconst atomFormatSchema = TreeStatic.schema(formatNode);\n\t\t\t\t\tif (!isObjectNodeSchema(atomFormatSchema)) {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\"formatRange currently only supports object nodes for the format.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const [key, value] of fieldFormats) {\n\t\t\t\t\t\tconst field = atomFormatSchema.fields.get(key);\n\t\t\t\t\t\tif (field === undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\t\t\t// Note that since this uses field schema, `undefined` can pass through this if allowed by the schema.\n\t\t\t\t\t\tconst clonedValue = TreeBeta.clone(TreeBeta.create(field, value as never)) as\n\t\t\t\t\t\t\t| TreeNode\n\t\t\t\t\t\t\t| TreeValue;\n\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformatNode as unknown as Record<\n\t\t\t\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\t\t\t\tTreeNode | TreeValue\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t)[key] = clonedValue;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic reformat(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): void {\n\t\t\t\tconst node = getFormatNode(format);\n\t\t\t\tthis.#editRange(start, end, \"FormattedTextAsTree.reformat\", (atom) => {\n\t\t\t\t\tatom.format = cloneFormat(node);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Map an edit over a range of atoms, validating the range and running the edits in a transaction.\n\t\t\t * @remarks\n\t\t\t * This is not exposed in the API since this approach will have to be replaced when formatting is optimized,\n\t\t\t * so we don't want users to directly depend on this un-optimizable layer.\n\t\t\t */\n\t\t\t#editRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tmethod: string,\n\t\t\t\tedit: (atom: StringAtom) => void,\n\t\t\t): void {\n\t\t\t\tconst formatStart = start ?? 0;\n\t\t\t\tvalidateIndex(formatStart, this.content, method, true);\n\n\t\t\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\t\t\tvalidateIndexRange(formatStart, formatEnd, this.content, method);\n\n\t\t\t\tTreeAlpha.context(this).runTransaction(() => {\n\t\t\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\t\t\tconst atom = this.content[i];\n\t\t\t\t\t\t// Range validated above, so this should never fail.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tatom !== undefined,\n\t\t\t\t\t\t\t0xd08 /* Index out of bounds while formatting text range. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tedit(atom);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Returns the {@link FormattedTextAsTree.TextAtom.content} at the given atom index, or `undefined` if out of bounds.\n\t\t\t */\n\t\t\tprivate getAtomCharacterAt(index: number): string | undefined {\n\t\t\t\tconst atom = this.content[index];\n\t\t\t\tif (atom === undefined) return undefined;\n\t\t\t\treturn atom.content.content;\n\t\t\t}\n\n\t\t\tpublic onCharactersChanged(\n\t\t\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"nodeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic onContentChanged(\n\t\t\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"treeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\t\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\t\t\treturn this.content.getString(startIndex, endIndex);\n\t\t\t}\n\t\t}\n\n\t\tfunction stringTextAtomsFromString(\n\t\t\tvalue: string,\n\t\t): Iterable<StringTextAtom & TextAtomNode> {\n\t\t\t// TypeScript can't prove in this Generic context that StringTextAtom is assignable to TextAtomNode, so we have to cast.\n\t\t\t// Since TextAtomSchemas unconditionally includes StringTextAtom, this cast is safe.\n\t\t\treturn StringTextAtom.fromString(value) as (StringTextAtom & TextAtomNode)[];\n\t\t}\n\n\t\tfunction stringAtomsFromTextAtoms(\n\t\t\tvalue: Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst result = mapIterable(value, (content) => {\n\t\t\t\tconst data = {\n\t\t\t\t\tcontent,\n\t\t\t\t\tformat: cloneFormat(format),\n\t\t\t\t};\n\t\t\t\treturn new StringAtom(data as never); // Generic break type safety here. TODO: try and make safer.\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\n\t\tfunction textAtomsFromString(\n\t\t\tvalue: string,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst textAtoms = stringTextAtomsFromString(value);\n\t\t\treturn stringAtomsFromTextAtoms(textAtoms, format);\n\t\t}\n\n\t\tclass StringArray extends sf.array(\"StringArray\", [() => StringAtom]) {\n\t\t\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\t\t\tconst innerNode = getInnerNode(this);\n\t\t\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t\t\t// treat it as if it observed the whole subtree.\n\t\t\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\t\t\tconst cursor = innerNode.borrowCursor();\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tconst result = f(cursor);\n\t\t\t\tcursor.exitField();\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\t\t\tconst slowPathIndexes: number[] = [];\n\t\t\t\tconst result: string[] = [];\n\t\t\t\tthis.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\t(cursor.type as string) === StringAtom.identifier ||\n\t\t\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tlet content: string;\n\t\t\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\t\t\tcase StringTextAtom.identifier: {\n\t\t\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.\n\t\t\t\t\t\t\t// A less general optimization could just include cases for build in types with constant values\n\t\t\t\t\t\t\t// (like below commented code: currently this would cause a cyclical dependency but could be refactored).\n\t\t\t\t\t\t\t// case FormattedTextAsTree.StringLineAtom.identifier: {\n\t\t\t\t\t\t\t// \tcontent = \"\\n\";\n\t\t\t\t\t\t\t// \tbreak;\n\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\tslowPathIndexes.push(result.length);\n\t\t\t\t\t\t\t\tcontent = \"\"; // Placeholder for slow path content\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tresult.push(content);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Fill in slow path cases not optimized above.\n\t\t\t\tfor (const index of slowPathIndexes) {\n\t\t\t\t\tconst node =\n\t\t\t\t\t\tthis[index + startIndex] ??\n\t\t\t\t\t\tfail(\n\t\t\t\t\t\t\t0xd09 /* getCharactersSubarray failed to find index after index range was checked */,\n\t\t\t\t\t\t);\n\t\t\t\t\tresult[index] = node.content.content;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\treturn this.getCharactersSubarray(0, this.length);\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\treturn this.charactersCopy().join(\"\");\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getString\");\n\t\t\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getUniformRun\");\n\t\t\t\tif (endIndex === startIndex) {\n\t\t\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t\t\t}\n\t\t\t\tconst arrayLength = this.length;\n\t\t\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t\t\t// Capture the content type of the first atom\n\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst contentType = cursor.type;\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t\t\t// This compares by field key\n\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\tlet runLength = 1;\n\t\t\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t\t\t// Compare atom type\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tif (!typeMatches) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trunLength++;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\treturn runLength;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * A unit of the text, with formatting.\n\t\t */\n\t\tclass StringAtom\n\t\t\textends sf.object(\"StringAtom\", {\n\t\t\t\tcontent: SchemaFactory.required(atoms, { key: EmptyKey }),\n\t\t\t\tformat: SchemaFactory.required(formatSchema),\n\t\t\t})\n\t\t\timplements\n\t\t\t\tFormattedAtom<\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<typeof atoms>\n\t\t\t\t> {}\n\n\t\t/**\n\t\t * Schema for a text node.\n\t\t * @remarks\n\t\t * See {@link FormattedTextAsTree.Members} for the API.\n\t\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t\t * @privateRemarks\n\t\t * eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.\n\t\t * Ideally we would generate private members for non-public properties, but TypeScript does not support this.\n\t\t * It is up to the user of eraseSchemaDetailsSubclassable to manage this risk.\n\t\t *\n\t\t * TODO: there is at least one collision prone member to worry about here: `content`.\n\t\t */\n\t\tconst Tree = eraseSchemaDetailsSubclassable<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tStatics<Tree, FormatSchema>\n\t\t>()(TextNode);\n\t\ttype Tree = ErasedNode<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n\n\t\treturn Tree;\n\t}\n\n\t/**\n\t * Portion of a string with formatting.\n\t * @privateRemarks\n\t * This is implemented {@link StringAtom}, but we avoid leaking the fact this is a TreeNode in the API surface to\n\t * preserve more future flexibility.\n\t * @sealed\n\t * @internal\n\t */\n\texport interface FormattedAtom<TFormat, TText> {\n\t\t/**\n\t\t * Content which is formatted.\n\t\t */\n\t\treadonly content: TText;\n\t\t/**\n\t\t * Formatting which is applied to the content.\n\t\t * @remarks\n\t\t * Can be reassigned or deeply mutated to edit the formatting of the content.\n\t\t */\n\t\tformat: TFormat;\n\t}\n\n\t/**\n\t * Portion of a string.\n\t * @remarks\n\t * Additional kinds of text atoms (also known as embedded objects) which can occur inside a string can implement this.\n\t * The schema for them can then be provided to {@link FormattedTextAsTree.createSchema}.\n\t * @internal\n\t */\n\texport interface TextAtom {\n\t\t/**\n\t\t * The content of the text atom, viewed as a string.\n\t\t */\n\t\treadonly content: string;\n\t}\n\n\t/**\n\t * Static factory functions for {@link FormattedTextAsTree.(StringTextAtom:variable)}.\n\t * @privateRemarks\n\t * We type-erase `StringTextAtom` and only provide these static factories for construction\n\t * to reduce the chance of someone accidentally creating a text atom for a string other than a single unicode code point.\n\t * 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.\n\t * 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.\n\t * @sealed\n\t * @internal\n\t */\n\texport interface StringTextAtomStatics {\n\t\t/**\n\t\t * Creates an atom from exactly one Unicode code point.\n\t\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if `value` does not contain exactly one Unicode code character.\n\t\t */\n\t\tfromCharacter(value: string): StringTextAtom;\n\n\t\t/**\n\t\t * Creates one atom for each Unicode code point in `value`.\n\t\t */\n\t\tfromString(value: string): StringTextAtom[];\n\t}\n\n\t/**\n\t * Schema for a {@link FormattedTextAsTree.(StringTextAtom:variable)} node.\n\t * @sealed\n\t * @internal\n\t */\n\texport const StringTextAtom = eraseSchemaDetails<TextAtom, StringTextAtomStatics>()(\n\t\tStringTextAtomNode,\n\t);\n\n\t/**\n\t * Node for the {@link FormattedTextAsTree.(StringTextAtom:variable)} schema.\n\t * @sealed\n\t * @internal\n\t */\n\texport type StringTextAtom = ErasedNode<\n\t\tTextAtom,\n\t\t\"com.fluidframework.text.formatted.StringTextAtom\"\n\t>;\n\n\t/**\n\t * Statics for formatted text nodes.\n\t * @sealed\n\t * @internal\n\t */\n\texport interface Statics<TTree, FormatSchema extends ImplicitAllowedTypes> {\n\t\t/**\n\t\t * Construct a node of `this` schema from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(\n\t\t\tvalue: string,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): TTree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedTextAsTree.Statics.fromString} for construction.\n\t * @see {@link FormattedTextAsTree.createSchema} for creating schemas whose nodes implement this.\n\t * @sealed\n\t * @internal\n\t */\n\texport interface Members<\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> extends TextAsTree.Members {\n\t\t/**\n\t\t * {@link TextAsTree.Members.insertAt} with optional formatting to apply to all additional characters,\n\t\t * and allowing an array of atoms instead of a string.\n\t\t * @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedTextAsTree.createSchema}) will be used.\n\t\t * @remarks\n\t\t * Use {@link FormattedTextAsTree.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.\n\t\t * @override\n\t\t */\n\t\tinsertAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters:\n\t\t\t\t| string\n\t\t\t\t| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Gets an array type view of the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t *\n\t\t * For more efficient access, use {@link FormattedTextAsTree.Members.getUniformRun} and {@link FormattedTextAsTree.Members.getString} to access ranges of characters\n\t\t * to avoid having to inspect the formatting on every atom.\n\t\t * @privateRemarks\n\t\t * Currently this is implemented by a node and changes with the text over time.\n\t\t * We might not want to leak a node like this in the API.\n\t\t * Providing a way to index and iterate separately might be better.\n\t\t */\n\t\tcharactersWithFormatting(): readonly FormattedAtom<\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\tTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>\n\t\t>[];\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedTextAsTree.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<\n\t\t\t\tFormattedAtomInsertable<\n\t\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>\n\t\t\t\t>\n\t\t\t>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t * For each atom, every property of `format` will be cloned and assigned to the atom's format's corresponding subtree, overwriting any existing values for those properties.\n\t\t * All enumerable own properties of `format` will be applied, including those with `undefined` values.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t * This edits existing formatting subtrees on each atom, and only works when those atoms are object nodes.\n\t\t *\n\t\t * This is typically used to set some formatting property, like `bold` on a range of text without impacting other formatting properties.\n\t\t * @privateRemarks\n\t\t * This API is designed such that it can be optimized and improved in the future in a few different ways:\n\t\t * 1. TODO: It can be optimized to use lower level APIs directly, bypassing the overhead of the public API surface.\n\t\t * 2. TODO: A lower level editing API could be introduced and used to more efficiently express the edit (for example a bulk edit based on path, or a way to reuse the inserted content in multiple places instead of having to clone it before making the edit).\n\t\t * 3. TODO: Optimize the encoding of such edits, either with a dedicated format for range edits like this and/or encoding optimizations that can compress such edits over ranges to O(1) space.\n\t\t * 4. TODO: Preserve the range editing semantics through the whole stack to allow for better merge behavior, and make optimizations easier.\n\t\t */\n\t\tformatRange(\n\t\t\tstartIndex: number | undefined,\n\t\t\tendIndex: number | undefined,\n\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Replace formatting of a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to replace the formatting of the indicated range with.\n\t\t * For each atom, `format` will be cloned and assigned to the atom's format, overwriting any existing formatting.\n\t\t * If not specified the `defaultFormat` from {@link FormattedTextAsTree.createSchema} will be used.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t *\n\t\t * This is typically used to normalize formatting, like resetting the formatting of a range to default settings.\n\t\t * @privateRemarks\n\t\t * See notes on {@link FormattedTextAsTree.Members.formatRange} for future optimization opportunities.\n\t\t */\n\t\treformat(\n\t\t\tstartIndex?: number | undefined,\n\t\t\tendIndex?: number | undefined,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Returns the length of the run of characters starting at `startIndex` which have the same formatting and atom type, up to `endIndex`.\n\t\t * @param startIndex - The starting index of the run.\n\t\t * @param endIndex - The ending index (exclusive) of the run. Defaults to the end of the text.\n\t\t */\n\t\tgetUniformRun(startIndex: number, endIndex?: number): number;\n\t\t/**\n\t\t * Returns a substring of the text from `startIndex` to `endIndex`\n\t\t * @param startIndex - starting index (inclusive)\n\t\t * @param endIndex - Optional ending index (exclusive). Defaults to the end of the text.\n\t\t */\n\t\tgetString(startIndex: number, endIndex?: number): string;\n\n\t\t/**\n\t\t * Subscribe to all content changes on this text node, including both shallow\n\t\t * changes (inserts/removes) and deep changes (formatting updates on existing characters).\n\t\t * @param callback - Called after each change with a sequence of {@link TextAsTree.TextOp}s describing what changed,\n\t\t * or `undefined` when a delta could not be computed (e.g. during a schema upgrade).\n\t\t * @returns A cleanup function that unsubscribes the callback when called.\n\t\t * @remarks\n\t\t * Unlike {@link TextAsTree.Members.onCharactersChanged} which only fires on\n\t\t * shallow changes (inserts and removes), this method also fires on deep changes —\n\t\t * formatting property updates on existing characters.\n\t\t * The {@link TextAsTree.TextRetainOp.formattingChanged} flag on retain ops\n\t\t * indicates which character ranges had formatting updates.\n\t\t *\n\t\t * All counts in the delivered ops are in Unicode code points, not UTF-16 code units.\n\t\t * For characters outside the Basic Multilingual Plane (e.g. emoji), one code point\n\t\t * corresponds to two UTF-16 code units — convert before using the counts as string indices.\n\t\t */\n\t\tonContentChanged(\n\t\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t\t): () => void;\n\t}\n\n\t/**\n\t * Insertable shape for a formatted text atom used by {@link FormattedTextAsTree.Members.insertWithFormattingAt}.\n\t * @input\n\t * @internal\n\t */\n\texport interface FormattedAtomInsertable<TFormat, TContent> {\n\t\treadonly content: TContent;\n\t\treadonly format: TFormat;\n\t}\n\n\t/**\n\t * Schema identifier for the a generic formatted text schema.\n\t * @privateRemarks\n\t * Eventually this should probably be given a better name and/or made a system type in a system namespace.\n\t * @internal\n\t */\n\texport type FormattedTextSchemaIdentifier<TUserScope extends string> = ScopedSchemaName<\n\t\t`com.fluidframework.text.formatted<${TUserScope}>`,\n\t\t\"Text\"\n\t>;\n\n\t/**\n\t * Helper for expressing the full set of text atoms for a given schema.\n\t * @remarks\n\t * This is just schema for the text atom {@link AllowedTypes},\n\t * and does not include the actual formatting (which is higher up in the tree).\n\t * @sealed\n\t * @internal\n\t */\n\texport type TextAtomSchemas<\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = readonly [typeof StringTextAtom, ...ExtraAtomsSchema];\n\n\t/**\n\t * A generic type for a formatted text schema.\n\t * @sealed\n\t * @internal\n\t */\n\texport type FormattedTextSchema<\n\t\tTUserScope extends string,\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = Statics<\n\t\tErasedNode<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>,\n\t\tFormatSchema\n\t> &\n\t\tErasedSchemaSubclassable<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n}\n"]}
1
+ {"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAA+F;AAC/F,uEAAsE;AAEtE,+CAM0B;AAC1B,4DAAqF;AACrF,sDAAwE;AACxE,sDAUiC;AAiBjC,+CAM0B;AAE1B,mDAKyB;AAEzB;;;GAGG;AACH,2HAA2H;AAC3H,SAAS,4BAA4B,CACpC,kBAAiD;IAEjD,OAAO,IAAA,sDAA2C,EAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAI,6BAAkB,CAAC,mCAAmC,CAAC,CAAC;AAE7E,MAAM,SAAS,GAAa,IAAA,gBAAK,EAAC,QAAQ,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAa,kBACZ,SAAQ,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE;IACzC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,wBAAa,CAAC,QAAQ,CAAC,CAAC,wBAAa,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;CAC1E,CAAC;IAGK,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,S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AAE,wBAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;YACzD,MAAM,EAAE,wBAAa,CAAC,QAAQ,CAAC,YAAY,CAAC;SAC5C,CAAC;SAKG;QAEN;;;;;;;;;;;WAWG;QACH,MAAM,IAAI,GAAG,IAAA,yCAA8B,GAGxC,CAAC,QAAQ,CAAC,CAAC;QAMd,OAAO,IAAI,CAAC;IACb,CAAC;IA7de,0BAAY,eA6d3B,CAAA;IA4DD;;;;OAIG;IACU,4BAAc,GAAG,IAAA,6BAAkB,GAAmC,CAClF,kBAAkB,CAClB,CAAC;AAqPH,CAAC,EA1yBgB,aAAa,6BAAb,aAAa,QA0yB7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachNodeSubsequence,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeValue,\n} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha, Tree as TreeStatic } from \"../shared-tree/index.js\";\nimport {\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n\tcreateCustomizedFluidFrameworkScopedFactory,\n\teraseSchemaDetails,\n\tisObjectNodeSchema,\n\teraseSchemaDetailsSubclassable,\n} from \"../simple-tree/index.js\";\nimport type {\n\tTreeNodeSchema,\n\tLazyItem,\n\tImplicitAllowedTypes,\n\tTreeFieldFromImplicitField,\n\tInsertableTypedNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeFieldFromImplicitField,\n\tNodeKind,\n\tTreeNode,\n\tScopedSchemaName,\n\tErasedSchemaSubclassable,\n\tErasedNode,\n\tSchemaFactoryBeta,\n} from \"../simple-tree/index.js\";\nimport {\n\tbrand,\n\tmapIterable,\n\toneFromIterable,\n\tvalidateIndex,\n\tvalidateIndexRange,\n} from \"../util/index.js\";\n\nimport {\n\tcharactersFromString,\n\texpensiveInternalValidationAssert,\n\tprocessCharactersChangedDelta,\n\ttype PlainText,\n} from \"./textDomain.js\";\n\n/**\n * Sets up scope for formatted text schema built-in types.\n * @remarks User-provided factory scoping will be applied as `com.fluidframework.text.formatted<user-scope>`.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Inferring is the most practical option here\nfunction createFormattedScopedFactory<TUserScope extends string>(\n\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n) {\n\treturn createCustomizedFluidFrameworkScopedFactory(inputSchemaFactory, \"text.formatted\");\n}\n\n/**\n * Schema factory for formatted text types which are not generic.\n */\nconst sfStatic = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nconst formatKey: FieldKey = brand(\"format\");\n\n/**\n * Atom in the string containing a single character.\n * @privateRemarks\n * This is outside the namespace so it can be exported for testing, but not package exported.\n */\nexport class StringTextAtomNode\n\textends sfStatic.object(\"StringTextAtom\", {\n\t\t/**\n\t\t * The underlying text content of this atom.\n\t\t * @remarks\n\t\t * This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.\n\t\t * Longer strings are still valid. For example, users might store whole grapheme clusters here, or even longer sections of text.\n\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t * Instead, atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t * @privateRemarks\n\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t */\n\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t})\n\timplements FormattedText.TextAtom\n{\n\tpublic static fromCharacter(value: string): StringTextAtomNode {\n\t\tconst character = oneFromIterable(charactersFromString(value));\n\t\tif (character === undefined) {\n\t\t\tthrow new UsageError(\"value must contain exactly one Unicode character.\");\n\t\t}\n\t\treturn new StringTextAtomNode({ content: character });\n\t}\n\n\tpublic static fromString(value: string): StringTextAtomNode[] {\n\t\treturn Array.from(\n\t\t\tcharactersFromString(value),\n\t\t\t(character) => new StringTextAtomNode({ content: character }),\n\t\t);\n\t}\n}\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n *\n * @remarks\n * This is generic over formatting an embedded object/atom types.\n *\n * @privateRemarks\n * See {@link FormattedTextDefault} for an example parameterization.\n *\n * TODO:\n * - Add more comprehensive tests for generic parameterizations other than default.\n * - Sort out API around overwriting subsets of formatting information.\n * @alpha\n */\nexport namespace FormattedText {\n\t/**\n\t * Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.\n\t *\n\t * @param inputSchemaFactory - The {@link SchemaFactoryBeta} used to scope the generated schema.\n\t * The generated types are scoped under `com.fluidframework.text.formatted<TUserScope>`, where `TUserScope` is the scope of this factory.\n\t * 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.\n\t * It must be different to distinguish different formatted text schema within the same document.\n\t * @param formatSchema - Schema describing the formatting associated with each atom of text.\n\t * Use an {@link NodeKind.Object|Object node} to support {@link FormattedText.Members.formatRange}.\n\t * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedText.(StringTextAtom:variable)}.\n\t * Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.\n\t * @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs\n\t * (for example {@link FormattedText.Members.insertAt} and {@link FormattedText.Statics.fromString} when no explicit format is provided).\n\t * @returns The schema for the formatted text node, whose nodes implement {@link FormattedText.Members} and whose statics implement {@link FormattedText.Statics}.\n\t *\n\t * @privateRemarks\n\t * See {@link FormattedTextDefault} for an example parameterization of this factory.\n\t *\n\t * TODO: The choice to always include the built-in {@link FormattedText.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.\n\t */\n\texport function createSchema<\n\t\tconst TUserScope extends string,\n\t\tconst FormatSchema extends ImplicitAllowedTypes,\n\t\tconst ExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n\t\tformatSchema: FormatSchema,\n\t\textraAtoms: ExtraAtomsSchema,\n\t\tdefaultFormatInsertable: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t): FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema> {\n\t\tconst atoms = [StringTextAtom, ...extraAtoms] as const;\n\t\t/**\n\t\t * The type of a text atom node, which goes in a StringAtom.\n\t\t */\n\t\ttype TextAtomNode = TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>;\n\n\t\tconst sf = createFormattedScopedFactory(inputSchemaFactory);\n\n\t\tconst defaultFormat: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\tTreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable);\n\n\t\t/**\n\t\t * Gets a format node, which must be cloned before being inserted.\n\t\t */\n\t\tfunction getFormatNode(\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): TreeFieldFromImplicitField<FormatSchema> {\n\t\t\t// Note we cannot use the `format ?? defaultFormat` syntax as format is allowed to be `null`.\n\t\t\treturn format === undefined\n\t\t\t\t? defaultFormat\n\t\t\t\t: TreeBeta.create<FormatSchema>(formatSchema, format);\n\t\t}\n\n\t\tfunction cloneFormat(\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): TreeFieldFromImplicitField<FormatSchema> &\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema> {\n\t\t\tconst clone: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\t\tTreeBeta.clone<FormatSchema>(format);\n\t\t\t// TypeScript fails to prove that cloning a node gives a node, and not possible undefined (like cloning a empty field could).\n\t\t\t// This cast helps users of this function get the types they need.\n\t\t\treturn clone as typeof clone & TreeNodeFromImplicitAllowedTypes<FormatSchema>;\n\t\t}\n\n\t\tclass TextNode\n\t\t\textends sf.object(\"Text\", {\n\t\t\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t\t\t})\n\t\t\timplements Members<FormatSchema, ExtraAtomsSchema>\n\t\t{\n\t\t\tpublic insertAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters:\n\t\t\t\t\t| string\n\t\t\t\t\t| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): void {\n\t\t\t\tconst newAtoms: Iterable<TextAtomNode> =\n\t\t\t\t\ttypeof additionalCharacters === \"string\"\n\t\t\t\t\t\t? stringTextAtomsFromString(additionalCharacters)\n\t\t\t\t\t\t: additionalCharacters;\n\t\t\t\tconst formatNode = getFormatNode(format);\n\t\t\t\tthis.content.insertAt(\n\t\t\t\t\tindex,\n\t\t\t\t\tTreeArrayNode.spread(stringAtomsFromTextAtoms(newAtoms, formatNode)),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\t\t\tthis.content.removeRange(index, end);\n\t\t\t}\n\n\t\t\tpublic characters(): Iterable<string> {\n\t\t\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\tconst result = this.content.charactersCopy();\n\t\t\t\texpensiveInternalValidationAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcompareArrays(result, this.#charactersCopy_reference()) ||\n\t\t\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic characterCount(): number {\n\t\t\t\treturn this.content.length;\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\tconst result = this.content.fullString();\n\t\t\t\texpensiveInternalValidationAssert(\n\t\t\t\t\t() => result === this.#fullString_reference() || \"invalid fullString optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A non-optimized reference implementation of fullString.\n\t\t\t */\n\t\t\t#fullString_reference(): string {\n\t\t\t\treturn [...this.characters()].join(\"\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Unoptimized trivially correct implementation of charactersCopy.\n\t\t\t */\n\t\t\t#charactersCopy_reference(): string[] {\n\t\t\t\treturn [...this.characters()];\n\t\t\t}\n\n\t\t\tpublic static fromString(\n\t\t\t\tvalue: string,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): TextNode {\n\t\t\t\tconst formatNode = getFormatNode(format);\n\t\t\t\t// Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.\n\t\t\t\treturn new this({\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t\t\t\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t\t\t\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\t\t\t\t\t...textAtomsFromString(value, formatNode),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic charactersWithFormatting(): readonly StringAtom[] {\n\t\t\t\treturn this.content;\n\t\t\t}\n\t\t\tpublic insertWithFormattingAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t\t): void {\n\t\t\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t\t\t}\n\n\t\t\tpublic formatRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t\t): void {\n\t\t\t\tconst fieldFormatsRaw = Object.entries(format) as [\n\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tunknown,\n\t\t\t\t][];\n\t\t\t\tconst fieldFormats = fieldFormatsRaw.map(([key, value]) => {\n\t\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\t\tassert(\n\t\t\t\t\t\ttypeof key === \"string\",\n\t\t\t\t\t\t0xcc8 /* Object.entries returned a non-string key. */,\n\t\t\t\t\t);\n\t\t\t\t\treturn [key, value] as const;\n\t\t\t\t});\n\t\t\t\tthis.#editRange(start, end, \"FormattedText.formatRange\", (atom) => {\n\t\t\t\t\tconst formatNode: TreeNode | TreeValue = atom.format;\n\t\t\t\t\tconst atomFormatSchema = TreeStatic.schema(formatNode);\n\t\t\t\t\tif (!isObjectNodeSchema(atomFormatSchema)) {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\"formatRange currently only supports object nodes for the format.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const [key, value] of fieldFormats) {\n\t\t\t\t\t\tconst field = atomFormatSchema.fields.get(key);\n\t\t\t\t\t\tif (field === undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\t\t\t// Note that since this uses field schema, `undefined` can pass through this if allowed by the schema.\n\t\t\t\t\t\tconst clonedValue = TreeBeta.clone(TreeBeta.create(field, value as never)) as\n\t\t\t\t\t\t\t| TreeNode\n\t\t\t\t\t\t\t| TreeValue;\n\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformatNode as unknown as Record<\n\t\t\t\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\t\t\t\tTreeNode | TreeValue\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t)[key] = clonedValue;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic reformat(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): void {\n\t\t\t\tconst node = getFormatNode(format);\n\t\t\t\tthis.#editRange(start, end, \"FormattedText.reformat\", (atom) => {\n\t\t\t\t\tatom.format = cloneFormat(node);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Map an edit over a range of atoms, validating the range and running the edits in a transaction.\n\t\t\t * @remarks\n\t\t\t * This is not exposed in the API since this approach will have to be replaced when formatting is optimized,\n\t\t\t * so we don't want users to directly depend on this un-optimizable layer.\n\t\t\t */\n\t\t\t#editRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tmethod: string,\n\t\t\t\tedit: (atom: StringAtom) => void,\n\t\t\t): void {\n\t\t\t\tconst formatStart = start ?? 0;\n\t\t\t\tvalidateIndex(formatStart, this.content, method, true);\n\n\t\t\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\t\t\tvalidateIndexRange(formatStart, formatEnd, this.content, method);\n\n\t\t\t\tTreeAlpha.context(this).runTransaction(() => {\n\t\t\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\t\t\tconst atom = this.content[i];\n\t\t\t\t\t\t// Range validated above, so this should never fail.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tatom !== undefined,\n\t\t\t\t\t\t\t0xd08 /* Index out of bounds while formatting text range. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tedit(atom);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Returns the {@link FormattedText.TextAtom.content} at the given atom index, or `undefined` if out of bounds.\n\t\t\t */\n\t\t\tprivate getAtomCharacterAt(index: number): string | undefined {\n\t\t\t\tconst atom = this.content[index];\n\t\t\t\tif (atom === undefined) return undefined;\n\t\t\t\treturn atom.content.content;\n\t\t\t}\n\n\t\t\tpublic onCharactersChanged(\n\t\t\t\tcallback: (ops: readonly PlainText.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"nodeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic onContentChanged(\n\t\t\t\tcallback: (ops: readonly PlainText.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"treeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\t\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\t\t\treturn this.content.getString(startIndex, endIndex);\n\t\t\t}\n\t\t}\n\n\t\tfunction stringTextAtomsFromString(\n\t\t\tvalue: string,\n\t\t): Iterable<StringTextAtom & TextAtomNode> {\n\t\t\t// TypeScript can't prove in this Generic context that StringTextAtom is assignable to TextAtomNode, so we have to cast.\n\t\t\t// Since TextAtomSchemas unconditionally includes StringTextAtom, this cast is safe.\n\t\t\treturn StringTextAtom.fromString(value) as (StringTextAtom & TextAtomNode)[];\n\t\t}\n\n\t\tfunction stringAtomsFromTextAtoms(\n\t\t\tvalue: Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst result = mapIterable(value, (content) => {\n\t\t\t\tconst data = {\n\t\t\t\t\tcontent,\n\t\t\t\t\tformat: cloneFormat(format),\n\t\t\t\t};\n\t\t\t\treturn new StringAtom(data as never); // Generic break type safety here. TODO: try and make safer.\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\n\t\tfunction textAtomsFromString(\n\t\t\tvalue: string,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst textAtoms = stringTextAtomsFromString(value);\n\t\t\treturn stringAtomsFromTextAtoms(textAtoms, format);\n\t\t}\n\n\t\tclass StringArray extends sf.array(\"StringArray\", [() => StringAtom]) {\n\t\t\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\t\t\tconst innerNode = getInnerNode(this);\n\t\t\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t\t\t// treat it as if it observed the whole subtree.\n\t\t\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\t\t\tconst cursor = innerNode.borrowCursor();\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tconst result = f(cursor);\n\t\t\t\tcursor.exitField();\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\t\t\tconst slowPathIndexes: number[] = [];\n\t\t\t\tconst result: string[] = [];\n\t\t\t\tthis.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\t(cursor.type as string) === StringAtom.identifier ||\n\t\t\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tlet content: string;\n\t\t\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\t\t\tcase StringTextAtom.identifier: {\n\t\t\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.\n\t\t\t\t\t\t\t// A less general optimization could just include cases for build in types with constant values\n\t\t\t\t\t\t\t// (like below commented code: currently this would cause a cyclical dependency but could be refactored).\n\t\t\t\t\t\t\t// case FormattedText.StringLineAtom.identifier: {\n\t\t\t\t\t\t\t// \tcontent = \"\\n\";\n\t\t\t\t\t\t\t// \tbreak;\n\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\tslowPathIndexes.push(result.length);\n\t\t\t\t\t\t\t\tcontent = \"\"; // Placeholder for slow path content\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tresult.push(content);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Fill in slow path cases not optimized above.\n\t\t\t\tfor (const index of slowPathIndexes) {\n\t\t\t\t\tconst node =\n\t\t\t\t\t\tthis[index + startIndex] ??\n\t\t\t\t\t\tfail(\n\t\t\t\t\t\t\t0xd09 /* getCharactersSubarray failed to find index after index range was checked */,\n\t\t\t\t\t\t);\n\t\t\t\t\tresult[index] = node.content.content;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\treturn this.getCharactersSubarray(0, this.length);\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\treturn this.charactersCopy().join(\"\");\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedText.getString\");\n\t\t\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedText.getUniformRun\");\n\t\t\t\tif (endIndex === startIndex) {\n\t\t\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t\t\t}\n\t\t\t\tconst arrayLength = this.length;\n\t\t\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t\t\t// Capture the content type of the first atom\n\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst contentType = cursor.type;\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t\t\t// This compares by field key\n\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\tlet runLength = 1;\n\t\t\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t\t\t// Compare atom type\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tif (!typeMatches) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trunLength++;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\treturn runLength;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * A unit of the text, with formatting.\n\t\t */\n\t\tclass StringAtom\n\t\t\textends sf.object(\"StringAtom\", {\n\t\t\t\tcontent: SchemaFactory.required(atoms, { key: EmptyKey }),\n\t\t\t\tformat: SchemaFactory.required(formatSchema),\n\t\t\t})\n\t\t\timplements\n\t\t\t\tFormattedAtom<\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<typeof atoms>\n\t\t\t\t> {}\n\n\t\t/**\n\t\t * Schema for a text node.\n\t\t * @remarks\n\t\t * See {@link FormattedText.Members} for the API.\n\t\t * See {@link FormattedText.Statics} for static APIs on this Schema, including construction.\n\t\t * @privateRemarks\n\t\t * eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.\n\t\t * Ideally we would generate private members for non-public properties, but TypeScript does not support this.\n\t\t * It is up to the user of eraseSchemaDetailsSubclassable to manage this risk.\n\t\t *\n\t\t * TODO: there is at least one collision prone member to worry about here: `content`.\n\t\t */\n\t\tconst Tree = eraseSchemaDetailsSubclassable<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tStatics<Tree, FormatSchema>\n\t\t>()(TextNode);\n\t\ttype Tree = ErasedNode<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n\n\t\treturn Tree;\n\t}\n\n\t/**\n\t * Portion of a string with formatting.\n\t * @privateRemarks\n\t * This is implemented {@link StringAtom}, but we avoid leaking the fact this is a TreeNode in the API surface to\n\t * preserve more future flexibility.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface FormattedAtom<TFormat, TText> {\n\t\t/**\n\t\t * Content which is formatted.\n\t\t */\n\t\treadonly content: TText;\n\t\t/**\n\t\t * Formatting which is applied to the content.\n\t\t * @remarks\n\t\t * Can be reassigned or deeply mutated to edit the formatting of the content.\n\t\t */\n\t\tformat: TFormat;\n\t}\n\n\t/**\n\t * Portion of a string.\n\t * @remarks\n\t * Additional kinds of text atoms (also known as embedded objects) which can occur inside a string can implement this.\n\t * The schema for them can then be provided to {@link FormattedText.createSchema}.\n\t * @alpha\n\t */\n\texport interface TextAtom {\n\t\t/**\n\t\t * The content of the text atom, viewed as a string.\n\t\t */\n\t\treadonly content: string;\n\t}\n\n\t/**\n\t * Static factory functions for {@link FormattedText.(StringTextAtom:variable)}.\n\t * @privateRemarks\n\t * We type-erase `StringTextAtom` and only provide these static factories for construction\n\t * to reduce the chance of someone accidentally creating a text atom for a string other than a single unicode code point.\n\t * 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.\n\t * 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.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface StringTextAtomStatics {\n\t\t/**\n\t\t * Creates an atom from exactly one Unicode code point.\n\t\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if `value` does not contain exactly one Unicode code character.\n\t\t */\n\t\tfromCharacter(value: string): StringTextAtom;\n\n\t\t/**\n\t\t * Creates one atom for each Unicode code point in `value`.\n\t\t */\n\t\tfromString(value: string): StringTextAtom[];\n\t}\n\n\t/**\n\t * Schema for a {@link FormattedText.(StringTextAtom:variable)} node.\n\t * @sealed\n\t * @alpha\n\t */\n\texport const StringTextAtom = eraseSchemaDetails<TextAtom, StringTextAtomStatics>()(\n\t\tStringTextAtomNode,\n\t);\n\n\t/**\n\t * Node for the {@link FormattedText.(StringTextAtom:variable)} schema.\n\t * @sealed\n\t * @alpha\n\t */\n\texport type StringTextAtom = ErasedNode<\n\t\tTextAtom,\n\t\t\"com.fluidframework.text.formatted.StringTextAtom\"\n\t>;\n\n\t/**\n\t * Statics for formatted text nodes.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface Statics<TTree, FormatSchema extends ImplicitAllowedTypes> {\n\t\t/**\n\t\t * Construct a node of `this` schema from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(\n\t\t\tvalue: string,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): TTree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedText.Statics.fromString} for construction.\n\t * @see {@link FormattedText.createSchema} for creating schemas whose nodes implement this.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface Members<\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> extends PlainText.Members {\n\t\t/**\n\t\t * {@link PlainText.Members.insertAt} with optional formatting to apply to all additional characters,\n\t\t * and allowing an array of atoms instead of a string.\n\t\t * @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedText.createSchema}) will be used.\n\t\t * @remarks\n\t\t * Use {@link FormattedText.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.\n\t\t * @override\n\t\t */\n\t\tinsertAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters:\n\t\t\t\t| string\n\t\t\t\t| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Gets an array type view of the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t *\n\t\t * For more efficient access, use {@link FormattedText.Members.getUniformRun} and {@link FormattedText.Members.getString} to access ranges of characters\n\t\t * to avoid having to inspect the formatting on every atom.\n\t\t * @privateRemarks\n\t\t * Currently this is implemented by a node and changes with the text over time.\n\t\t * We might not want to leak a node like this in the API.\n\t\t * Providing a way to index and iterate separately might be better.\n\t\t */\n\t\tcharactersWithFormatting(): readonly FormattedAtom<\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\tTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>\n\t\t>[];\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedText.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<\n\t\t\t\tFormattedAtomInsertable<\n\t\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>\n\t\t\t\t>\n\t\t\t>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t * For each atom, every property of `format` will be cloned and assigned to the atom's format's corresponding subtree, overwriting any existing values for those properties.\n\t\t * All enumerable own properties of `format` will be applied, including those with `undefined` values.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t * This edits existing formatting subtrees on each atom, and only works when those atoms are object nodes.\n\t\t *\n\t\t * This is typically used to set some formatting property, like `bold` on a range of text without impacting other formatting properties.\n\t\t * @privateRemarks\n\t\t * This API is designed such that it can be optimized and improved in the future in a few different ways:\n\t\t * 1. TODO: It can be optimized to use lower level APIs directly, bypassing the overhead of the public API surface.\n\t\t * 2. TODO: A lower level editing API could be introduced and used to more efficiently express the edit (for example a bulk edit based on path, or a way to reuse the inserted content in multiple places instead of having to clone it before making the edit).\n\t\t * 3. TODO: Optimize the encoding of such edits, either with a dedicated format for range edits like this and/or encoding optimizations that can compress such edits over ranges to O(1) space.\n\t\t * 4. TODO: Preserve the range editing semantics through the whole stack to allow for better merge behavior, and make optimizations easier.\n\t\t */\n\t\tformatRange(\n\t\t\tstartIndex: number | undefined,\n\t\t\tendIndex: number | undefined,\n\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Replace formatting of a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to replace the formatting of the indicated range with.\n\t\t * For each atom, `format` will be cloned and assigned to the atom's format, overwriting any existing formatting.\n\t\t * If not specified the `defaultFormat` from {@link FormattedText.createSchema} will be used.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t *\n\t\t * This is typically used to normalize formatting, like resetting the formatting of a range to default settings.\n\t\t * @privateRemarks\n\t\t * See notes on {@link FormattedText.Members.formatRange} for future optimization opportunities.\n\t\t */\n\t\treformat(\n\t\t\tstartIndex?: number | undefined,\n\t\t\tendIndex?: number | undefined,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Returns the length of the run of characters starting at `startIndex` which have the same formatting and atom type, up to `endIndex`.\n\t\t * @param startIndex - The starting index of the run.\n\t\t * @param endIndex - The ending index (exclusive) of the run. Defaults to the end of the text.\n\t\t */\n\t\tgetUniformRun(startIndex: number, endIndex?: number): number;\n\t\t/**\n\t\t * Returns a substring of the text from `startIndex` to `endIndex`\n\t\t * @param startIndex - starting index (inclusive)\n\t\t * @param endIndex - Optional ending index (exclusive). Defaults to the end of the text.\n\t\t */\n\t\tgetString(startIndex: number, endIndex?: number): string;\n\n\t\t/**\n\t\t * Subscribe to all content changes on this text node, including both shallow\n\t\t * changes (inserts/removes) and deep changes (formatting updates on existing characters).\n\t\t * @param callback - Called after each change with a sequence of {@link PlainText.TextOp}s describing what changed,\n\t\t * or `undefined` when a delta could not be computed (e.g. during a schema upgrade).\n\t\t * @returns A cleanup function that unsubscribes the callback when called.\n\t\t * @remarks\n\t\t * Unlike {@link PlainText.Members.onCharactersChanged} which only fires on\n\t\t * shallow changes (inserts and removes), this method also fires on deep changes —\n\t\t * formatting property updates on existing characters.\n\t\t * The {@link PlainText.TextRetainOp.formattingChanged} flag on retain ops\n\t\t * indicates which character ranges had formatting updates.\n\t\t *\n\t\t * All counts in the delivered ops are in Unicode code points, not UTF-16 code units.\n\t\t * For characters outside the Basic Multilingual Plane (e.g. emoji), one code point\n\t\t * corresponds to two UTF-16 code units — convert before using the counts as string indices.\n\t\t */\n\t\tonContentChanged(\n\t\t\tcallback: (ops: readonly PlainText.TextOp[] | undefined) => void,\n\t\t): () => void;\n\t}\n\n\t/**\n\t * Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.\n\t * @input\n\t * @alpha\n\t */\n\texport interface FormattedAtomInsertable<TFormat, TContent> {\n\t\treadonly content: TContent;\n\t\treadonly format: TFormat;\n\t}\n\n\t/**\n\t * Schema identifier for the a generic formatted text schema.\n\t * @privateRemarks\n\t * Eventually this should probably be given a better name and/or made a system type in a system namespace.\n\t * @alpha\n\t */\n\texport type FormattedTextSchemaIdentifier<TUserScope extends string> = ScopedSchemaName<\n\t\t`com.fluidframework.text.formatted<${TUserScope}>`,\n\t\t\"Text\"\n\t>;\n\n\t/**\n\t * Helper for expressing the full set of text atoms for a given schema.\n\t * @remarks\n\t * This is just schema for the text atom {@link AllowedTypes},\n\t * and does not include the actual formatting (which is higher up in the tree).\n\t * @sealed\n\t * @alpha\n\t */\n\texport type TextAtomSchemas<\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = readonly [typeof StringTextAtom, ...ExtraAtomsSchema];\n\n\t/**\n\t * A generic type for a formatted text schema.\n\t * @sealed\n\t * @alpha\n\t */\n\texport type FormattedTextSchema<\n\t\tTUserScope extends string,\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = Statics<\n\t\tErasedNode<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>,\n\t\tFormatSchema\n\t> &\n\t\tErasedSchemaSubclassable<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n}\n"]}
@@ -3,20 +3,20 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { TreeNodeFromImplicitAllowedTypes, InsertableTreeNodeFromImplicitAllowedTypes } from "../simple-tree/index.js";
6
- import { FormattedTextAsTree } from "./textDomainFormatted.js";
6
+ import { FormattedText } from "./textDomainFormatted.js";
7
7
  /**
8
- * A default parameterization of the generic {@link FormattedTextAsTree} with hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
8
+ * 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.
9
9
  * @remarks
10
- * 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 FormattedTextAsTree}.
10
+ * 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}.
11
11
  * @internal
12
12
  */
13
- export declare namespace FormattedTextAsTreeDefault {
13
+ export declare namespace FormattedTextDefault {
14
14
  /**
15
15
  * Portion of a string with formatting.
16
16
  * @sealed
17
17
  * @internal
18
18
  */
19
- export type FormattedAtom = FormattedTextAsTree.FormattedAtom<CharacterFormat, StringAtomContent>;
19
+ export type FormattedAtom = FormattedText.FormattedAtom<CharacterFormat, StringAtomContent>;
20
20
  const CharacterFormat_base: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.CharacterFormat", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeObjectNode<{
21
21
  readonly bold: import("../simple-tree/leafNodeSchema.js").LeafSchema<"boolean", boolean>;
22
22
  readonly italic: import("../simple-tree/leafNodeSchema.js").LeafSchema<"boolean", boolean>;
@@ -66,8 +66,8 @@ export declare namespace FormattedTextAsTreeDefault {
66
66
  h4: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.h4" | "com.h4", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
67
67
  readonly value: "h4";
68
68
  }, Record<string, never>, true, Record<string, never>, undefined>;
69
- unchecked: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.unchecked" | "com.unchecked", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
70
- readonly value: "unchecked";
69
+ blockquote: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.blockquote" | "com.blockquote", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
70
+ readonly value: "blockquote";
71
71
  }, Record<string, never>, true, Record<string, never>, undefined>;
72
72
  h5: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.h5" | "com.h5", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
73
73
  readonly value: "h5";
@@ -81,8 +81,8 @@ export declare namespace FormattedTextAsTreeDefault {
81
81
  checked: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.checked" | "com.checked", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
82
82
  readonly value: "checked";
83
83
  }, Record<string, never>, true, Record<string, never>, undefined>;
84
- blockquote: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.blockquote" | "com.blockquote", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
85
- readonly value: "blockquote";
84
+ unchecked: import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.unchecked" | "com.unchecked", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
85
+ readonly value: "unchecked";
86
86
  }, Record<string, never>, true, Record<string, never>, undefined>;
87
87
  } & {
88
88
  readonly schema: [import("../simple-tree/index.js").TreeNodeSchemaClass<"com.fluidframework.text.formatted.default.lineTag.ol" | "com.ol", import("../simple-tree/index.js").NodeKind.Object, import("../simple-tree/index.js").TreeNode & {
@@ -110,7 +110,7 @@ export declare namespace FormattedTextAsTreeDefault {
110
110
  })];
111
111
  };
112
112
  /**
113
- * {@inheritdoc FormattedTextAsTreeDefault.(LineTag:variable)}
113
+ * {@inheritdoc FormattedTextDefault.(LineTag:variable)}
114
114
  * @sealed
115
115
  * @internal
116
116
  */
@@ -255,9 +255,9 @@ export declare namespace FormattedTextAsTreeDefault {
255
255
  * @sealed
256
256
  * @internal
257
257
  */
258
- export const StringAtomContent: readonly [FormattedTextAsTree.StringTextAtomStatics & import("../simple-tree/index.js").TreeNodeSchema<"com.fluidframework.text.formatted.StringTextAtom", import("../simple-tree/index.js").NodeKind, FormattedTextAsTree.TextAtom & import("../simple-tree/index.js").TreeNode & import("../simple-tree/index.js").WithType<"com.fluidframework.text.formatted.StringTextAtom", import("../simple-tree/index.js").NodeKind, unknown>, never, false>, typeof StringLineAtom];
258
+ export const StringAtomContent: readonly [FormattedText.StringTextAtomStatics & import("../simple-tree/index.js").TreeNodeSchema<"com.fluidframework.text.formatted.StringTextAtom", import("../simple-tree/index.js").NodeKind, FormattedText.TextAtom & import("../simple-tree/index.js").TreeNode & import("../simple-tree/index.js").WithType<"com.fluidframework.text.formatted.StringTextAtom", import("../simple-tree/index.js").NodeKind, unknown>, never, false>, typeof StringLineAtom];
259
259
  /**
260
- * {@inheritdoc FormattedTextAsTreeDefault.(StringAtomContent:variable)}
260
+ * {@inheritdoc FormattedTextDefault.(StringAtomContent:variable)}
261
261
  * @sealed
262
262
  * @internal
263
263
  */
@@ -267,13 +267,13 @@ export declare namespace FormattedTextAsTreeDefault {
267
267
  * @sealed
268
268
  * @internal
269
269
  */
270
- export type Statics<TTree = Tree> = FormattedTextAsTree.Statics<TTree, typeof CharacterFormat>;
270
+ export type Statics<TTree = Tree> = FormattedText.Statics<TTree, typeof CharacterFormat>;
271
271
  /**
272
- * Insertable shape for a formatted text atom used by {@link FormattedTextAsTree.Members.insertWithFormattingAt}.
272
+ * Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.
273
273
  * @sealed
274
274
  * @internal
275
275
  */
276
- export type FormattedAtomInsertable = FormattedTextAsTree.FormattedAtom<InsertableTreeNodeFromImplicitAllowedTypes<typeof CharacterFormat>, InsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas>>;
276
+ export type FormattedAtomInsertable = FormattedText.FormattedAtom<InsertableTreeNodeFromImplicitAllowedTypes<typeof CharacterFormat>, InsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas>>;
277
277
  /**
278
278
  * Helper for expressing the full set of formatted text atoms for a given schema.
279
279
  * @privateRemarks
@@ -281,10 +281,10 @@ export declare namespace FormattedTextAsTreeDefault {
281
281
  * @sealed
282
282
  * @internal
283
283
  */
284
- export type TextAtomSchemas = FormattedTextAsTree.TextAtomSchemas<[typeof StringLineAtom]>;
285
- const Tree_base: FormattedTextAsTree.FormattedTextSchema<"com.fluidframework.text.formatted.default", typeof CharacterFormat, readonly [typeof StringLineAtom]>;
284
+ export type TextAtomSchemas = FormattedText.TextAtomSchemas<[typeof StringLineAtom]>;
285
+ const Tree_base: FormattedText.FormattedTextSchema<"com.fluidframework.text.formatted.default", typeof CharacterFormat, readonly [typeof StringLineAtom]>;
286
286
  /**
287
- * The schema produced using {@link FormattedTextAsTree.createSchema} with hard-coded assumptions
287
+ * The schema produced using {@link FormattedText.createSchema} with hard-coded assumptions
288
288
  * about what kind of embedded content and what kind of formatting is supported.
289
289
  * @sealed
290
290
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"textDomainFormattedDefault.d.ts","sourceRoot":"","sources":["../../src/text/textDomainFormattedDefault.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,gCAAgC,EAChC,0CAA0C,EAC1C,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAe/D;;;;;GAKG;AACH,yBAAiB,0BAA0B,CAAC;IAC3C;;;;OAIG;IACH,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAC5D,eAAe,EACf,iBAAiB,CACjB,CAAC;;;;;;;;;;;;;;;;;;;;IAEF;;;;OAIG;IACH,MAAM,OAAO,eAAgB,SAAQ,oBAMnC;QACD,gBAAuB,aAAa,kBAAsC;KAC1E;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAYlB,CAAC;IACH;;;;OAIG;IACH,MAAM,MAAM,OAAO,GAAG,gCAAgC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE9E;;;;;;;;;;;OAWG;IACH,MAAM,OAAO,cAAe,SAAQ,mBAGlC;QACD,SAAgB,OAAO,QAAQ;KAC/B;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,iBAAiB,+cAGpB,CAAC;IACX;;;;OAIG;IACH,MAAM,MAAM,iBAAiB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE9E;;;;;;;;;;;OAWG;IACH,MAAM,OAAO,cAAe,SAAQ,mBAGlC;QACD,SAAgB,OAAO,QAAQ;KAC/B;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,iBAAiB,mcAA0D,CAAC;IACzF;;;;OAIG;IACH,MAAM,MAAM,iBAAiB,GAAG,gCAAgC,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAE3F;;;;OAIG;IACH,MAAM,MAAM,OAAO,CAAC,KAAK,GAAG,IAAI,IAAI,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,eAAe,CAAC,CAAC;IAEzF;;;;OAIG;IACH,MAAM,MAAM,uBAAuB,GAAG,aAAa,CAAC,aAAa,CAChE,0CAA0C,CAAC,OAAO,eAAe,CAAC,EAClE,0CAA0C,CAAC,eAAe,CAAC,CAC3D,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC;;IAErF;;;;;OAKG;IACH,MAAM,OAAO,IAAK,SAAQ,SAKzB;KAAG;;CACJ"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FormattedTextAsTreeDefault = void 0;
7
+ exports.FormattedTextDefault = void 0;
8
8
  const index_js_1 = require("../simple-tree/index.js");
9
9
  const textDomainFormatted_js_1 = require("./textDomainFormatted.js");
10
10
  /**
@@ -19,13 +19,13 @@ const defaultFormat = {
19
19
  font: "Arial",
20
20
  };
21
21
  /**
22
- * A default parameterization of the generic {@link FormattedTextAsTree} with hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
22
+ * 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.
23
23
  * @remarks
24
- * 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 FormattedTextAsTree}.
24
+ * 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}.
25
25
  * @internal
26
26
  */
27
- var FormattedTextAsTreeDefault;
28
- (function (FormattedTextAsTreeDefault) {
27
+ var FormattedTextDefault;
28
+ (function (FormattedTextDefault) {
29
29
  /**
30
30
  * Formatting options for characters.
31
31
  * @sealed
@@ -40,12 +40,12 @@ var FormattedTextAsTreeDefault;
40
40
  }) {
41
41
  }
42
42
  CharacterFormat.defaultFormat = new CharacterFormat(defaultFormat);
43
- FormattedTextAsTreeDefault.CharacterFormat = CharacterFormat;
43
+ FormattedTextDefault.CharacterFormat = CharacterFormat;
44
44
  /**
45
45
  * Tag with which a line in text can be formatted from HTML.
46
46
  * @internal
47
47
  */
48
- FormattedTextAsTreeDefault.LineTag = (0, index_js_1.enumFromStrings)(sf.scopedFactory("lineTag"), [
48
+ FormattedTextDefault.LineTag = (0, index_js_1.enumFromStrings)(sf.scopedFactory("lineTag"), [
49
49
  "h1",
50
50
  "h2",
51
51
  "h3",
@@ -71,7 +71,7 @@ var FormattedTextAsTreeDefault;
71
71
  * @internal
72
72
  */
73
73
  class StringLineAtom extends sf.object("StringLineAtom", {
74
- tag: FormattedTextAsTreeDefault.LineTag.schema,
74
+ tag: FormattedTextDefault.LineTag.schema,
75
75
  indent: index_js_1.SchemaFactory.number,
76
76
  }) {
77
77
  constructor() {
@@ -79,24 +79,21 @@ var FormattedTextAsTreeDefault;
79
79
  this.content = "\n";
80
80
  }
81
81
  }
82
- FormattedTextAsTreeDefault.StringLineAtom = StringLineAtom;
82
+ FormattedTextDefault.StringLineAtom = StringLineAtom;
83
83
  /**
84
84
  * Types of "atoms" that make up the text.
85
85
  * @sealed
86
86
  * @internal
87
87
  */
88
- FormattedTextAsTreeDefault.StringAtomContent = [
89
- textDomainFormatted_js_1.FormattedTextAsTree.StringTextAtom,
90
- StringLineAtom,
91
- ];
88
+ FormattedTextDefault.StringAtomContent = [textDomainFormatted_js_1.FormattedText.StringTextAtom, StringLineAtom];
92
89
  /**
93
- * The schema produced using {@link FormattedTextAsTree.createSchema} with hard-coded assumptions
90
+ * The schema produced using {@link FormattedText.createSchema} with hard-coded assumptions
94
91
  * about what kind of embedded content and what kind of formatting is supported.
95
92
  * @sealed
96
93
  * @internal
97
94
  */
98
- class Tree extends textDomainFormatted_js_1.FormattedTextAsTree.createSchema(sf, CharacterFormat, [StringLineAtom], defaultFormat) {
95
+ class Tree extends textDomainFormatted_js_1.FormattedText.createSchema(sf, CharacterFormat, [StringLineAtom], defaultFormat) {
99
96
  }
100
- FormattedTextAsTreeDefault.Tree = Tree;
101
- })(FormattedTextAsTreeDefault || (exports.FormattedTextAsTreeDefault = FormattedTextAsTreeDefault = {}));
97
+ FormattedTextDefault.Tree = Tree;
98
+ })(FormattedTextDefault || (exports.FormattedTextDefault = FormattedTextDefault = {}));
102
99
  //# sourceMappingURL=textDomainFormattedDefault.js.map