@searsuite/sear-domain-commands
Typed command definitions and the editor-local command bus contract.
Document transactions
- enumDocTransactionRenderOperationType
-
Render pipeline effect declared by a document command transaction.
enum member Reflow: "reflow"enum member Repaint: "repaint" - classDocTransaction
-
Builder for rich-document command transactions.
Commands append document OT steps and selection mapping metadata here. The caller later applies the steps through the editor pipeline.
constructor DocTransaction(): DocTransactionproperty readonly meta: Record<string, unknown>Command metadata consumed by the document editor host.
property readonly renderOperationType: DocTransactionRenderOperationTypeRender pipeline effect produced by this document transaction.
property readonly steps: DocStep[]Ordered steps produced by the command.
method addStep(step: DocStep): thisAppends a prepared document step.
ReturnsThe current transaction for chaining.
stepStep to run during transaction application.
method deleteNode(path: number[], nodeSnapshot: NodeSchema): thisAppends a node deletion step.
ReturnsThe current transaction for chaining.
pathPath of the node to delete.
nodeSnapshotDeleted node payload used for OT inversion.
method deleteText(path: number[], offset: number, text: string): thisAppends a text deletion step.
ReturnsThe current transaction for chaining.
pathPath to the text node.
offsetString offset where deletion starts.
textExact text expected to be deleted.
method getMeta<T>(key: string): T | undefinedReads command metadata by key.
ReturnsThe stored value when present.
keyMetadata key.
method insertNode(path: number[], node: NodeSchema): thisAppends a node insertion step.
ReturnsThe current transaction for chaining.
pathTarget insertion path.
nodeNode payload to insert.
method insertText(path: number[], offset: number, text: string): thisAppends a text insertion step.
ReturnsThe current transaction for chaining.
pathPath to the text node.
offsetString offset where text is inserted.
textText to insert.
method setInlineTextStyle(doc: RichDocNode[], selection: DocSelection, property: string, value: unknown, patchAttrs?: InlineTextRangeAttrsPatcher): thisApplies one inline text-style property to the selected range using RichDoc OT operations.
method setMeta(key: string, value: unknown): thisStores command metadata.
ReturnsThe current transaction for chaining.
keyMetadata key.
valueMetadata value.
method setSelection(sel: DocSelection): thisAppends a selection-only step.
ReturnsThe current transaction for chaining.
selSelection that should be active after this transaction.
method updateAttrs(path: number[], key: string, value: unknown, prev: unknown): thisAppends one attribute update operation and retains its previous value for inversion.
- classReflowDocTransaction
-
class ReflowDocTransaction extends DocTransactionDocument transaction whose RichDoc OT operations may change layout measurement.
constructor ReflowDocTransaction(): ReflowDocTransactionproperty readonly renderOperationType: ReflowRender pipeline effect produced by this document transaction.
Inherited members 12
Inherited from DocTransaction.
- classRepaintDocTransaction
-
class RepaintDocTransaction extends DocTransactionDocument transaction whose RichDoc OT operations only require repainting existing layout.
constructor RepaintDocTransaction(): RepaintDocTransactionproperty readonly renderOperationType: RepaintRender pipeline effect produced by this document transaction.
Inherited members 12
Inherited from DocTransaction.
- interfaceDocCommandContext
-
Runtime state available while a rich-document command builds a transaction.
property docSelection: DocSelectionCurrent document selection before the command applies.
property lastSnapshot: LayoutSnapshot | nullLast measured layout snapshot, required for vertical cursor movement.
property pendingDoc: RichDocNode[]Pending document tree used for reads before the transaction is committed.
property preferredX: number | nullPreferred horizontal position used by repeated vertical cursor navigation.
- interfaceDocStep
-
One atomic document transaction step with its selection mapping logic.
property ops: RichDocOTOperation[]Rich-document OT operations produced by this step.
method mapSelection(sel: DocSelection, newDoc: RichDocNode[]): DocSelectionMaps an existing selection through the step.
ReturnsSelection rebased onto newDoc.
selSelection before this step.
newDocDocument state after this step.
- typeDocCommand
-
type DocCommand = (tr: DocTransaction, state: DocCommandContext): DocTransactionRich-document command that appends steps to a transaction.
- typeDocCursorDirection
-
type DocCursorDirection = typeof DocCursorDirection[keyof typeof DocCursorDirection]DocCursorDirection: { Down: "down"; Left: "left"; Right: "right"; Up: "up" }Union of cursor directions accepted by rich-document navigation.
Editing commands
- functiondeleteBackwardCommand
-
deleteBackwardCommand(): DocCommandCreates a command for Backspace behavior.
ReturnsCommand that deletes a selection, deletes the previous character, or merges with the previous paragraph.
- functioninputCommand
-
inputCommand(text: string): DocCommandCreates a command that inserts text at the current cursor or replaces a same-node selection.
ReturnsCommand that records text OT and collapses the selection after the insert.
textText to insert into the rich document.
- functionmoveCursorCommand
-
moveCursorCommand(direction: DocCursorDirection, shiftKey: boolean, layoutEngine: DocLayoutEngine): DocCommandCreates a command for arrow-key cursor movement.
ReturnsSelection-only command with the computed cursor or range.
directionNavigation direction.
shiftKeyWhether the movement should extend selection.
layoutEngineLayout engine used for vertical line navigation.
- functionselectAllCommand
-
selectAllCommand(): DocCommandCreates a command that selects the complete rich document.
ReturnsSelection-only command spanning the first text node to the last text node.
- functionsplitParagraphCommand
-
splitParagraphCommand(): DocCommandCreates a command that splits the current paragraph at the cursor.
ReturnsCommand that moves trailing text and nodes into a newly inserted paragraph.
No matching API entries.