FormattedText Namespace
A collection of text related types, schema and utilities for working with text beyond the basic string.
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
| Interface | Alerts | Modifiers | Description |
|---|---|---|---|
| FormattedAtom | Alpha | sealed | Portion of a string with formatting. |
| FormattedAtomInsertable | Alpha | Insertable shape for a formatted text atom used by insertWithFormattingAt(index, additionalCharacters). | |
| Members | Alpha | sealed | Interface for a text node. |
| Statics | Alpha | sealed | Statics for formatted text nodes. |
| StringTextAtomStatics | Alpha | sealed | Static factory functions for StringTextAtom. |
| TextAtom | Alpha | Portion of a string. |
Types
| TypeAlias | Alerts | Modifiers | Description |
|---|---|---|---|
| FormattedTextSchema | Alpha | sealed | A generic type for a formatted text schema. |
| FormattedTextSchemaIdentifier | Alpha | Schema identifier for the a generic formatted text schema. | |
| StringTextAtom | Alpha | sealed | Node for the StringTextAtom schema. |
| TextAtomSchemas | Alpha | sealed | Helper for expressing the full set of text atoms for a given schema. |
Functions
| Function | Alerts | Return Type | Description |
|---|---|---|---|
| createSchema(inputSchemaFactory, formatSchema, extraAtoms, defaultFormatInsertable) | Alpha | FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema> | Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types. |
Variables
| Variable | Alerts | Modifiers | Type | Description |
|---|---|---|---|---|
| StringTextAtom | Alpha | readonly, sealed | 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> | 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.
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
| Parameter | Constraint | Description |
|---|---|---|
| TUserScope | string | |
| FormatSchema | ImplicitAllowedTypes | |
| ExtraAtomsSchema | readonly LazyItem<TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>>[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
| inputSchemaFactory | SchemaFactoryBeta<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. |
| formatSchema | FormatSchema | Schema describing the formatting associated with each atom of text. Use an Object node to support formatRange(startIndex, endIndex, format). |
| extraAtoms | ExtraAtomsSchema | Additional 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. |
| defaultFormatInsertable | InsertableTreeFieldFromImplicitField<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.
For more information about our API support guarantees, see here.
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>