← All packages

API reference

@searsuite/sear-domain-doc

Rich-document nodes, selections, schema helpers, inline styles, and layout contracts.

86 exportsderived from source

classDocNodeRegistrysource ↗
class DocNodeRegistry

Registry that maps persisted rich-document node types to constructors.

constructorconstructor
DocNodeRegistry(): DocNodeRegistry
propertysymbolstatic
readonly symbol: typeof symbol

DI token for resolving the document node registry.

methodcreate
create(schema: Schema): RichDocNode

Instance method: delegates to the static registry; used by DI-injected consumers.

schema: Schema
methodisBlockType
isBlockType(type: string): boolean

Instance method: returns whether the persisted type has been registered as a block container.

type: string
methodisTextType
isTextType(type: string): boolean

Instance method: returns whether the persisted type has been registered as text-like.

type: string
methodregister
register(definition: DocNodeDefinition): void

Registers a node factory on this registry instance.

definition: DocNodeDefinition
methodrequireDefaultBlockType
requireDefaultBlockType(): string

Instance method: returns the registered default block type for generic text editing.

methodrequireDefaultTextType
requireDefaultTextType(): string

Instance method: returns the registered default text type for generic text editing.

methodcreatestatic
create(schema: Schema): RichDocNode

Creates a rich-document node from persisted schema.

schema: Schema
methodisBlockTypestatic
isBlockType(type: string): boolean

Returns whether the persisted type has been registered as a block container.

type: string
methodisTextTypestatic
isTextType(type: string): boolean

Returns whether the persisted type has been registered as text-like.

type: string
methodregisterstatic
register(type: string, creator: (schema: Schema): RichDocNode): void register(definition: DocNodeDefinition): void

Registers a node factory for a persisted node type.

type: string
creator: (schema: Schema): RichDocNode
definition: DocNodeDefinition
methodrequireDefaultBlockTypestatic
requireDefaultBlockType(): string

Returns the registered default block type for generic text editing.

methodrequireDefaultTextTypestatic
requireDefaultTextType(): string

Returns the registered default text type for generic text editing.

classParagraphNodesource ↗
class ParagraphNode extends RichDocNode

Built-in paragraph node.

constructorconstructor
ParagraphNode(schema: NodeSchema): ParagraphNode

Creates a paragraph node from persisted schema.

schema: NodeSchema
propertynodeTypestatic
readonly nodeType: "paragraph"

Persisted schema type owned by the paragraph document feature.

Inherited members 5

Inherited from RichDocNode.

classRichDocNodesource ↗
class RichDocNode

Base class for rich-document nodes used by the document layout engine.

propertyattrs
attrs: Record<string, any>

Node attributes such as text styles or block metadata.

propertycontent
content: RichDocNode[] | TextNode[]

Child rich-document nodes.

propertyid
id: string | undefined

Stable structural identity for layout, retained render nodes, and collaboration mapping.

propertytype
type: string

Domain node type identifier.

methodcreatestatic
create(_schema: Schema): RichDocNode

Creates a concrete rich-document node from persisted schema.

_schema: Schema
classRichTextBlockFlowRegistrysource ↗
class RichTextBlockFlowRegistry

Ordered registry for plugin-owned top-level block flow resolution.

constructorconstructor
RichTextBlockFlowRegistry(defaultSpacingAfter?: number): RichTextBlockFlowRegistry
defaultSpacingAfter: number
propertysymbolstatic
readonly symbol: typeof symbol
methodenforceWriteBoundary
enforceWriteBoundary(assertWrite: (): void): void
assertWrite: (): void
methodregister
register(contribution: RichTextBlockFlowContribution): (): void
contribution: RichTextBlockFlowContribution
methodresolve
resolve(input: { blockCount: number; index: number; node: RichDocNode }): number
input: { blockCount: number; index: number; node: RichDocNode }
classRichTextInlineStyleRegistrysource ↗
class RichTextInlineStyleRegistry

Ordered registry for plugin-owned rich-text inline style readers and mutations.

constructorconstructor
RichTextInlineStyleRegistry(): RichTextInlineStyleRegistry
propertysymbolstatic
readonly symbol: typeof symbol

DI token for resolving the inline style registry.

methodenforceWriteBoundary
enforceWriteBoundary(assertWrite: (): void): void
assertWrite: (): void
methodgetMutation
getMutation(styleKey: string): RichTextInlineStyleMutation | undefined

Resolves a plugin-owned persisted inline style mutation by style key when registered.

styleKey: string
methodgetMutationKeys
getMutationKeys(): readonly string[]

Returns all registered persisted inline-style mutation keys in registration order.

methodreadTextNodeStyle
readTextNodeStyle(node: TextNode): Readonly<Record<string, unknown>> | undefined

Reads all registered style slices from a text node.

node: TextNode
methodregister
register(contribution: RichTextInlineStyleContribution): (): void

Registers one plugin-owned inline style contribution.

contribution: RichTextInlineStyleContribution
methodrequireMutation
requireMutation(styleKey: string): RichTextInlineStyleMutation

Resolves a plugin-owned persisted inline style mutation by style key.

styleKey: string
methodsameStyle
sameStyle(styleA: Readonly<Record<string, unknown>> | undefined, styleB: Readonly<Record<string, unknown>> | undefined): boolean

Compares two style bags using stable key/value serialization.

styleA: Readonly<Record<string, unknown>> | undefined
styleB: Readonly<Record<string, unknown>> | undefined
classRichTextLineBoxRegistrysource ↗
class RichTextLineBoxRegistry

Ordered registry for plugin-owned rich-text line box resolution.

constructorconstructor
RichTextLineBoxRegistry(): RichTextLineBoxRegistry
propertysymbolstatic
readonly symbol: typeof symbol

DI token for resolving the rich-text line box registry.

methodenforceWriteBoundary
enforceWriteBoundary(assertWrite: (): void): void
assertWrite: (): void
methodregister
register(contribution: RichTextLineBoxContribution): (): void

Registers one plugin-owned line box contribution.

contribution: RichTextLineBoxContribution
methodresolve
resolve(input: { chars: readonly RichTextChar[]; lineSpacing?: RichTextLineSpacing }): RichTextLineBox

Resolves the final line box for one measured line.

input: { chars: readonly RichTextChar[]; lineSpacing?: RichTextLineSpacing }
classTableCellNodesource ↗
class TableCellNode extends RichDocNode

Built-in table cell node.

constructorconstructor
TableCellNode(schema: NodeSchema): TableCellNode

Creates a table cell node from persisted schema.

schema: NodeSchema
propertynodeTypestatic
readonly nodeType: "tableCell"

Persisted schema type owned by the table document feature.

Inherited members 5

Inherited from RichDocNode.

classTableNodesource ↗
class TableNode extends RichDocNode

Built-in table block node.

constructorconstructor
TableNode(schema: NodeSchema): TableNode

Creates a table node from persisted schema.

schema: NodeSchema
propertynodeTypestatic
readonly nodeType: "table"

Persisted schema type owned by the table document feature.

Inherited members 5

Inherited from RichDocNode.

classTableRowNodesource ↗
class TableRowNode extends RichDocNode

Built-in table row node.

constructorconstructor
TableRowNode(schema: NodeSchema): TableRowNode

Creates a table row node from persisted schema.

schema: NodeSchema
propertynodeTypestatic
readonly nodeType: "tableRow"

Persisted schema type owned by the table document feature.

Inherited members 5

Inherited from RichDocNode.

classTextNodesource ↗
class TextNode extends RichDocNode

Built-in text leaf node.

constructorconstructor
TextNode(schema: NodeSchema): TextNode TextNode(schema: TextSchema): TextNode

Creates a text node from persisted schema.

schema: NodeSchema
propertytext
text?: string

Text content carried by this leaf node.

propertynodeTypestatic
readonly nodeType: "text"

Persisted schema type owned by the text input document feature.

Inherited members 5

Inherited from RichDocNode.

interfaceDocCursorPossource ↗
interface DocCursorPos

Cursor position inside a RichDocNode tree.

path is an array of integer indices that navigates from the implicit document root (the RichDocNode[] array treated as root.content) down to the text node that contains the cursor.

Examples for a flat document: [0, 0] → paragraph 0 → text node 0 (the most common case in P0) [1, 2] → paragraph 1 → inline span 2

The path aligns with OT operation paths: a StringInsert at this cursor becomes { p: [...path, offset], si: text } applied to the root wrapper { type: &#39;doc&#39;, content: doc }.

offset is the character position within the leaf text node: 0 = before first character n = after the nth character (= text.length means "end of node")

propertyoffset
offset: number

Character offset within the leaf text node.

propertypath
path: number[]

Path from root content[] to the leaf text node.

interfaceDocNodeDefinitionsource ↗
interface DocNodeDefinition

Registration contract for one persisted rich-document node type.

propertycreate
readonly create: (schema: Schema): RichDocNode

Factory that creates the runtime node instance for this persisted schema.

propertydefaultBlock
readonly defaultBlock?: boolean

Whether this block is the default container for plain text editing.

propertydefaultText
readonly defaultText?: boolean

Whether this text-like node is the default leaf for plain text editing.

propertyrole
readonly role?: DocNodeRole

Generic role consumed by core editing/layout helpers.

propertytype
readonly type: string

Persisted schema type owned by a document feature plugin.

interfaceDocSelectionsource ↗
interface DocSelection

Anchor + head selection model. Collapsed selection (cursor only): anchor === head. head moves freely; anchor is fixed until a non-Shift action resets it.

propertyanchor
anchor: DocCursorPos
propertyhead
head: DocCursorPos
interfaceInlineTextRangePatchsource ↗
interface InlineTextRangePatch

One text-node replacement produced by an inline text range edit.

propertybeforeLength
readonly beforeLength: number
propertyblockIndex
readonly blockIndex: number
propertychildIndex
readonly childIndex: number
propertyendOffset
readonly endOffset: number
propertyoldNode
readonly oldNode: TextNode
propertyreplacement
readonly replacement: readonly RichDocNode[]
propertyreplacementCount
readonly replacementCount: number
propertyselectedLength
readonly selectedLength: number
propertystartOffset
readonly startOffset: number
propertywholeNode
readonly wholeNode: boolean
interfaceInlineTextRangePatchContextsource ↗
interface InlineTextRangePatchContext

Context supplied when patching one selected text-node segment.

propertyblockIndex
readonly blockIndex: number
propertychildIndex
readonly childIndex: number
propertyendOffset
readonly endOffset: number
propertynode
readonly node: TextNode
propertystartOffset
readonly startOffset: number
interfaceRichNodeFactorysource ↗
interface RichNodeFactory

Minimal factory interface for creating document nodes. Implemented by DocNodeRegistry (static or injected).

methodcreate
create(schema: { attrs?: Record<string, unknown>; content?: unknown[]; id?: string; text?: string; type: string }): RichDocNode
schema: { attrs?: Record<string, unknown>; content?: unknown[]; id?: string; text?: string; type: string }
interfaceRichTextBlockFlowContributionsource ↗
interface RichTextBlockFlowContribution

Plugin-owned contribution that can refine block flow metrics.

propertykey
readonly key: string
methodresolve
resolve(input: RichTextBlockFlowResolveInput): number
input: RichTextBlockFlowResolveInput
interfaceRichTextBlockFlowResolveInputsource ↗
interface RichTextBlockFlowResolveInput

Input used to resolve the flow spacing after one top-level document block.

propertyblockCount
readonly blockCount: number
propertyindex
readonly index: number
propertynode
readonly node: RichDocNode
propertyspacingAfter
readonly spacingAfter: number
interfaceRichTextBlockLayoutProvidersource ↗
interface RichTextBlockLayoutProvider

Domain-side contract for services that provide measured rich-text block layout.

methodcalculateLayoutPerParagraph
calculateLayoutPerParagraph(width: number): RichTextLine[][]
width: number
methodsetBaseFont
setBaseFont(font: string): void

Updates the transient font used when measuring unstyled text.

font: string
interfaceRichTextInlineStyleContributionsource ↗
interface RichTextInlineStyleContribution

Plugin-owned contribution for one inline text style concern.

propertykey
readonly key: string

Stable contribution key used for duplicate detection and unregister.

propertymutations
mutations?: readonly RichTextInlineStyleMutation[]

Persisted inline text-style mutations owned by this contribution.

methodread
read(input: RichTextInlineStyleReadInput): Readonly<Record<string, unknown>> | undefined

Reads this contribution's style slice from a text node.

input: RichTextInlineStyleReadInput
interfaceRichTextInlineStyleMutationsource ↗
interface RichTextInlineStyleMutation

Plugin-owned mutation for one persisted inline text-style concern.

propertystyleKey
readonly styleKey: string

Stable style key used by commands to resolve this mutation.

methodapply
apply(input: RichTextInlineStyleMutationInput): Record<string, unknown>

Applies the normalized style value to a text node's persisted attrs.

input: RichTextInlineStyleMutationInput
interfaceRichTextInlineStyleMutationInputsource ↗
interface RichTextInlineStyleMutationInput

Input supplied when an inline-style contribution mutates persisted text-node attrs.

propertyattrs
readonly attrs: Record<string, unknown>
propertyvalue
readonly value: unknown
interfaceRichTextInlineStyleReadInputsource ↗
interface RichTextInlineStyleReadInput

Input supplied when an inline-style contribution reads document attrs.

propertyattrs
readonly attrs: Record<string, unknown>
propertynode
readonly node: TextNode
interfaceRichTextLineBoxsource ↗
interface RichTextLineBox

Flow metrics for one rich-text line.

propertyascent
readonly ascent: number
propertycontentHeight
readonly contentHeight: number
propertydescent
readonly descent: number
propertyleadingBottom
readonly leadingBottom: number
propertyleadingTop
readonly leadingTop: number
propertylineGap
readonly lineGap: number
propertylineHeight
readonly lineHeight: number
interfaceRichTextLineBoxContributionsource ↗
interface RichTextLineBoxContribution

Plugin-owned contribution that can refine rich-text line flow metrics.

propertykey
readonly key: string

Stable contribution key used for duplicate detection and unregister.

methodresolve
resolve(input: RichTextLineBoxResolveInput): RichTextLineBox

Resolves the next line box from the current accumulated line box.

input: RichTextLineBoxResolveInput
interfaceRichTextLineBoxResolveInputsource ↗
interface RichTextLineBoxResolveInput

Input used to resolve the flow box for one measured rich-text line.

propertychars
readonly chars: readonly RichTextChar[]
propertylineBox
readonly lineBox: RichTextLineBox
propertylineSpacing
readonly lineSpacing?: RichTextLineSpacing
interfaceRichTextLineSpacingsource ↗
interface RichTextLineSpacing

Persisted or default line-spacing policy resolved by paragraph layout.

propertymode
readonly mode: RichTextLineSpacingMode
propertyvalue
readonly value?: number
interfaceRichTextParagraphLayoutsource ↗
interface RichTextParagraphLayout

Resolved paragraph layout values consumed by line and block flow.

propertylineSpacing
readonly lineSpacing: RichTextLineSpacing
propertyspacingAfter
readonly spacingAfter: number
interfaceRichTextParagraphLayoutDefaultssource ↗
interface RichTextParagraphLayoutDefaults

Default paragraph layout values supplied by the owning document runtime.

propertylineSpacing
readonly lineSpacing: RichTextLineSpacing
propertyspacingAfter
readonly spacingAfter: number
interfaceTextAttributeRangesource ↗
interface TextAttributeRange<TAttributes>

A generic text attribute range in document-relative character offsets.

propertyattrs
attrs: TAttributes
propertyend
end: number
propertystart
start: number
interfaceTextGraphemeRangesource ↗
interface TextGraphemeRange

One grapheme range expressed in UTF-16 source offsets.

propertyend
readonly end: number
propertystart
readonly start: number
interfaceTextSelectionsource ↗
interface TextSelection

Public contract for TextSelection.

propertyanchor
anchor: string | number[]
propertyhead
head: string | number[]
typeDocNodeIdsource ↗
type DocNodeId = string & { [docNodeIdBrand]: true }

Stable identity used by document layout and retained render nodes.

typeDocNodeRolesource ↗
type DocNodeRole = typeof DocNodeRole[keyof typeof DocNodeRole]

Type contract for DocNodeRole.

typeInlineTextRangeAttrsPatchersource ↗
type InlineTextRangeAttrsPatcher = (attrs: Record<string, unknown>, context: InlineTextRangePatchContext): Record<string, unknown>

Patches the attrs for the selected segment of one text node.

typeRichTextCharsource ↗
type RichTextChar = unknown

Measured inline character/token used by rich-text line wrapping.

propertychar
char: string
propertyfontAscent
fontAscent: number
propertyfontDescent
fontDescent?: number
propertyfontLineGap
fontLineGap?: number
propertyheight
height: number
propertystyle
style?: RichTextInlineStyle
propertytextNodeIndex
textNodeIndex?: number

Direct child index of the source text node within its paragraph.

propertytextNodeOffset
textNodeOffset?: number

Character offset within the source text node.

propertywidth
width: number
typeRichTextInlineStylesource ↗
type RichTextInlineStyle = Readonly<Record<string, unknown>>

Domain-neutral inline style bag carried by measured rich-text chars.

typeRichTextLinesource ↗
type RichTextLine = unknown

One laid-out rich-text line with aggregate dimensions.

propertychars
chars: RichTextChar[]
propertyfontAscent
fontAscent: number

Max measured font ascent across all chars on this line; used for stable vertical centering.

propertyfontDescent
fontDescent?: number

Max measured font descent across all chars on this line.

propertyheight
height: number
propertylineBox
lineBox?: RichTextLineBox

Plugin-resolved line box used for flow and baseline placement.

propertywidth
width: number
typeRichTextLineSpacingModesource ↗
type RichTextLineSpacingMode = "auto" | "multiple" | "atLeast" | "exact"

Supported paragraph line-spacing semantics.

typeTextAttributePatchsource ↗
type TextAttributePatch = Readonly<Record<string, unknown>>

Attributes merged into a text node for one presentation range.

variabledefaultRichTextParagraphLayoutDefaultssource ↗
defaultRichTextParagraphLayoutDefaults: RichTextParagraphLayoutDefaults

Neutral defaults for runtimes that do not configure document paragraph spacing.

variableDocNodeRolesource ↗
DocNodeRole: { Block: "block"; Text: "text" }

Node roles used by generic rich-document editing and layout helpers.

variableRichTextParagraphAttributesource ↗
RichTextParagraphAttribute: { LineSpacing: "lineSpacing"; SpacingAfter: "spacingAfter" }

Persisted paragraph attribute keys owned by the paragraph feature.

functionapplyInlineTextRangePatchPlansource ↗
applyInlineTextRangePatchPlan(doc: readonly RichDocNode[], patches: readonly InlineTextRangePatch[]): RichDocNode[]

Applies an inline text range patch plan to an immutable document snapshot.

doc: readonly RichDocNode[]
patches: readonly InlineTextRangePatch[]
functionapplyInlineTextStylePropertyMutationsource ↗
applyInlineTextStylePropertyMutation(attrs: Readonly<Record<string, unknown>>, property: string, value: unknown): Record<string, unknown>

Applies or removes one persisted inline-text style property.

attrs: Readonly<Record<string, unknown>>
property: string
value: unknown
functionapplyRichTextFormatsource ↗
applyRichTextFormat(document: readonly Schema[], format: Readonly<Record<string, unknown>>, registry: RichTextInlineStyleRegistry): Schema[]

Replaces registered styles while retaining text, structure and unrelated attributes.

document: readonly Schema[]
format: Readonly<Record<string, unknown>>
registry: RichTextInlineStyleRegistry
functionapplyTextAttributeRangessource ↗
applyTextAttributeRanges(doc: RichDocNode[], ranges: readonly TextAttributeRange<Readonly<Record<string, unknown>>>[]): RichDocNode[]

Applies presentation attributes to text ranges without owning their meaning. Plugins decide how to interpret the resulting text-node attrs.

doc: RichDocNode[]
ranges: readonly TextAttributeRange<Readonly<Record<string, unknown>>>[]
functionbuildInlineTextRangePatchPlansource ↗
buildInlineTextRangePatchPlan(doc: readonly RichDocNode[], selection: DocSelection, patchAttrs: InlineTextRangeAttrsPatcher): InlineTextRangePatch[]

Builds reusable text-node split/replacement patches for a document selection.

doc: readonly RichDocNode[]
selection: DocSelection
patchAttrs: InlineTextRangeAttrsPatcher
functioncaptureRichTextFormatsource ↗
captureRichTextFormat(document: readonly Schema[], registry: RichTextInlineStyleRegistry): Readonly<Record<string, unknown>>

Captures the leading text run's explicit registered styles, excluding host defaults.

document: readonly Schema[]
registry: RichTextInlineStyleRegistry
functioncloneRichDocumentsource ↗
cloneRichDocument(document: readonly RichDocNode[]): RichDocNode[]

Returns a detached mutable snapshot of a rich document.

document: readonly RichDocNode[]
functioncompareCursorsource ↗
compareCursor(a: DocCursorPos, b: DocCursorPos): -1 | 0 | 1

Lexicographic comparison of two cursor positions. Compares path element-by-element, then offset. Returns -1 | 0 | 1.

a: DocCursorPos
b: DocCursorPos
functioncomputeFirstBaselineYsource ↗
computeFirstBaselineY(boxHeight: number, cellPadding: number, fontAscent: number, lineHeight: number, offsetY?: number): number

Compute the Y coordinate of the first text line's baseline for vertical centering.

Text painters in this engine position runs by their alphabetic baseline, so the correct formula to visually center a line inside a padded box is:

baseline = center + (fontAscent - fontDescent) / 2

Since lineHeight = fontAscent + fontDescent, this simplifies to:

baseline = offsetY + cellPadding + (boxHeight - 2·cellPadding + 2·fontAscent - lineHeight) / 2

boxHeight: number

Total pixel height of the containing box (e.g. cell height).

cellPadding: number

Padding on each side of the box.

fontAscent: number

Measured font ascent of the first line (stable across all glyphs in the font).

lineHeight: number

Total line height (fontAscent + fontDescent) of the first line.

offsetY: number

Absolute Y offset of the box top-left (default 0 for relative coordinates).

functioncreateDefaultRichTextBlockFlowContributionsource ↗
createDefaultRichTextBlockFlowContribution(): RichTextBlockFlowContribution

Creates the paragraph-owned default after-spacing contribution.

functioncreateDefaultRichTextLineBoxContributionsource ↗
createDefaultRichTextLineBoxContribution(): RichTextLineBoxContribution

Creates the default line box contribution used by document composition roots.

functioncreateDocNodeIdsource ↗
createDocNodeId(value: string): DocNodeId

Creates a typed document node id from a non-empty string value.

value: string
functioncreateDocNodeIdFromPathsource ↗
createDocNodeIdFromPath(path: readonly string | number[]): DocNodeId

Creates a fallback document node id from a rich-document path.

path: readonly string | number[]
functioncreateEmptyParagraphsource ↗
createEmptyParagraph(): RichDocNode

Create a single empty paragraph containing one empty text node.

functioncreateInlineTextStyleAttrsPatchersource ↗
createInlineTextStyleAttrsPatcher(property: string, value: unknown): InlineTextRangeAttrsPatcher

Creates the compatibility inline text-style attrs patcher for property/value callers.

property: string
value: unknown
functioncreateRichTextLineSpacingContributionsource ↗
createRichTextLineSpacingContribution(): RichTextLineBoxContribution

Creates the paragraph-owned line-spacing contribution.

functiongetDocumentOffsetsource ↗
getDocumentOffset(doc: RichDocNode[], position: DocCursorPos): number

Converts a cursor position into a zero-based offset in the document's plain text, using one newline character between paragraphs.

doc: RichDocNode[]
position: DocCursorPos
functiongetTextNodeLengthsource ↗
getTextNodeLength(doc: RichDocNode[], path: number[]): number

Character length of the text node at path. Returns 0 for missing / non-text nodes.

doc: RichDocNode[]
path: number[]
functionisCollapsedsource ↗
isCollapsed(sel: DocSelection): boolean

Runs the is collapsed helper.

sel: DocSelection
functionisDocSemanticallyEmptysource ↗
isDocSemanticallyEmpty(doc: RichDocNode[]): boolean

Returns true if every paragraph in doc contains no meaningful text.

doc: RichDocNode[]
functionisTextNodesource ↗
isTextNode(node: TextNode | RichDocNode): node

Returns true when a rich-document node is a text leaf.

node: TextNode | RichDocNode
functionmapInlineTextRangePatchCursorsource ↗
mapInlineTextRangePatchCursor(cursor: DocCursorPos, patches: readonly InlineTextRangePatch[]): DocCursorPos

Repositions a cursor after an inline text range patch plan has been applied.

cursor: DocCursorPos
patches: readonly InlineTextRangePatch[]
functionnormalizeDocForEditsource ↗
normalizeDocForEdit(doc: RichDocNode[]): RichDocNode[]

Ensure doc has at least one paragraph. Returns the same array if already valid; otherwise [createEmptyParagraph()].

doc: RichDocNode[]
functionnormalizeSelectionsource ↗
normalizeSelection(sel: DocSelection): { end: DocCursorPos; start: DocCursorPos }

Normalize selection so start ≤ end regardless of direction.

sel: DocSelection
functionparaTextsource ↗
paraText(para: RichDocNode): string

Extract the concatenated plain text of a paragraph node.

para: RichDocNode
functionparaTextLengthsource ↗
paraTextLength(para: RichDocNode): number

Total plain-text length of a paragraph node (sums all direct text children).

para: RichDocNode
functionparseRichTextLineSpacingsource ↗
parseRichTextLineSpacing(value: unknown): RichTextLineSpacing | null

Parses a persisted line-spacing override, returning null when invalid.

value: unknown
functionparseRichTextParagraphSpacingsource ↗
parseRichTextParagraphSpacing(value: unknown): number | null

Parses a persisted paragraph-spacing override, returning null when invalid.

value: unknown
functionreadTextStyleAttrssource ↗
readTextStyleAttrs(attrs: Record<string, unknown>): Record<string, unknown>

Reads the inline text-style attribute bag from a node's attributes.

attrs: Record<string, unknown>
functionregisterParagraphDocNodesource ↗
registerParagraphDocNode(registry: DocNodeRegistrar): void

Registers the paragraph node type owned by paragraph-oriented document features.

registry: DocNodeRegistrar
functionregisterTableDocNodessource ↗
registerTableDocNodes(registry: DocNodeRegistrar): void

Registers the table node types owned by table-oriented document features.

registry: DocNodeRegistrar
functionregisterTextDocNodesource ↗
registerTextDocNode(registry: DocNodeRegistrar): void

Registers the text node type owned by text-input document features.

registry: DocNodeRegistrar
functionreplaceInlineTextStylesource ↗
replaceInlineTextStyle(doc: RichDocNode[], selection: DocSelection, property: string, value: unknown, patchAttrs?: InlineTextRangeAttrsPatcher): RichDocNode[]

Replaces one inline text-style property on the selected document range.

doc: RichDocNode[]
selection: DocSelection
property: string
value: unknown
patchAttrs: InlineTextRangeAttrsPatcher
functionresolveDocNodeIdsource ↗
resolveDocNodeId(node: { id?: string } | undefined, path: readonly string | number[]): DocNodeId

Resolves a block-level document id, preferring persisted node identity over path fallback.

node: { id?: string } | undefined
path: readonly string | number[]
functionresolveNodesource ↗
resolveNode(doc: RichDocNode[], path: number[]): RichDocNode | undefined

Resolve the text node at path inside doc (treated as the root content array). Returns undefined if the path is invalid.

doc: RichDocNode[]
path: number[]
functionresolveRichTextParagraphLayoutsource ↗
resolveRichTextParagraphLayout(node: RichDocNode | undefined, defaults?: RichTextParagraphLayoutDefaults): RichTextParagraphLayout

Resolves paragraph-owned overrides over the runtime defaults.

node: RichDocNode | undefined
defaults: RichTextParagraphLayoutDefaults
functionresolveTextContentsource ↗
resolveTextContent(doc: RichDocNode[], path: number[]): string

Get the plain-text string of the node at path. Convenience wrapper around resolveNode.

doc: RichDocNode[]
path: number[]
functionsegmentTextGraphemessource ↗
segmentTextGraphemes(text: string): readonly TextGraphemeRange[]

Segments text into grapheme ranges, with a code-point fallback for older hosts.

text: string
functionstringToRichDocsource ↗
stringToRichDoc(text: string): RichDocNode[]

Convert a plain string to a single-paragraph RichDocNode[]. Used for backward-compat when cell data is still stored as a plain string.

text: string
functionupdateInlineTextStyleAttrssource ↗
updateInlineTextStyleAttrs(current: unknown, property: string, value: unknown): Record<string, unknown>

Updates one entry in a text node's style attrs bag.

current: unknown
property: string
value: unknown
interfaceNodeSchemasource ↗
interface NodeSchema

Persisted rich-document node schema shared by document runtime, commands, and OT.

propertyattrs
attrs?: Record<string, any>

Node attributes for styles, formatting, and feature-owned metadata.

propertycontent
content?: Schema[]

Child rich-document nodes.

propertyid
id?: string

Stable structural identity for layout, retained render nodes, and collaboration mapping.

propertytext
text?: string

Optional text content for leaf text nodes.

propertytype
type: string

Domain node type identifier.

typeSchemasource ↗
type Schema = NodeSchema | TextSchema

Persisted rich-document schema node.

interfaceTextSchemasource ↗
interface TextSchema extends NodeSchema

Persisted text-bearing rich-document node schema.

propertytext
text: string

Optional text content for leaf text nodes.

Inherited members 4

Inherited from NodeSchema.