@fluidframework/tree 2.113.1 → 2.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/api-report/tree.alpha.api.md +19 -0
- package/dist/core/change-family/changeFamily.d.ts +15 -4
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/change-family/editBuilder.d.ts +2 -3
- package/dist/core/change-family/editBuilder.d.ts.map +1 -1
- package/dist/core/change-family/editBuilder.js +1 -2
- package/dist/core/change-family/editBuilder.js.map +1 -1
- package/dist/core/change-family/index.d.ts +1 -1
- package/dist/core/change-family/index.d.ts.map +1 -1
- package/dist/core/change-family/index.js.map +1 -1
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/tree/delta.d.ts +62 -16
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +7 -13
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +32 -46
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -0
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +2 -4
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +2 -2
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/entrypoints/alpha.d.ts +1 -1
- package/dist/entrypoints/alpha.d.ts.map +1 -1
- package/dist/entrypoints/alpha.js +5 -2
- package/dist/entrypoints/alpha.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +10 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
- package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
- package/dist/feature-libraries/comparison-forest/comparisonForest.js +98 -0
- package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
- package/dist/feature-libraries/comparison-forest/index.d.ts +6 -0
- package/dist/feature-libraries/comparison-forest/index.d.ts.map +1 -0
- package/dist/feature-libraries/comparison-forest/index.js +10 -0
- package/dist/feature-libraries/comparison-forest/index.js.map +1 -0
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.js +3 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +18 -6
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +4 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +77 -72
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +12 -0
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/invert.d.ts +15 -0
- package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/invert.js +159 -0
- package/dist/feature-libraries/modular-schema/invert.js.map +1 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +53 -406
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
- package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeUtils.js +205 -0
- package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
- package/dist/feature-libraries/modular-schema/prune.d.ts +10 -0
- package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/prune.js +49 -0
- package/dist/feature-libraries/modular-schema/prune.js.map +1 -0
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/treeTextCursor.d.ts +15 -0
- package/dist/feature-libraries/treeTextCursor.d.ts.map +1 -1
- package/dist/feature-libraries/treeTextCursor.js +64 -1
- package/dist/feature-libraries/treeTextCursor.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/serializedChange.d.ts +2 -2
- package/dist/shared-tree/serializedChange.d.ts.map +1 -1
- package/dist/shared-tree/serializedChange.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +6 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +8 -6
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +57 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
- package/dist/shared-tree/transactionMinimize.js +2 -2
- package/dist/shared-tree/transactionMinimize.js.map +1 -1
- package/dist/shared-tree/transactionPostProcessor.d.ts +2 -1
- package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -1
- package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +8 -7
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +23 -9
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +7 -0
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +4 -4
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +2 -0
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -14
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +4 -4
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +0 -1
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +8 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +5 -5
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +10 -10
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +6 -3
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.js +15 -0
- package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +21 -2
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +9 -0
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/text/textDomain.d.ts +12 -0
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +37 -16
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +155 -61
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +147 -71
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/text/textDomainFormattedDefault.d.ts +37 -14
- package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
- package/dist/text/textDomainFormattedDefault.js +13 -5
- package/dist/text/textDomainFormattedDefault.js.map +1 -1
- package/dist/treeDataStore.d.ts +49 -0
- package/dist/treeDataStore.d.ts.map +1 -0
- package/dist/treeDataStore.js +57 -0
- package/dist/treeDataStore.js.map +1 -0
- package/dist/treeFactory.d.ts +8 -3
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +6 -1
- package/dist/treeFactory.js.map +1 -1
- package/lib/core/change-family/changeFamily.d.ts +15 -4
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/change-family/editBuilder.d.ts +2 -3
- package/lib/core/change-family/editBuilder.d.ts.map +1 -1
- package/lib/core/change-family/editBuilder.js +1 -2
- package/lib/core/change-family/editBuilder.js.map +1 -1
- package/lib/core/change-family/index.d.ts +1 -1
- package/lib/core/change-family/index.d.ts.map +1 -1
- package/lib/core/change-family/index.js.map +1 -1
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/tree/delta.d.ts +62 -16
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +7 -13
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +7 -21
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -0
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +2 -4
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +2 -2
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/entrypoints/alpha.d.ts +1 -1
- package/lib/entrypoints/alpha.d.ts.map +1 -1
- package/lib/entrypoints/alpha.js +1 -1
- package/lib/entrypoints/alpha.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +10 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
- package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
- package/lib/feature-libraries/comparison-forest/comparisonForest.js +94 -0
- package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
- package/lib/feature-libraries/comparison-forest/index.d.ts +6 -0
- package/lib/feature-libraries/comparison-forest/index.d.ts.map +1 -0
- package/lib/feature-libraries/comparison-forest/index.js +6 -0
- package/lib/feature-libraries/comparison-forest/index.js.map +1 -0
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.js +3 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +16 -4
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +4 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +12 -0
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/invert.d.ts +15 -0
- package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/invert.js +155 -0
- package/lib/feature-libraries/modular-schema/invert.js.map +1 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +16 -367
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
- package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeUtils.js +192 -0
- package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
- package/lib/feature-libraries/modular-schema/prune.d.ts +10 -0
- package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/prune.js +45 -0
- package/lib/feature-libraries/modular-schema/prune.js.map +1 -0
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/treeTextCursor.d.ts +15 -0
- package/lib/feature-libraries/treeTextCursor.d.ts.map +1 -1
- package/lib/feature-libraries/treeTextCursor.js +62 -1
- package/lib/feature-libraries/treeTextCursor.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/serializedChange.d.ts +2 -2
- package/lib/shared-tree/serializedChange.d.ts.map +1 -1
- package/lib/shared-tree/serializedChange.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +6 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +9 -7
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +55 -0
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
- package/lib/shared-tree/transactionMinimize.js +3 -3
- package/lib/shared-tree/transactionMinimize.js.map +1 -1
- package/lib/shared-tree/transactionPostProcessor.d.ts +2 -1
- package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -1
- package/lib/shared-tree/transactionPostProcessor.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +8 -7
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +1 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +23 -9
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +7 -0
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +4 -4
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +2 -0
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -14
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +4 -4
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +0 -1
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +8 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +5 -5
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +10 -10
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +6 -3
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.js +15 -0
- package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +21 -2
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +9 -0
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/text/textDomain.d.ts +12 -0
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +34 -15
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +155 -61
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +148 -73
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/text/textDomainFormattedDefault.d.ts +37 -14
- package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
- package/lib/text/textDomainFormattedDefault.js +14 -6
- package/lib/text/textDomainFormattedDefault.js.map +1 -1
- package/lib/treeDataStore.d.ts +49 -0
- package/lib/treeDataStore.d.ts.map +1 -0
- package/lib/treeDataStore.js +52 -0
- package/lib/treeDataStore.js.map +1 -0
- package/lib/treeFactory.d.ts +8 -3
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +5 -0
- package/lib/treeFactory.js.map +1 -1
- package/package.json +25 -24
- package/src/core/change-family/changeFamily.ts +32 -4
- package/src/core/change-family/editBuilder.ts +1 -2
- package/src/core/change-family/index.ts +2 -0
- package/src/core/index.ts +9 -6
- package/src/core/tree/delta.ts +62 -16
- package/src/core/tree/detachedFieldIndex.ts +7 -38
- package/src/core/tree/index.ts +2 -0
- package/src/core/tree/visitorUtils.ts +3 -17
- package/src/entrypoints/alpha.ts +7 -3
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +11 -1
- package/src/feature-libraries/comparison-forest/comparisonForest.ts +140 -0
- package/src/feature-libraries/comparison-forest/index.ts +6 -0
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +20 -6
- package/src/feature-libraries/default-schema/index.ts +1 -0
- package/src/feature-libraries/default-schema/noChangeCodecs.ts +11 -3
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +33 -5
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -3
- package/src/feature-libraries/index.ts +5 -0
- package/src/feature-libraries/mitigatedChangeFamily.ts +21 -3
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -1
- package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +9 -4
- package/src/feature-libraries/modular-schema/index.ts +1 -0
- package/src/feature-libraries/modular-schema/invert.ts +338 -0
- package/src/feature-libraries/modular-schema/minimizeModularChange.ts +3 -5
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +16 -13
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +3 -1
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +2 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +45 -644
- package/src/feature-libraries/modular-schema/modularChangeUtils.ts +340 -0
- package/src/feature-libraries/modular-schema/prune.ts +69 -0
- package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +4 -2
- package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +6 -3
- package/src/feature-libraries/treeTextCursor.ts +66 -1
- package/src/index.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/serializedChange.ts +2 -2
- package/src/shared-tree/sharedTree.ts +34 -14
- package/src/shared-tree/sharedTreeChangeCodecs.ts +11 -3
- package/src/shared-tree/sharedTreeChangeFamily.ts +77 -2
- package/src/shared-tree/transactionMinimize.ts +7 -3
- package/src/shared-tree/transactionPostProcessor.ts +5 -1
- package/src/shared-tree/treeCheckout.ts +55 -16
- package/src/shared-tree-core/branch.ts +40 -12
- package/src/shared-tree-core/editManager.ts +46 -25
- package/src/shared-tree-core/editManagerCodecs.ts +9 -21
- package/src/shared-tree-core/editManagerCodecsCommons.ts +14 -2
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +18 -21
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +18 -20
- package/src/shared-tree-core/editManagerSummarizer.ts +9 -6
- package/src/shared-tree-core/messageCodecV1ToV4.ts +3 -3
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -2
- package/src/shared-tree-core/messageCodecs.ts +12 -2
- package/src/shared-tree-core/sharedTreeCore.ts +15 -6
- package/src/shared-tree-core/transaction.ts +47 -25
- package/src/simple-tree/api/eraseSchemaDetails.ts +15 -0
- package/src/simple-tree/node-kinds/array/arrayNode.ts +21 -2
- package/src/simple-tree/node-kinds/map/mapNode.ts +24 -2
- package/src/text/textDomain.ts +29 -6
- package/src/text/textDomainFormatted.ts +351 -134
- package/src/text/textDomainFormattedDefault.ts +25 -16
- package/src/treeDataStore.ts +125 -0
- package/src/treeFactory.ts +11 -3
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
TreeArrayNode,
|
|
23
23
|
TreeBeta,
|
|
24
24
|
createCustomizedFluidFrameworkScopedFactory,
|
|
25
|
+
eraseSchemaDetails,
|
|
25
26
|
isObjectNodeSchema,
|
|
26
27
|
eraseSchemaDetailsSubclassable,
|
|
27
28
|
} from "../simple-tree/index.js";
|
|
@@ -41,10 +42,17 @@ import type {
|
|
|
41
42
|
ErasedNode,
|
|
42
43
|
SchemaFactoryBeta,
|
|
43
44
|
} from "../simple-tree/index.js";
|
|
44
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
brand,
|
|
47
|
+
mapIterable,
|
|
48
|
+
oneFromIterable,
|
|
49
|
+
validateIndex,
|
|
50
|
+
validateIndexRange,
|
|
51
|
+
} from "../util/index.js";
|
|
45
52
|
|
|
46
53
|
import {
|
|
47
54
|
charactersFromString,
|
|
55
|
+
expensiveInternalValidationAssert,
|
|
48
56
|
processCharactersChangedDelta,
|
|
49
57
|
type TextAsTree,
|
|
50
58
|
} from "./textDomain.js";
|
|
@@ -67,6 +75,44 @@ const sfStatic = new SchemaFactoryAlpha("com.fluidframework.text.formatted");
|
|
|
67
75
|
|
|
68
76
|
const formatKey: FieldKey = brand("format");
|
|
69
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Atom in the string containing a single character.
|
|
80
|
+
* @privateRemarks
|
|
81
|
+
* This is outside the namespace so it can be exported for testing, but not package exported.
|
|
82
|
+
*/
|
|
83
|
+
export class StringTextAtomNode
|
|
84
|
+
extends sfStatic.object("StringTextAtom", {
|
|
85
|
+
/**
|
|
86
|
+
* The underlying text content of this atom.
|
|
87
|
+
* @remarks
|
|
88
|
+
* This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.
|
|
89
|
+
* Longer strings are still valid. For example, users might store whole grapheme clusters here, or even longer sections of text.
|
|
90
|
+
* Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.
|
|
91
|
+
* Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.
|
|
92
|
+
* Instead, atoms should always be the smallest unit of text which will be independently selected, moved or formatted.
|
|
93
|
+
* @privateRemarks
|
|
94
|
+
* This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.
|
|
95
|
+
*/
|
|
96
|
+
content: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),
|
|
97
|
+
})
|
|
98
|
+
implements FormattedTextAsTree.TextAtom
|
|
99
|
+
{
|
|
100
|
+
public static fromCharacter(value: string): StringTextAtomNode {
|
|
101
|
+
const character = oneFromIterable(charactersFromString(value));
|
|
102
|
+
if (character === undefined) {
|
|
103
|
+
throw new UsageError("value must contain exactly one Unicode character.");
|
|
104
|
+
}
|
|
105
|
+
return new StringTextAtomNode({ content: character });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public static fromString(value: string): StringTextAtomNode[] {
|
|
109
|
+
return Array.from(
|
|
110
|
+
charactersFromString(value),
|
|
111
|
+
(character) => new StringTextAtomNode({ content: character }),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
70
116
|
/**
|
|
71
117
|
* A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
|
|
72
118
|
* @remarks
|
|
@@ -80,7 +126,23 @@ const formatKey: FieldKey = brand("format");
|
|
|
80
126
|
*/
|
|
81
127
|
export namespace FormattedTextAsTree {
|
|
82
128
|
/**
|
|
83
|
-
*
|
|
129
|
+
* Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.
|
|
130
|
+
*
|
|
131
|
+
* @param inputSchemaFactory - The {@link SchemaFactoryBeta} used to scope the generated schema.
|
|
132
|
+
* The generated types are scoped under `com.fluidframework.text.formatted<TUserScope>`, where `TUserScope` is the scope of this factory.
|
|
133
|
+
* This scope is used to distinguish different usages of `createSchema` from each-other, and must be kept the same between versions for nodes to remain compatible.
|
|
134
|
+
* It must be different to distinguish different formatted text schema within the same document.
|
|
135
|
+
* @param formatSchema - Schema describing the formatting associated with each atom of text.
|
|
136
|
+
* Use an {@link NodeKind.Object|Object node} to support {@link FormattedTextAsTree.Members.formatRange}.
|
|
137
|
+
* @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)}.
|
|
138
|
+
* Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.
|
|
139
|
+
* @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs
|
|
140
|
+
* (for example {@link FormattedTextAsTree.Members.insertAt} and {@link FormattedTextAsTree.Statics.fromString} when no explicit format is provided).
|
|
141
|
+
* @returns The schema for the formatted text node, whose nodes implement {@link FormattedTextAsTree.Members} and whose statics implement {@link FormattedTextAsTree.Statics}.
|
|
142
|
+
* @remarks
|
|
143
|
+
* See {@link FormattedTextAsTreeDefault} for a default parameterization of this factory.
|
|
144
|
+
* @privateRemarks
|
|
145
|
+
* TODO: The choice to always include the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
|
|
84
146
|
*/
|
|
85
147
|
export function createSchema<
|
|
86
148
|
const TUserScope extends string,
|
|
@@ -95,21 +157,60 @@ export namespace FormattedTextAsTree {
|
|
|
95
157
|
defaultFormatInsertable: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
96
158
|
): FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema> {
|
|
97
159
|
const atoms = [StringTextAtom, ...extraAtoms] as const;
|
|
160
|
+
/**
|
|
161
|
+
* The type of a text atom node, which goes in a StringAtom.
|
|
162
|
+
*/
|
|
163
|
+
type TextAtomNode = TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>;
|
|
98
164
|
|
|
99
165
|
const sf = createFormattedScopedFactory(inputSchemaFactory);
|
|
166
|
+
|
|
167
|
+
const defaultFormat: TreeFieldFromImplicitField<FormatSchema> =
|
|
168
|
+
TreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable);
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Gets a format node, which must be cloned before being inserted.
|
|
172
|
+
*/
|
|
173
|
+
function getFormatNode(
|
|
174
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
175
|
+
): TreeFieldFromImplicitField<FormatSchema> {
|
|
176
|
+
// Note we cannot use the `format ?? defaultFormat` syntax as format is allowed to be `null`.
|
|
177
|
+
return format === undefined
|
|
178
|
+
? defaultFormat
|
|
179
|
+
: TreeBeta.create<FormatSchema>(formatSchema, format);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function cloneFormat(
|
|
183
|
+
format: TreeFieldFromImplicitField<FormatSchema>,
|
|
184
|
+
): TreeFieldFromImplicitField<FormatSchema> &
|
|
185
|
+
TreeNodeFromImplicitAllowedTypes<FormatSchema> {
|
|
186
|
+
const clone: TreeFieldFromImplicitField<FormatSchema> =
|
|
187
|
+
TreeBeta.clone<FormatSchema>(format);
|
|
188
|
+
// TypeScript fails to prove that cloning a node gives a node, and not possible undefined (like cloning a empty field could).
|
|
189
|
+
// This cast helps users of this function get the types they need.
|
|
190
|
+
return clone as typeof clone & TreeNodeFromImplicitAllowedTypes<FormatSchema>;
|
|
191
|
+
}
|
|
192
|
+
|
|
100
193
|
class TextNode
|
|
101
194
|
extends sf.object("Text", {
|
|
102
195
|
content: SchemaFactory.required([() => StringArray], { key: EmptyKey }),
|
|
103
196
|
})
|
|
104
|
-
implements
|
|
197
|
+
implements Members<FormatSchema, ExtraAtomsSchema>
|
|
105
198
|
{
|
|
106
|
-
public
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
199
|
+
public insertAt(
|
|
200
|
+
index: number,
|
|
201
|
+
additionalCharacters:
|
|
202
|
+
| string
|
|
203
|
+
| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,
|
|
204
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
205
|
+
): void {
|
|
206
|
+
const newAtoms: Iterable<TextAtomNode> =
|
|
207
|
+
typeof additionalCharacters === "string"
|
|
208
|
+
? stringTextAtomsFromString(additionalCharacters)
|
|
209
|
+
: additionalCharacters;
|
|
210
|
+
const formatNode = getFormatNode(format);
|
|
110
211
|
this.content.insertAt(
|
|
111
212
|
index,
|
|
112
|
-
TreeArrayNode.spread(
|
|
213
|
+
TreeArrayNode.spread(stringAtomsFromTextAtoms(newAtoms, formatNode)),
|
|
113
214
|
);
|
|
114
215
|
}
|
|
115
216
|
|
|
@@ -123,9 +224,9 @@ export namespace FormattedTextAsTree {
|
|
|
123
224
|
|
|
124
225
|
public charactersCopy(): string[] {
|
|
125
226
|
const result = this.content.charactersCopy();
|
|
126
|
-
|
|
227
|
+
expensiveInternalValidationAssert(
|
|
127
228
|
() =>
|
|
128
|
-
compareArrays(result, this
|
|
229
|
+
compareArrays(result, this.#charactersCopy_reference()) ||
|
|
129
230
|
"invalid charactersCopy optimizations",
|
|
130
231
|
);
|
|
131
232
|
return result;
|
|
@@ -137,8 +238,8 @@ export namespace FormattedTextAsTree {
|
|
|
137
238
|
|
|
138
239
|
public fullString(): string {
|
|
139
240
|
const result = this.content.fullString();
|
|
140
|
-
|
|
141
|
-
() => result === this
|
|
241
|
+
expensiveInternalValidationAssert(
|
|
242
|
+
() => result === this.#fullString_reference() || "invalid fullString optimizations",
|
|
142
243
|
);
|
|
143
244
|
return result;
|
|
144
245
|
}
|
|
@@ -146,31 +247,29 @@ export namespace FormattedTextAsTree {
|
|
|
146
247
|
/**
|
|
147
248
|
* A non-optimized reference implementation of fullString.
|
|
148
249
|
*/
|
|
149
|
-
|
|
250
|
+
#fullString_reference(): string {
|
|
150
251
|
return [...this.characters()].join("");
|
|
151
252
|
}
|
|
152
253
|
|
|
153
254
|
/**
|
|
154
255
|
* Unoptimized trivially correct implementation of charactersCopy.
|
|
155
256
|
*/
|
|
156
|
-
|
|
257
|
+
#charactersCopy_reference(): string[] {
|
|
157
258
|
return [...this.characters()];
|
|
158
259
|
}
|
|
159
260
|
|
|
160
261
|
public static fromString(
|
|
161
262
|
value: string,
|
|
162
|
-
format?:
|
|
263
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
163
264
|
): TextNode {
|
|
265
|
+
const formatNode = getFormatNode(format);
|
|
164
266
|
// Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.
|
|
165
267
|
return new this({
|
|
166
268
|
content: [
|
|
167
269
|
// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,
|
|
168
270
|
// 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.
|
|
169
271
|
// Thus the array construction here is necessary to avoid a runtime error.
|
|
170
|
-
...textAtomsFromString(
|
|
171
|
-
value,
|
|
172
|
-
format ?? TreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable),
|
|
173
|
-
),
|
|
272
|
+
...textAtomsFromString(value, formatNode),
|
|
174
273
|
],
|
|
175
274
|
});
|
|
176
275
|
}
|
|
@@ -190,21 +289,77 @@ export namespace FormattedTextAsTree {
|
|
|
190
289
|
end: number | undefined,
|
|
191
290
|
format: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,
|
|
192
291
|
): void {
|
|
193
|
-
const
|
|
194
|
-
validateIndex(formatStart, this.content, "FormattedTextAsTree.formatRange", true);
|
|
195
|
-
|
|
196
|
-
const formatEnd = Math.min(this.content.length, end ?? this.content.length);
|
|
197
|
-
validateIndexRange(
|
|
198
|
-
formatStart,
|
|
199
|
-
formatEnd,
|
|
200
|
-
this.content,
|
|
201
|
-
"FormattedTextAsTree.formatRange",
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const fieldFormats = Object.entries(format) as [
|
|
292
|
+
const fieldFormatsRaw = Object.entries(format) as [
|
|
205
293
|
keyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
206
294
|
unknown,
|
|
207
295
|
][];
|
|
296
|
+
const fieldFormats = fieldFormatsRaw.map(([key, value]) => {
|
|
297
|
+
// Object.entries should only return string keyed enumerable own properties.
|
|
298
|
+
// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
|
|
299
|
+
assert(
|
|
300
|
+
typeof key === "string",
|
|
301
|
+
0xcc8 /* Object.entries returned a non-string key. */,
|
|
302
|
+
);
|
|
303
|
+
return [key, value] as const;
|
|
304
|
+
});
|
|
305
|
+
this.#editRange(start, end, "FormattedTextAsTree.formatRange", (atom) => {
|
|
306
|
+
const formatNode: TreeNode | TreeValue = atom.format;
|
|
307
|
+
const atomFormatSchema = TreeStatic.schema(formatNode);
|
|
308
|
+
if (!isObjectNodeSchema(atomFormatSchema)) {
|
|
309
|
+
throw new UsageError(
|
|
310
|
+
"formatRange currently only supports object nodes for the format.",
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
for (const [key, value] of fieldFormats) {
|
|
314
|
+
const field = atomFormatSchema.fields.get(key);
|
|
315
|
+
if (field === undefined) {
|
|
316
|
+
throw new UsageError(`Unknown format key: ${key}`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Ensures that if the input is a node, it is cloned before being inserted into the tree.
|
|
320
|
+
// Note that since this uses field schema, `undefined` can pass through this if allowed by the schema.
|
|
321
|
+
const clonedValue = TreeBeta.clone(TreeBeta.create(field, value as never)) as
|
|
322
|
+
| TreeNode
|
|
323
|
+
| TreeValue;
|
|
324
|
+
|
|
325
|
+
(
|
|
326
|
+
formatNode as unknown as Record<
|
|
327
|
+
keyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
328
|
+
TreeNode | TreeValue
|
|
329
|
+
>
|
|
330
|
+
)[key] = clonedValue;
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public reformat(
|
|
336
|
+
start: number | undefined,
|
|
337
|
+
end: number | undefined,
|
|
338
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
339
|
+
): void {
|
|
340
|
+
const node = getFormatNode(format);
|
|
341
|
+
this.#editRange(start, end, "FormattedTextAsTree.reformat", (atom) => {
|
|
342
|
+
atom.format = cloneFormat(node);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Map an edit over a range of atoms, validating the range and running the edits in a transaction.
|
|
348
|
+
* @remarks
|
|
349
|
+
* This is not exposed in the API since this approach will have to be replaced when formatting is optimized,
|
|
350
|
+
* so we don't want users to directly depend on this un-optimizable layer.
|
|
351
|
+
*/
|
|
352
|
+
#editRange(
|
|
353
|
+
start: number | undefined,
|
|
354
|
+
end: number | undefined,
|
|
355
|
+
method: string,
|
|
356
|
+
edit: (atom: StringAtom) => void,
|
|
357
|
+
): void {
|
|
358
|
+
const formatStart = start ?? 0;
|
|
359
|
+
validateIndex(formatStart, this.content, method, true);
|
|
360
|
+
|
|
361
|
+
const formatEnd = Math.min(this.content.length, end ?? this.content.length);
|
|
362
|
+
validateIndexRange(formatStart, formatEnd, this.content, method);
|
|
208
363
|
|
|
209
364
|
TreeAlpha.context(this).runTransaction(() => {
|
|
210
365
|
for (let i = formatStart; i < formatEnd; i++) {
|
|
@@ -214,39 +369,7 @@ export namespace FormattedTextAsTree {
|
|
|
214
369
|
atom !== undefined,
|
|
215
370
|
0xd08 /* Index out of bounds while formatting text range. */,
|
|
216
371
|
);
|
|
217
|
-
|
|
218
|
-
const atomFormatSchema = TreeStatic.schema(formatNode);
|
|
219
|
-
if (!isObjectNodeSchema(atomFormatSchema)) {
|
|
220
|
-
// TODO: redesign this API to work with all allowed FormatSchema types.
|
|
221
|
-
throw new UsageError(
|
|
222
|
-
"formatRange currently only supports object nodes for the format.",
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
for (const [key, value] of fieldFormats) {
|
|
226
|
-
// Object.entries should only return string keyed enumerable own properties.
|
|
227
|
-
// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
|
|
228
|
-
assert(
|
|
229
|
-
typeof key === "string",
|
|
230
|
-
0xcc8 /* Object.entries returned a non-string key. */,
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
const field = atomFormatSchema.fields.get(key);
|
|
234
|
-
if (field === undefined) {
|
|
235
|
-
throw new UsageError(`Unknown format key: ${key}`);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Ensures that if the input is a node, it is cloned before being inserted into the tree.
|
|
239
|
-
const clonedValue = TreeBeta.clone(TreeBeta.create(field, value as never)) as
|
|
240
|
-
| TreeNode
|
|
241
|
-
| TreeValue;
|
|
242
|
-
|
|
243
|
-
(
|
|
244
|
-
formatNode as unknown as Record<
|
|
245
|
-
keyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
246
|
-
TreeNode | TreeValue
|
|
247
|
-
>
|
|
248
|
-
)[key] = clonedValue;
|
|
249
|
-
}
|
|
372
|
+
edit(atom);
|
|
250
373
|
}
|
|
251
374
|
});
|
|
252
375
|
}
|
|
@@ -293,21 +416,36 @@ export namespace FormattedTextAsTree {
|
|
|
293
416
|
}
|
|
294
417
|
}
|
|
295
418
|
|
|
296
|
-
function
|
|
419
|
+
function stringTextAtomsFromString(
|
|
297
420
|
value: string,
|
|
421
|
+
): Iterable<StringTextAtom & TextAtomNode> {
|
|
422
|
+
// TypeScript can't prove in this Generic context that StringTextAtom is assignable to TextAtomNode, so we have to cast.
|
|
423
|
+
// Since TextAtomSchemas unconditionally includes StringTextAtom, this cast is safe.
|
|
424
|
+
return StringTextAtom.fromString(value) as (StringTextAtom & TextAtomNode)[];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function stringAtomsFromTextAtoms(
|
|
428
|
+
value: Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,
|
|
298
429
|
format: TreeFieldFromImplicitField<FormatSchema>,
|
|
299
430
|
): Iterable<StringAtom> {
|
|
300
|
-
const result = mapIterable(
|
|
301
|
-
const textAtom = new StringTextAtom({ content: char });
|
|
431
|
+
const result = mapIterable(value, (content) => {
|
|
302
432
|
const data = {
|
|
303
|
-
content
|
|
304
|
-
format:
|
|
433
|
+
content,
|
|
434
|
+
format: cloneFormat(format),
|
|
305
435
|
};
|
|
306
436
|
return new StringAtom(data as never); // Generic break type safety here. TODO: try and make safer.
|
|
307
437
|
});
|
|
308
438
|
return result;
|
|
309
439
|
}
|
|
310
440
|
|
|
441
|
+
function textAtomsFromString(
|
|
442
|
+
value: string,
|
|
443
|
+
format: TreeFieldFromImplicitField<FormatSchema>,
|
|
444
|
+
): Iterable<StringAtom> {
|
|
445
|
+
const textAtoms = stringTextAtomsFromString(value);
|
|
446
|
+
return stringAtomsFromTextAtoms(textAtoms, format);
|
|
447
|
+
}
|
|
448
|
+
|
|
311
449
|
class StringArray extends sf.array("StringArray", [() => StringAtom]) {
|
|
312
450
|
public withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {
|
|
313
451
|
const innerNode = getInnerNode(this);
|
|
@@ -466,13 +604,19 @@ export namespace FormattedTextAsTree {
|
|
|
466
604
|
* @remarks
|
|
467
605
|
* See {@link FormattedTextAsTree.Members} for the API.
|
|
468
606
|
* See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.
|
|
607
|
+
* @privateRemarks
|
|
608
|
+
* eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.
|
|
609
|
+
* Ideally we would generate private members for non-public properties, but TypeScript does not support this.
|
|
610
|
+
* It is up to the user of eraseSchemaDetailsSubclassable to manage this risk.
|
|
611
|
+
*
|
|
612
|
+
* TODO: there is at least one collision prone member to worry about here: `content`.
|
|
469
613
|
*/
|
|
470
614
|
const Tree = eraseSchemaDetailsSubclassable<
|
|
471
|
-
|
|
472
|
-
Statics<Tree>
|
|
615
|
+
Members<FormatSchema, ExtraAtomsSchema>,
|
|
616
|
+
Statics<Tree, FormatSchema>
|
|
473
617
|
>()(TextNode);
|
|
474
618
|
type Tree = ErasedNode<
|
|
475
|
-
|
|
619
|
+
Members<FormatSchema, ExtraAtomsSchema>,
|
|
476
620
|
FormattedTextSchemaIdentifier<TUserScope>
|
|
477
621
|
>;
|
|
478
622
|
|
|
@@ -481,16 +625,30 @@ export namespace FormattedTextAsTree {
|
|
|
481
625
|
|
|
482
626
|
/**
|
|
483
627
|
* Portion of a string with formatting.
|
|
628
|
+
* @privateRemarks
|
|
629
|
+
* This is implemented {@link StringAtom}, but we avoid leaking the fact this is a TreeNode in the API surface to
|
|
630
|
+
* preserve more future flexibility.
|
|
484
631
|
* @sealed
|
|
485
632
|
* @internal
|
|
486
633
|
*/
|
|
487
634
|
export interface FormattedAtom<TFormat, TText> {
|
|
635
|
+
/**
|
|
636
|
+
* Content which is formatted.
|
|
637
|
+
*/
|
|
488
638
|
readonly content: TText;
|
|
639
|
+
/**
|
|
640
|
+
* Formatting which is applied to the content.
|
|
641
|
+
* @remarks
|
|
642
|
+
* Can be reassigned or deeply mutated to edit the formatting of the content.
|
|
643
|
+
*/
|
|
489
644
|
format: TFormat;
|
|
490
645
|
}
|
|
491
646
|
|
|
492
647
|
/**
|
|
493
648
|
* Portion of a string.
|
|
649
|
+
* @remarks
|
|
650
|
+
* Additional kinds of text atoms (also known as embedded objects) which can occur inside a string can implement this.
|
|
651
|
+
* The schema for them can then be provided to {@link FormattedTextAsTree.createSchema}.
|
|
494
652
|
* @internal
|
|
495
653
|
*/
|
|
496
654
|
export interface TextAtom {
|
|
@@ -501,36 +659,61 @@ export namespace FormattedTextAsTree {
|
|
|
501
659
|
}
|
|
502
660
|
|
|
503
661
|
/**
|
|
504
|
-
*
|
|
662
|
+
* Static factory functions for {@link FormattedTextAsTree.(StringTextAtom:variable)}.
|
|
663
|
+
* @privateRemarks
|
|
664
|
+
* We type-erase `StringTextAtom` and only provide these static factories for construction
|
|
665
|
+
* to reduce the chance of someone accidentally creating a text atom for a string other than a single unicode code point.
|
|
666
|
+
* Other strings should work, but our intention is to provide no type-safe API which can produce them, so an application can take their lack of existence as an invariant if they want.
|
|
667
|
+
* It is still however possible to produce them, like export/import round trips with editing in the middle of the process, or collaboration with an equivalent schema which doesn't enforce this invariant.
|
|
668
|
+
* @sealed
|
|
505
669
|
* @internal
|
|
506
670
|
*/
|
|
507
|
-
export
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
671
|
+
export interface StringTextAtomStatics {
|
|
672
|
+
/**
|
|
673
|
+
* Creates an atom from exactly one Unicode code point.
|
|
674
|
+
* @throws A {@link @fluidframework/telemetry-utils#UsageError} if `value` does not contain exactly one Unicode code character.
|
|
675
|
+
*/
|
|
676
|
+
fromCharacter(value: string): StringTextAtom;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Creates one atom for each Unicode code point in `value`.
|
|
680
|
+
*/
|
|
681
|
+
fromString(value: string): StringTextAtom[];
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Schema for a {@link FormattedTextAsTree.(StringTextAtom:variable)} node.
|
|
686
|
+
* @sealed
|
|
687
|
+
* @internal
|
|
688
|
+
*/
|
|
689
|
+
export const StringTextAtom = eraseSchemaDetails<TextAtom, StringTextAtomStatics>()(
|
|
690
|
+
StringTextAtomNode,
|
|
691
|
+
);
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Node for the {@link FormattedTextAsTree.(StringTextAtom:variable)} schema.
|
|
695
|
+
* @sealed
|
|
696
|
+
* @internal
|
|
697
|
+
*/
|
|
698
|
+
export type StringTextAtom = ErasedNode<
|
|
699
|
+
TextAtom,
|
|
700
|
+
"com.fluidframework.text.formatted.StringTextAtom"
|
|
701
|
+
>;
|
|
523
702
|
|
|
524
703
|
/**
|
|
525
|
-
* Statics for text nodes.
|
|
704
|
+
* Statics for formatted text nodes.
|
|
705
|
+
* @sealed
|
|
526
706
|
* @internal
|
|
527
707
|
*/
|
|
528
|
-
export interface Statics<TTree> {
|
|
708
|
+
export interface Statics<TTree, FormatSchema extends ImplicitAllowedTypes> {
|
|
529
709
|
/**
|
|
530
710
|
* 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.
|
|
531
711
|
* @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.
|
|
532
712
|
*/
|
|
533
|
-
fromString(
|
|
713
|
+
fromString(
|
|
714
|
+
value: string,
|
|
715
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
716
|
+
): TTree;
|
|
534
717
|
}
|
|
535
718
|
|
|
536
719
|
/**
|
|
@@ -548,29 +731,47 @@ export namespace FormattedTextAsTree {
|
|
|
548
731
|
*
|
|
549
732
|
* @see {@link FormattedTextAsTree.Statics.fromString} for construction.
|
|
550
733
|
* @see {@link FormattedTextAsTree.createSchema} for creating schemas whose nodes implement this.
|
|
734
|
+
* @sealed
|
|
551
735
|
* @internal
|
|
552
736
|
*/
|
|
553
|
-
export interface Members<
|
|
554
|
-
extends
|
|
737
|
+
export interface Members<
|
|
738
|
+
FormatSchema extends ImplicitAllowedTypes,
|
|
739
|
+
ExtraAtomsSchema extends readonly LazyItem<
|
|
740
|
+
TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>
|
|
741
|
+
>[],
|
|
742
|
+
> extends TextAsTree.Members {
|
|
555
743
|
/**
|
|
556
|
-
*
|
|
744
|
+
* {@link TextAsTree.Members.insertAt} with optional formatting to apply to all additional characters,
|
|
745
|
+
* and allowing an array of atoms instead of a string.
|
|
746
|
+
* @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedTextAsTree.createSchema}) will be used.
|
|
557
747
|
* @remarks
|
|
558
|
-
*
|
|
559
|
-
* @
|
|
560
|
-
* Opt this into observation tracking.
|
|
748
|
+
* Use {@link FormattedTextAsTree.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.
|
|
749
|
+
* @override
|
|
561
750
|
*/
|
|
562
|
-
|
|
751
|
+
insertAt(
|
|
752
|
+
index: number,
|
|
753
|
+
additionalCharacters:
|
|
754
|
+
| string
|
|
755
|
+
| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,
|
|
756
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
757
|
+
): void;
|
|
563
758
|
|
|
564
759
|
/**
|
|
565
760
|
* Gets an array type view of the characters currently in the text.
|
|
566
761
|
* @remarks
|
|
567
762
|
* This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.
|
|
763
|
+
*
|
|
764
|
+
* For more efficient access, use {@link FormattedTextAsTree.Members.getUniformRun} and {@link FormattedTextAsTree.Members.getString} to access ranges of characters
|
|
765
|
+
* to avoid having to inspect the formatting on every atom.
|
|
568
766
|
* @privateRemarks
|
|
569
767
|
* Currently this is implemented by a node and changes with the text over time.
|
|
570
768
|
* We might not want to leak a node like this in the API.
|
|
571
769
|
* Providing a way to index and iterate separately might be better.
|
|
572
770
|
*/
|
|
573
|
-
charactersWithFormatting(): readonly
|
|
771
|
+
charactersWithFormatting(): readonly FormattedAtom<
|
|
772
|
+
TreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
773
|
+
TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>
|
|
774
|
+
>[];
|
|
574
775
|
|
|
575
776
|
/**
|
|
576
777
|
* Insert a range of characters into the string based on character index.
|
|
@@ -587,7 +788,12 @@ export namespace FormattedTextAsTree {
|
|
|
587
788
|
*/
|
|
588
789
|
insertWithFormattingAt(
|
|
589
790
|
index: number,
|
|
590
|
-
additionalCharacters: Iterable<
|
|
791
|
+
additionalCharacters: Iterable<
|
|
792
|
+
FormattedAtomInsertable<
|
|
793
|
+
InsertableTreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
794
|
+
InsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>
|
|
795
|
+
>
|
|
796
|
+
>,
|
|
591
797
|
): void;
|
|
592
798
|
|
|
593
799
|
/**
|
|
@@ -595,13 +801,44 @@ export namespace FormattedTextAsTree {
|
|
|
595
801
|
* @param startIndex - The starting index (inclusive) of the range to format.
|
|
596
802
|
* @param endIndex - The ending index (exclusive) of the range to format.
|
|
597
803
|
* @param format - The formatting to apply to the specified range.
|
|
804
|
+
* 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.
|
|
805
|
+
* All enumerable own properties of `format` will be applied, including those with `undefined` values.
|
|
598
806
|
* @remarks
|
|
599
807
|
* The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.
|
|
808
|
+
* This edits existing formatting subtrees on each atom, and only works when those atoms are object nodes.
|
|
809
|
+
*
|
|
810
|
+
* This is typically used to set some formatting property, like `bold` on a range of text without impacting other formatting properties.
|
|
811
|
+
* @privateRemarks
|
|
812
|
+
* This API is designed such that it can be optimized and improved in the future in a few different ways:
|
|
813
|
+
* 1. TODO: It can be optimized to use lower level APIs directly, bypassing the overhead of the public API surface.
|
|
814
|
+
* 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).
|
|
815
|
+
* 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.
|
|
816
|
+
* 4. TODO: Preserve the range editing semantics through the whole stack to allow for better merge behavior, and make optimizations easier.
|
|
600
817
|
*/
|
|
601
818
|
formatRange(
|
|
602
819
|
startIndex: number | undefined,
|
|
603
820
|
endIndex: number | undefined,
|
|
604
|
-
format:
|
|
821
|
+
format: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,
|
|
822
|
+
): void;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Replace formatting of a range of characters based on character index.
|
|
826
|
+
* @param startIndex - The starting index (inclusive) of the range to format.
|
|
827
|
+
* @param endIndex - The ending index (exclusive) of the range to format.
|
|
828
|
+
* @param format - The formatting to replace the formatting of the indicated range with.
|
|
829
|
+
* For each atom, `format` will be cloned and assigned to the atom's format, overwriting any existing formatting.
|
|
830
|
+
* If not specified the `defaultFormat` from {@link FormattedTextAsTree.createSchema} will be used.
|
|
831
|
+
* @remarks
|
|
832
|
+
* The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.
|
|
833
|
+
*
|
|
834
|
+
* This is typically used to normalize formatting, like resetting the formatting of a range to default settings.
|
|
835
|
+
* @privateRemarks
|
|
836
|
+
* See notes on {@link FormattedTextAsTree.Members.formatRange} for future optimization opportunities.
|
|
837
|
+
*/
|
|
838
|
+
reformat(
|
|
839
|
+
startIndex?: number | undefined,
|
|
840
|
+
endIndex?: number | undefined,
|
|
841
|
+
format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
|
|
605
842
|
): void;
|
|
606
843
|
|
|
607
844
|
/**
|
|
@@ -641,6 +878,7 @@ export namespace FormattedTextAsTree {
|
|
|
641
878
|
|
|
642
879
|
/**
|
|
643
880
|
* Insertable shape for a formatted text atom used by {@link FormattedTextAsTree.Members.insertWithFormattingAt}.
|
|
881
|
+
* @input
|
|
644
882
|
* @internal
|
|
645
883
|
*/
|
|
646
884
|
export interface FormattedAtomInsertable<TFormat, TContent> {
|
|
@@ -660,44 +898,22 @@ export namespace FormattedTextAsTree {
|
|
|
660
898
|
>;
|
|
661
899
|
|
|
662
900
|
/**
|
|
663
|
-
* Helper for expressing the full set of
|
|
664
|
-
* @
|
|
665
|
-
*
|
|
901
|
+
* Helper for expressing the full set of text atoms for a given schema.
|
|
902
|
+
* @remarks
|
|
903
|
+
* This is just schema for the text atom {@link AllowedTypes},
|
|
904
|
+
* and does not include the actual formatting (which is higher up in the tree).
|
|
905
|
+
* @sealed
|
|
666
906
|
* @internal
|
|
667
907
|
*/
|
|
668
|
-
export type
|
|
908
|
+
export type TextAtomSchemas<
|
|
669
909
|
ExtraAtomsSchema extends readonly LazyItem<
|
|
670
910
|
TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>
|
|
671
911
|
>[],
|
|
672
912
|
> = readonly [typeof StringTextAtom, ...ExtraAtomsSchema];
|
|
673
913
|
|
|
674
|
-
/**
|
|
675
|
-
* Helper for configuring {@link FormattedTextAsTree.Members}.
|
|
676
|
-
* @privateRemarks
|
|
677
|
-
* Eventually this should probably be inlined into `FormattedTextAsTree.Members` or made a system type in a system namespace.
|
|
678
|
-
* The approach should be evaluated after settling on a redesign of the `formatRange` API as that will impact what the type parameters are.
|
|
679
|
-
* @internal
|
|
680
|
-
*/
|
|
681
|
-
export type FormattedTextMembers<
|
|
682
|
-
FormatSchema extends ImplicitAllowedTypes,
|
|
683
|
-
ExtraAtomsSchema extends readonly LazyItem<
|
|
684
|
-
TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>
|
|
685
|
-
>[],
|
|
686
|
-
> = Members<
|
|
687
|
-
TreeFieldFromImplicitField<FormatSchema>,
|
|
688
|
-
Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,
|
|
689
|
-
FormattedAtom<
|
|
690
|
-
TreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
691
|
-
TreeNodeFromImplicitAllowedTypes<FormattedTextAtoms<ExtraAtomsSchema>>
|
|
692
|
-
>,
|
|
693
|
-
FormattedAtomInsertable<
|
|
694
|
-
InsertableTreeNodeFromImplicitAllowedTypes<FormatSchema>,
|
|
695
|
-
InsertableTreeNodeFromImplicitAllowedTypes<FormattedTextAtoms<ExtraAtomsSchema>>
|
|
696
|
-
>
|
|
697
|
-
>;
|
|
698
|
-
|
|
699
914
|
/**
|
|
700
915
|
* A generic type for a formatted text schema.
|
|
916
|
+
* @sealed
|
|
701
917
|
* @internal
|
|
702
918
|
*/
|
|
703
919
|
export type FormattedTextSchema<
|
|
@@ -708,12 +924,13 @@ export namespace FormattedTextAsTree {
|
|
|
708
924
|
>[],
|
|
709
925
|
> = Statics<
|
|
710
926
|
ErasedNode<
|
|
711
|
-
|
|
927
|
+
Members<FormatSchema, ExtraAtomsSchema>,
|
|
712
928
|
FormattedTextSchemaIdentifier<TUserScope>
|
|
713
|
-
|
|
929
|
+
>,
|
|
930
|
+
FormatSchema
|
|
714
931
|
> &
|
|
715
932
|
ErasedSchemaSubclassable<
|
|
716
|
-
|
|
933
|
+
Members<FormatSchema, ExtraAtomsSchema>,
|
|
717
934
|
FormattedTextSchemaIdentifier<TUserScope>
|
|
718
935
|
>;
|
|
719
936
|
}
|