← All packages

@searsuite/sear-assembly-doc

Document plugin contracts

A Doc assembly chooses plugins for paragraphs, tables, inline styles, and line layout. For example, ParagraphPlugin handles paragraph behavior and BoldTextStylePlugin contributes a bold inline style. The Doc plugin contracts define what those plugins receive from the editor runtime; the node and selection values they act on live in @searsuite/sear-domain-doc.

Import a feature plugin when composing the editor. Host controls should call its registered commands instead of changing document nodes directly.

classDocPlugin
class DocPlugin<StateType> extends Plugin<SearCoreDoc, NodeProperties, StateType>, PluginExtension<DocCommandBus, ObservationRegistry, SessionStateRegistry, DocRuntimeExtensionRegistry>

Convenience base class for a Plugin targeting createDocEditor().

constructorDocPlugin<StateType>(__namedParameters: PluginSpec<StateType>): DocPlugin<StateType>

Creates a plugin with its stable identity and initial state.

methodconfigure(context: DocPluginSetupContext): void

Configures the document editor before runtime start.

methodinitialize(context: DocPluginRuntimeContext): void

Prepares behavior that requires initialized Core state but must run before runtime effects.

methodonEditorDestroy(context: DocPluginRuntimeContext): void

Releases resources owned by this plugin before the Core is destroyed.

methodregisterBlockFlows(registry: RichTextBlockFlowRegistry): void

Registers plugin-owned top-level block flow resolvers.

methodregisterCapabilities(registry: DocRuntimeExtensionRegistry): void

Publishes typed runtime services owned by this document plugin.

methodregisterCommands(commands: DocCommandBus): void

Registers every stable command id owned by this document plugin.

methodregisterInlineStyleRenderers(registry: RichTextRunRenderRegistry): void

Registers plugin-owned render behavior for styled text runs.

methodregisterInlineStyles(registry: RichTextInlineStyleRegistry): void

Registers plugin-owned inline text style readers and mutation policies.

methodregisterKeyboardHandlers(context: DocKeyboardHandlerRegistrationContext): void

Registers keyboard-to-command bindings owned by this document plugin.

methodregisterLineBoxes(registry: RichTextLineBoxRegistry): void

Registers plugin-owned rich-text line box resolvers.

methodregisterObservations(observations: ObservationRegistry): void

Registers typed state and event observations owned by this document plugin.

methodregisterSessionState(registry: SessionStateRegistry): void

Registers local state that must survive an in-memory editor remount.

methodstart(context: DocPluginRuntimeContext): void

Starts runtime behavior after the first document frame.

methodregisterServices(context: DocPluginServiceContext): voidstatic

Registers bindings required before this Doc plugin is instantiated.

Inherited members 34

Inherited from Plugin.

classDocRuntimeExtensionRegistry
class DocRuntimeExtensionRegistry extends RuntimeCapabilityRegistry

Registry of extension capabilities available to document plugins.

constructorDocRuntimeExtensionRegistry(): DocRuntimeExtensionRegistry
propertyreadonly symbol: typeof symbolstatic

DI token for resolving the document runtime extension registry.

Inherited members 7

Inherited from RuntimeCapabilityRegistry.

interfaceDocPluginImplementation
interface DocPluginImplementation<TPlugin>

Injectable DocPlugin class accepted by createDocEditor().

interfaceDocPluginRuntime

Stable host capabilities supplied to a DocPlugin after editor assembly.

propertyreadonly commands: DocCommandBus

Command bus exposed by the document editor instance.

propertyreadonly document: { blockFlows: RichTextBlockFlowRegistry; core: SearCoreDoc; cursor: DocCursorManager; inlineStyles: RichTextInlineStyleRegistry; input: DocInputPlugin; layout: DocLayoutEngine; lineBoxes: RichTextLineBoxRegistry; nodes: DocNodeRegistry }

Rich-document domain services.

propertyreadonly events: { engine: EventEngine<NodeProperties>; registrar: EventRegistrar }

Event and hit-test services used by document interactions.

propertyreadonly extensions: DocRuntimeExtensionRegistry

Extension capability registry for third-party document plugins.

propertyreadonly input: { keyboard: KeyboardRouter; pointer: PointerCapture; text: TextInput }

Host input adapters used by document editing commands.

propertyreadonly observations: ObservationRegistry

Typed state and event observations owned by this editor instance.

propertyreadonly platform: Platform

Platform adapter for timers, resize observation, and diagnostics.

propertyreadonly plugins: PluginManager<SearCoreDoc, NodeProperties>

Ordered document plugin registry for this editor.

propertyreadonly render: { context: RenderContext; engine: DocRenderEngineCapability }

Document render services and visible context.

propertyreadonly scroll: { manager: ScrollManager }

Scroll state shared by document layout and rendering.

propertyreadonly session: SessionStateRegistry

Local remount state contributed by built-in and third-party plugins.

propertyreadonly textShaper: TextShaper

Text shaper used by document layout and rendering.

interfaceDocPluginRuntimeContext
interface DocPluginRuntimeContext extends DocPluginSetupContext

Document setup capabilities plus the Core created by createDocEditor().

propertyreadonly core: SearCoreDoc

Core document runtime.

Inherited members 2

Inherited from DocPluginSetupContext.

interfaceDocPluginServiceContext

Services available while createDocEditor() registers document plugins.

propertyreadonly container: Container

DI container used by the document assembly root.

interfaceDocPluginSetupContext

Typed public services available before createDocEditor() starts Core.

propertyreadonly container: Container

DI container used by the document assembly root.

propertyreadonly runtime: DocPluginRuntime

Runtime services available to document plugins.

typeDocRuntimeCapabilityReader
type DocRuntimeCapabilityReader = RuntimeCapabilityReader

Read-only view of editor-local document runtime capabilities exposed to hosts.

typeDocRuntimeCapabilityToken
type DocRuntimeCapabilityToken = RuntimeCapability<T>

Typed token used to publish and consume document runtime capabilities.

variableDocCaretPluginKey
DocCaretPluginKey: PluginKey
variableDocCompositionPluginKey
DocCompositionPluginKey: PluginKey
variableDocContentRenderPluginKey
DocContentRenderPluginKey: PluginKey

Default document feature plugin keys used by command pipelines.

variableDocPluginRuntimeCapability
DocPluginRuntimeCapability: { CaretState: DocRuntimeCapability<DocCaretStateCapability>; Composition: DocRuntimeCapability<DocCompositionManager>; InputBindings: DocRuntimeCapability<DocInputBindingRegistryCapability>; Interaction: DocRuntimeCapability<DocInteractionRuntime> }

Runtime extension tokens owned by document plugins assembled by editor composition roots.

variableDocRuntimeCapability
DocRuntimeCapability: { BlockFlows: DocRuntimeCapability<RichTextBlockFlowRegistry>; Commands: DocRuntimeCapability<DocCommandBus>; Config: DocRuntimeCapability<ConfigEngine<any>>; Document: DocRuntimeCapability<{ blockFlows: RichTextBlockFlowRegistry; core: SearCoreDoc; cursor: DocCursorManager; inlineStyles: RichTextInlineStyleRegistry; input: DocInputPlugin; layout: DocLayoutEngine; lineBoxes: RichTextLineBoxRegistry; nodes: DocNodeRegistry }>; Events: DocRuntimeCapability<{ engine: EventEngine<NodeProperties>; registrar: EventRegistrar }>; InlineStyles: DocRuntimeCapability<RichTextInlineStyleRegistry>; Input: DocRuntimeCapability<{ keyboard: KeyboardRouter; pointer: PointerCapture; text: TextInput }>; LayoutService: DocRuntimeCapability<DocRenderLayoutServiceCapability>; … }

Document runtime capabilities registered by the default assembly root.

variableDocSelectionPluginKey
DocSelectionPluginKey: PluginKey

Document input

interfaceDocCaretStateCapability

Caret-state capability consumed by document plugins.

interfaceDocInteractionContentRect
interface DocInteractionContentRect extends DocInteractionViewport

Current document content rectangle exposed to interaction plugins.

Inherited members 2

Inherited from DocInteractionViewport.

interfaceDocInteractionViewport

Current document viewport model exposed to interaction plugins.

interfaceDocKeyboardHandlerRegistrationContext

Services available while a Doc plugin registers keyboard bindings.

propertyreadonly bindings: DocInputBindingRegistryCapability

Aggregates plugin-owned keyboard handlers for the host adapter.

propertyreadonly commands: DocCommandBus

Executes semantic editor commands from keyboard handlers.

interfaceDocPointerDragHandlers

Document pointer-drag lifecycle consumed by interaction plugins.

interfaceDocPointerInput

Pointer input used by document interaction plugins.

Document rendering

interfaceDocRenderEngineCapability

Render-engine surface exposed to Doc plugins.

typeDocVirtualLayoutRenderPhase
type DocVirtualLayoutRenderPhase = "initial" | "realtime"

Render phase reported by virtual document layout instrumentation.

typeDocVirtualLayoutSummaryListener
type DocVirtualLayoutSummaryListener = (summary: DocVirtualLayoutSummary): void

Listener notified when the virtual layout summary changes.

Register document extensions

Use DocNodeRegistry for document node creation, RichTextInlineStyleRegistry for inline style behavior, RichTextLineBoxRegistry for line layout, and RichTextBlockFlowRegistry for block flow. A Doc plugin registers its own contributions at assembly time. DocRuntimeExtensionRegistry exposes editor-local capabilities needed by plugins and hosts without sharing one global runtime.

functioncreateDocCommand
createDocCommand(id: string, renderPluginKey: PluginKey | readonly PluginKey[], createTransaction?: (): Transaction, effects?: readonly DocCommandEffect[] | undefined, localAction?: (): void): DocEditorCommand

Creates a pipeline-backed document command with an optional transaction or local action.

functiondefineDocRuntimeCapability
defineDocRuntimeCapability<T>(id: string): DocRuntimeCapability<T>

Creates a typed document runtime capability token.

functionregisterDocPluginBlockFlows
registerDocPluginBlockFlows(plugins: readonly unknown[], registry: RichTextBlockFlowRegistry): (): void

Registers every top-level block flow contribution owned by document plugins.

functionregisterDocPluginCapabilities
registerDocPluginCapabilities(plugins: readonly unknown[], registry: DocRuntimeExtensionRegistry): void

Publishes every typed runtime capability contributed by document plugins.

functionregisterDocPluginCommands
registerDocPluginCommands(plugins: readonly unknown[], commands: DocCommandBus): (): void
functionregisterDocPluginInlineStyleRenderers
registerDocPluginInlineStyleRenderers(plugins: readonly unknown[], registry: RichTextRunRenderRegistry): (): void

Registers every rich-text run renderer contributed by document plugins.

functionregisterDocPluginInlineStyles
registerDocPluginInlineStyles(plugins: readonly unknown[], registry: RichTextInlineStyleRegistry): (): void

Registers every inline text-style contribution owned by document plugins.

functionregisterDocPluginKeyboardHandlers
registerDocPluginKeyboardHandlers(plugins: readonly unknown[], context: DocKeyboardHandlerRegistrationContext): (): void

Registers every keyboard binding contributed by document plugins.

functionregisterDocPluginLineBoxes
registerDocPluginLineBoxes(plugins: readonly unknown[], registry: RichTextLineBoxRegistry): (): void

Registers every rich-text line box contribution owned by document plugins.

functionregisterDocPluginObservations
registerDocPluginObservations(plugins: readonly unknown[], observations: ObservationRegistry): void

Registers every typed observation source contributed by document plugins.

functionregisterDocPluginSessionStates
registerDocPluginSessionStates(plugins: readonly unknown[], registry: SessionStateRegistry): void

Registers every local session-state adapter contributed by document plugins.

Blocks and tables

classParagraphPlugin
class ParagraphPlugin extends DocPlugin<null>

Registers paragraph and text node model support plus block-level commands.

constructorParagraphPlugin(): ParagraphPlugin
propertyreadonly symbol: typeof symbolstatic

DI token for resolving ParagraphPlugin.

methodapply(_state: null, _transaction: unknown): null

Applies a transaction to plugin-owned state and returns the next state.

methodconfigure(context: DocPluginSetupContext): void

Configures the document editor before runtime start.

methodgetPluginConfig(): null

Returns this plugin's runtime configuration view for the current core.

methodonEditorDestroy(): void

Releases resources owned by this plugin before the Core is destroyed.

methodregisterBlockFlows(registry: RichTextBlockFlowRegistry): void

Registers plugin-owned top-level block flow resolvers.

methodregisterCommands(commands: DocCommandBus): void

Registers every stable command id owned by this document plugin.

methodregisterKeyboardHandlers(__namedParameters: DocKeyboardHandlerRegistrationContext): void

Registers keyboard-to-command bindings owned by this document plugin.

methodregisterLineBoxes(registry: RichTextLineBoxRegistry): void

Registers plugin-owned rich-text line box resolvers.

methodregisterState(): { key: PluginKey; state: null }

Registers one or more plugin-owned state records with the host manager.

methodrender(): Node<NodeProperties>[] | null

Produces scene nodes owned by this plugin for the current core state.

methodregisterServices(context: DocPluginServiceContext): voidstatic

Registers paragraph node model support owned by this plugin.

Inherited members 37

Inherited from DocPlugin.

classTablePlugin
class TablePlugin extends DocPlugin<null>

Contributes table model and insertion command without adding table knowledge to Core.

constructorTablePlugin(): TablePlugin
propertyreadonly symbol: typeof symbolstatic

DI token for resolving TablePlugin.

methodapply(_state: null, _transaction: unknown): null

Applies a transaction to plugin-owned state and returns the next state.

methodconfigure(context: DocPluginSetupContext): void

Configures the document editor before runtime start.

methodgetPluginConfig(): null

Returns this plugin's runtime configuration view for the current core.

methodonEditorDestroy(): void

Releases resources owned by this plugin before the Core is destroyed.

methodregisterCommands(commands: DocCommandBus): void

Registers every stable command id owned by this document plugin.

methodregisterState(): { key: PluginKey; state: null }

Registers one or more plugin-owned state records with the host manager.

methodrender(): Node<NodeProperties>[] | null

Produces scene nodes owned by this plugin for the current core state.

methodregisterServices(context: DocPluginServiceContext): voidstatic

Registers table node model support owned by this plugin.

Inherited members 40

Inherited from DocPlugin.

classRichTextLineBoxPlugin
class RichTextLineBoxPlugin extends DocPlugin<null>

Registers rich-text line box resolution for document layout.

constructorRichTextLineBoxPlugin(): RichTextLineBoxPlugin
propertyreadonly symbol: typeof symbolstatic

DI token for resolving RichTextLineBoxPlugin.

methodapply(_state: null, _transaction: unknown): null

Applies a transaction to plugin-owned state and returns the next state.

methodgetPluginConfig(): null

Returns this plugin's runtime configuration view for the current core.

methodregisterLineBoxes(registry: RichTextLineBoxRegistry): void

Registers plugin-owned rich-text line box resolvers.

methodregisterState(): { key: PluginKey; state: null }

Registers one or more plugin-owned state records with the host manager.

methodrender(): Node<NodeProperties>[] | null

Produces scene nodes owned by this plugin for the current core state.

Inherited members 43

Inherited from DocPlugin.

interfaceInsertDocTableInput

Input accepted by InsertDocTableCommand.

propertyreadonly columns: number

Number of columns in the inserted table.

propertyreadonly rows: number

Number of rows in the inserted table.

interfaceSetDocLineSpacingInput

Input accepted by SetDocLineSpacingCommand. Null clears the paragraph override.

interfaceSetDocParagraphSpacingAfterInput

Input accepted by SetDocParagraphSpacingAfterCommand. Null clears the paragraph override.

variableInsertDocTableCommand
InsertDocTableCommand: DocCommandDefinition<InsertDocTableInput, DocCommandResult>

Inserts a table block at the current document position.

variableSetDocLineSpacingCommand
SetDocLineSpacingCommand: DocCommandDefinition<SetDocLineSpacingInput, DocCommandResult>

Sets or clears line-spacing overrides on the selected paragraphs.

variableSetDocParagraphSpacingAfterCommand
SetDocParagraphSpacingAfterCommand: DocCommandDefinition<SetDocParagraphSpacingAfterInput, DocCommandResult>

Sets or clears after-spacing overrides on the selected paragraphs.

variableSplitDocParagraphCommand
SplitDocParagraphCommand: DocCommandDefinition<void, DocCommandResult>

Splits the current paragraph at the current document selection.

Text style definitions

Style keys identify the attributes stored on inline text runs.

enumBoldTextStyleKey

Persisted style key owned by the bold text-style plugin.

enum memberBold: "bold"
enumFontFamilyTextStyleKey

Persisted style key owned by the font-family text-style plugin.

enumFontSizeTextStyleKey

Persisted style key owned by the font-size text-style plugin.

enumTextColorStyleKey

Persisted style key owned by the text-color style plugin.

enum memberColor: "color"
classInlineTextStylePluginBase
class InlineTextStylePluginBase extends DocPlugin<null>

Shared lifecycle helper for concrete inline style plugins.

methodapply(_state: null, _transaction: unknown): null

Applies a transaction to plugin-owned state and returns the next state.

methodconfigure(context: DocPluginSetupContext): void

Configures the document editor before runtime start.

methodgetPluginConfig(): null

Returns this plugin's runtime configuration view for the current core.

methodonEditorDestroy(): void

Releases resources owned by this plugin before the Core is destroyed.

methodregisterInlineStyleRenderers(registry: RichTextRunRenderRegistry): void

Registers plugin-owned render behavior for styled text runs.

methodregisterInlineStyles(registry: RichTextInlineStyleRegistry): void

Registers plugin-owned inline text style readers and mutation policies.

methodregisterState(): { key: PluginKey; state: null }

Registers one or more plugin-owned state records with the host manager.

methodrender(): Node<NodeProperties>[] | null

Produces scene nodes owned by this plugin for the current core state.

Inherited members 40

Inherited from DocPlugin.

Style commands

interfaceSetDocBoldInput

Input accepted by SetDocBoldCommand. A null or false value clears bold.

interfaceSetDocFontFamilyInput

Input accepted by SetDocFontFamilyCommand. A null or empty value clears the font family.

interfaceSetDocFontSizeInput

Input accepted by SetDocFontSizeCommand. A null or empty value clears the font size.

interfaceSetDocTextColorInput

Input accepted by SetDocTextColorCommand. A null or empty value clears the text color.

variableSetDocBoldCommand
SetDocBoldCommand: DocCommandDefinition<SetDocBoldInput, DocCommandResult>

Sets whether the selected document text is bold.

variableSetDocFontFamilyCommand
SetDocFontFamilyCommand: DocCommandDefinition<SetDocFontFamilyInput, DocCommandResult>

Sets the font family on the selected document text.

variableSetDocFontSizeCommand
SetDocFontSizeCommand: DocCommandDefinition<SetDocFontSizeInput, DocCommandResult>

Sets the font size in pixels on the selected document text.

variableSetDocItalicCommand
SetDocItalicCommand: DocCommandDefinition<SetDocItalicInput, DocCommandResult>
variableSetDocStrikethroughCommand
SetDocStrikethroughCommand: DocCommandDefinition<SetDocStrikethroughInput, DocCommandResult>
variableSetDocTextColorCommand
SetDocTextColorCommand: DocCommandDefinition<SetDocTextColorInput, DocCommandResult>

Sets the text color on the selected document text.

variableSetDocUnderlineCommand
SetDocUnderlineCommand: DocCommandDefinition<SetDocUnderlineInput, DocCommandResult>
variableToggleDocBoldCommand
ToggleDocBoldCommand: DocCommandDefinition<void, DocCommandResult>

Toggles bold on the selected document text.

variableToggleDocItalicCommand
ToggleDocItalicCommand: DocCommandDefinition<void, DocCommandResult>
variableToggleDocStrikethroughCommand
ToggleDocStrikethroughCommand: DocCommandDefinition<void, DocCommandResult>
variableToggleDocUnderlineCommand
ToggleDocUnderlineCommand: DocCommandDefinition<void, DocCommandResult>

Style contributions

functioncreateBoldContribution
createBoldContribution(): RichTextInlineStyleContribution

Creates the shared bold inline style contribution.

functioncreateBoldRenderContribution
createBoldRenderContribution(): RichTextRunRenderContribution

Creates the render-layer bold contribution.

functioncreateFontFamilyContribution
createFontFamilyContribution(): RichTextInlineStyleContribution

Creates the shared font-family inline style contribution.

functioncreateFontFamilyRenderContribution
createFontFamilyRenderContribution(): RichTextRunRenderContribution

Creates the render-layer font-family contribution.

functioncreateFontSizeContribution
createFontSizeContribution(): RichTextInlineStyleContribution

Creates the shared font-size inline style contribution.

functioncreateFontSizeRenderContribution
createFontSizeRenderContribution(): RichTextRunRenderContribution

Creates the render-layer font-size contribution.

functioncreateItalicContribution
createItalicContribution(): RichTextInlineStyleContribution
functioncreateItalicRenderContribution
createItalicRenderContribution(): RichTextRunRenderContribution

Creates the render-layer italic contribution.

functioncreateStrikethroughContribution
createStrikethroughContribution(): RichTextInlineStyleContribution
functioncreateStrikethroughRenderContribution
createStrikethroughRenderContribution(): RichTextRunRenderContribution

Creates the render-layer strikethrough contribution.

functioncreateTextColorContribution
createTextColorContribution(): RichTextInlineStyleContribution

Creates the shared text-color inline style contribution.

functioncreateTextColorRenderContribution
createTextColorRenderContribution(): RichTextRunRenderContribution

Creates the render-layer text-color contribution.

functioncreateUnderlineContribution
createUnderlineContribution(): RichTextInlineStyleContribution
functioncreateUnderlineRenderContribution
createUnderlineRenderContribution(): RichTextRunRenderContribution

Creates the render-layer underline contribution.

Editing commands

interfaceInsertDocTextInput

Input accepted by InsertDocTextCommand.

propertyreadonly text: string

Text to insert at the current document selection.

interfaceLoadDocumentInput

Input accepted by LoadDocumentCommand.

propertyreadonly document: RichDocNode[]

Rich-document content to load into the document editor.

interfaceMoveDocCursorInput

Input accepted by MoveDocCursorCommand.

propertyreadonly direction: DocCursorDirection

Direction for cursor movement.

propertyreadonly shiftKey?: boolean

Whether the movement should extend the current selection.

interfaceSetDocCompositionInput

Input accepted by SetDocCompositionCommand.

propertyreadonly caretOffset: number

Caret offset inside the composing text.

propertyreadonly text: string

Current composing text emitted by the host input method.

interfaceSetDocSelectionInput

Input accepted by SetDocSelectionCommand.

propertyreadonly selection: DocSelection

Selection to make active in the document editor.

variableClearDocCompositionCommand
ClearDocCompositionCommand: DocCommandDefinition<void, DocCommandResult>

Clears the active IME composition preview text.

variableDeleteDocBackwardCommand
DeleteDocBackwardCommand: DocCommandDefinition<void, DocCommandResult>

Deletes content before the current document selection.

variableFocusDocCommand
FocusDocCommand: DocCommandDefinition<void, DocCommandResult>

Focuses the host text-input adapter for the document editor.

variableInsertDocTextCommand
InsertDocTextCommand: DocCommandDefinition<InsertDocTextInput, DocCommandResult>

Inserts text at the current document selection.

variableLoadDocumentCommand
LoadDocumentCommand: DocCommandDefinition<LoadDocumentInput, DocCommandResult>

Replaces the active document content.

variableMoveDocCursorCommand
MoveDocCursorCommand: DocCommandDefinition<MoveDocCursorInput, DocCommandResult>

Moves the current document cursor.

variableRenderDocCommand
RenderDocCommand: DocCommandDefinition<void, DocCommandResult>

Requests a document render without changing content.

variableSelectAllDocCommand
SelectAllDocCommand: DocCommandDefinition<void, DocCommandResult>

Selects all document content.

variableSetDocCompositionCommand
SetDocCompositionCommand: DocCommandDefinition<SetDocCompositionInput, DocCommandResult>

Sets the active IME composition preview text.

variableSetDocSelectionCommand
SetDocSelectionCommand: DocCommandDefinition<SetDocSelectionInput, DocCommandResult>

Sets the active document selection without changing content.