API reference
@searsuite/sear-domain-commands
Typed command definitions and the editor-local command bus contract.
14 exportsderived from source
- enumDocTransactionRenderOperationTypesource ↗
-
enum DocTransactionRenderOperationTypeRender pipeline effect declared by a document command transaction.
- classDocTransactionsource ↗
-
class DocTransactionBuilder 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.
constructorconstructor DocTransaction(): DocTransactionpropertymeta readonly meta: Record<string, unknown>Command metadata consumed by the document editor host.
propertyrenderOperationType readonly renderOperationType: DocTransactionRenderOperationTypeRender pipeline effect produced by this document transaction.
propertysteps readonly steps: DocStep[]Ordered steps produced by the command.
methodaddStep addStep(step: DocStep): thisAppends a prepared document step.
ReturnsThe current transaction for chaining.
step: DocStepStep to run during transaction application.
methoddeleteNode deleteNode(path: number[], nodeSnapshot: NodeSchema): thisAppends a node deletion step.
ReturnsThe current transaction for chaining.
path: number[]Path of the node to delete.
nodeSnapshot: NodeSchemaDeleted node payload used for OT inversion.
methoddeleteText deleteText(path: number[], offset: number, text: string): thisAppends a text deletion step.
ReturnsThe current transaction for chaining.
path: number[]Path to the text node.
offset: numberString offset where deletion starts.
text: stringExact text expected to be deleted.
methodgetMeta getMeta<T>(key: string): T | undefinedReads command metadata by key.
ReturnsThe stored value when present.
key: stringMetadata key.
methodinsertNode insertNode(path: number[], node: NodeSchema): thisAppends a node insertion step.
ReturnsThe current transaction for chaining.
path: number[]Target insertion path.
node: NodeSchemaNode payload to insert.
methodinsertText insertText(path: number[], offset: number, text: string): thisAppends a text insertion step.
ReturnsThe current transaction for chaining.
path: number[]Path to the text node.
offset: numberString offset where text is inserted.
text: stringText to insert.
methodsetInlineTextStyle 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.
doc: RichDocNode[]selection: DocSelectionproperty: stringvalue: unknownpatchAttrs: InlineTextRangeAttrsPatcher
methodsetMeta setMeta(key: string, value: unknown): thisStores command metadata.
ReturnsThe current transaction for chaining.
key: stringMetadata key.
value: unknownMetadata value.
methodsetSelection setSelection(sel: DocSelection): thisAppends a selection-only step.
ReturnsThe current transaction for chaining.
sel: DocSelectionSelection that should be active after this transaction.
methodupdateAttrs updateAttrs(path: number[], key: string, value: unknown, prev: unknown): thisAppends one attribute update operation and retains its previous value for inversion.
path: number[]key: stringvalue: unknownprev: unknown
- classReflowDocTransactionsource ↗
-
class ReflowDocTransaction extends DocTransactionDocument transaction whose RichDoc OT operations may change layout measurement.
constructorconstructor ReflowDocTransaction(): ReflowDocTransactionpropertyrenderOperationType readonly renderOperationType: ReflowRender pipeline effect produced by this document transaction.
Inherited members 12
Inherited from DocTransaction.
- classRepaintDocTransactionsource ↗
-
class RepaintDocTransaction extends DocTransactionDocument transaction whose RichDoc OT operations only require repainting existing layout.
constructorconstructor RepaintDocTransaction(): RepaintDocTransactionpropertyrenderOperationType readonly renderOperationType: RepaintRender pipeline effect produced by this document transaction.
Inherited members 12
Inherited from DocTransaction.
- interfaceDocCommandContextsource ↗
-
interface DocCommandContextRuntime state available while a rich-document command builds a transaction.
propertydocSelection docSelection: DocSelectionCurrent document selection before the command applies.
propertylastSnapshot lastSnapshot: LayoutSnapshot | nullLast measured layout snapshot, required for vertical cursor movement.
propertypendingDoc pendingDoc: RichDocNode[]Pending document tree used for reads before the transaction is committed.
propertypreferredX preferredX: number | nullPreferred horizontal position used by repeated vertical cursor navigation.
- interfaceDocStepsource ↗
-
interface DocStepOne atomic document transaction step with its selection mapping logic.
propertyops ops: RichDocOTOperation[]Rich-document OT operations produced by this step.
methodmapSelection mapSelection(sel: DocSelection, newDoc: RichDocNode[]): DocSelectionMaps an existing selection through the step.
ReturnsSelection rebased onto newDoc.
sel: DocSelectionSelection before this step.
newDoc: RichDocNode[]Document state after this step.
- typeDocCommandsource ↗
-
type DocCommand = (tr: DocTransaction, state: DocCommandContext): DocTransactionRich-document command that appends steps to a transaction.
- typeDocCursorDirectionsource ↗
-
type DocCursorDirection = typeof DocCursorDirection[keyof typeof DocCursorDirection]Union of cursor directions accepted by rich-document navigation.
- variableDocCursorDirectionsource ↗
-
DocCursorDirection: { Down: "down"; Left: "left"; Right: "right"; Up: "up" }Cardinal directions accepted by rich-document cursor navigation commands.
- functiondeleteBackwardCommandsource ↗
-
deleteBackwardCommand(): DocCommandCreates a command for Backspace behavior.
ReturnsCommand that deletes a selection, deletes the previous character, or merges with the previous paragraph.
- functioninputCommandsource ↗
-
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.
text: stringText to insert into the rich document.
- functionmoveCursorCommandsource ↗
-
moveCursorCommand(direction: DocCursorDirection, shiftKey: boolean, layoutEngine: DocLayoutEngine): DocCommandCreates a command for arrow-key cursor movement.
ReturnsSelection-only command with the computed cursor or range.
direction: DocCursorDirectionNavigation direction.
shiftKey: booleanWhether the movement should extend selection.
layoutEngine: DocLayoutEngineLayout engine used for vertical line navigation.
- functionselectAllCommandsource ↗
-
selectAllCommand(): DocCommandCreates a command that selects the complete rich document.
ReturnsSelection-only command spanning the first text node to the last text node.
- functionsplitParagraphCommandsource ↗
-
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 public exports match that search.