trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
42 lines • 2.2 kB
TypeScript
/**
* Editor core — headless rich text behind the standard bridge
* (ADR 0034 wedge 4).
*
* Framework-free, DOM-free, timer-free: the document model is ProseMirror
* (adopted per ADR 0034 §4.2 — pure state, runs in Node), wrapped behind
* the HeadlessCore contract so every behavior is deterministic. The
* Trellis-specific layer is built:
*
* - the schema is descriptor-driven: `EditorSchemaConfig` picks the
* block/mark surface from the adopted schema (the same shape as the
* forms-descriptor generator — per-surface constraints);
* - the document is core data: `state.doc` is ProseMirror node JSON —
* the descriptor shape, one op to persist (EQL-S write surface);
* - `undoHistory` composes the undo-history service core: every
* mutation pushes one reversible command (full doc snapshots), and
* consecutive `type()` calls coalesce into one undo step (typing
* bursts); `canUndo`/`canRedo` are projected live, even for external
* pushes on the composed core.
*
* Selections are expressed in document-text offsets (offsets into
* `state.text`), independent of block structure: PM's gap positions are
* normalized so the same offset means the same caret, whether the
* selection spans blocks or sits in a gap.
*
* The DOM view (caret, input events, IME) is the visual runtime's job —
* the adapters expose the core for view binding; ProseMirror's built-in
* history is not used (the shared undo-history core owns the stack).
*
* const undo = createUndoHistoryCore();
* const editor = createEditorCore({ undoHistory: undo });
* editor.actions.type('hello');
* editor.actions.setSelection(0, 5);
* editor.actions.toggleMark('strong');
* editor.actions.undo(); // one step back through the burst
*
* @module trellis/editor
*/
import type { EditorConfig, UseEditorReturn } from './types.js';
export type { BlockType, EditorActions, EditorConfig, EditorDocJSON, EditorSchemaConfig, EditorSelection, EditorState, MarkType, UndoCommandLike, UndoLike, UseEditorReturn, } from './types.js';
export declare function createEditorCore(config?: EditorConfig): UseEditorReturn;
//# sourceMappingURL=index.d.ts.map