Skip to main content

FormattedText Namespace

A collection of text related types, schema and utilities for working with text beyond the basic string.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree/alpha.

For more information about our API support guarantees, see here.

Signature

export declare namespace FormattedText

Remarks

This is generic over formatting an embedded object/atom types.

Interfaces

InterfaceAlertsModifiersDescription
FormattedAtomAlphasealedPortion of a string with formatting.
FormattedAtomInsertableAlphaInsertable shape for a formatted text atom used by insertWithFormattingAt(index, additionalCharacters).
MembersAlphasealedInterface for a text node.
StaticsAlphasealedStatics for formatted text nodes.
StringTextAtomStaticsAlphasealedStatic factory functions for StringTextAtom.
TextAtomAlphaPortion of a string.

Types

TypeAliasAlertsModifiersDescription
FormattedTextSchemaAlphasealedA generic type for a formatted text schema.
FormattedTextSchemaIdentifierAlphaSchema identifier for the a generic formatted text schema.
StringTextAtomAlphasealedNode for the StringTextAtom schema.
TextAtomSchemasAlphasealedHelper for expressing the full set of text atoms for a given schema.

Functions

FunctionAlertsReturn TypeDescription
createSchema(inputSchemaFactory, formatSchema, extraAtoms, defaultFormatInsertable)AlphaFormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema>Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.

Variables

VariableAlertsModifiersTypeDescription
StringTextAtomAlphareadonly, sealedStringTextAtomStatics & TreeNodeSchema<"com.fluidframework.text.formatted.StringTextAtom", NodeKind, TextAtom & TreeNode & import("../simple-tree/index.js").WithType<"com.fluidframework.text.formatted.StringTextAtom", NodeKind, unknown>, never, false>Schema for a StringTextAtom node.

Function Details

createSchema

Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

function createSchema<const TUserScope extends string, const FormatSchema extends ImplicitAllowedTypes, const ExtraAtomsSchema extends readonly LazyItem<TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>>[]>(inputSchemaFactory: SchemaFactoryBeta<TUserScope>, formatSchema: FormatSchema, extraAtoms: ExtraAtomsSchema, defaultFormatInsertable: InsertableTreeFieldFromImplicitField<FormatSchema>): FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema>;
Type Parameters
ParameterConstraintDescription
TUserScopestring
FormatSchemaImplicitAllowedTypes
ExtraAtomsSchemareadonly LazyItem<TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>>[]

Parameters

ParameterTypeDescription
inputSchemaFactorySchemaFactoryBeta<TUserScope>The SchemaFactoryBeta used to scope the generated schema. The generated types are scoped under com.fluidframework.text.formatted<TUserScope>, where TUserScope is the scope of this factory. 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. It must be different to distinguish different formatted text schema within the same document.
formatSchemaFormatSchemaSchema describing the formatting associated with each atom of text. Use an Object node to support formatRange(startIndex, endIndex, format).
extraAtomsExtraAtomsSchemaAdditional atom schema to allow as text content beyond the built-in StringTextAtom. Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.
defaultFormatInsertableInsertableTreeFieldFromImplicitField<FormatSchema>The formatting applied to text inserted via non-formatted APIs (for example insertAt(index, additionalCharacters, format) and fromString(value, format) when no explicit format is provided).

Returns

The schema for the formatted text node, whose nodes implement Members and whose statics implement Statics.

Return type: FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema>

Variable Details

StringTextAtom

Schema for a StringTextAtom node.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
StringTextAtom: StringTextAtomStatics & TreeNodeSchema<"com.fluidframework.text.formatted.StringTextAtom", NodeKind, TextAtom & TreeNode & import("../simple-tree/index.js").WithType<"com.fluidframework.text.formatted.StringTextAtom", NodeKind, unknown>, never, false>

Type: StringTextAtomStatics & TreeNodeSchema<"com.fluidframework.text.formatted.StringTextAtom", NodeKind, TextAtom & TreeNode & import("../simple-tree/index.js").WithType<"com.fluidframework.text.formatted.StringTextAtom", NodeKind, unknown>, never, false>