API reference
@searsuite/sear-domain-editor
Editor-local query, observation, capability, and lifecycle contracts shared by facades.
28 exportsderived from source
- classArrayIndexedSnapshotsource ↗
-
class ArrayIndexedSnapshot<TSnapshot, TItem, TKey> extends IndexedSnapshot<TSnapshot, TItem, TKey>Array and Map backed implementation of IndexedSnapshot.
constructorconstructor ArrayIndexedSnapshot<TSnapshot, TItem, TKey>(snapshot: TSnapshot, items: readonly TItem[], getKey: (item: TItem): TKey, getIndex: (item: TItem): number): ArrayIndexedSnapshot<TSnapshot, TItem, TKey>Creates an indexed snapshot from ordered items and selector functions.
snapshot: TSnapshotitems: readonly TItem[]getKey: (item: TItem): TKeygetIndex: (item: TItem): number
methodgetByIndex getByIndex(index: number): TItem | nullReturns one item by its numeric index.
index: number
methodgetByKey getByKey(key: TKey): TItem | nullReturns one item by its stable key.
key: TKey
methodgetKeysByIndexes getKeysByIndexes(indexes: readonly number[]): readonly TKey[]Returns keys for the supplied numeric indexes, preserving input order.
indexes: readonly number[]
- classDocBlockLayoutDiffsource ↗
-
class DocBlockLayoutDiffCompares two block-layout snapshots and exposes render-neutral reuse facts.
constructorconstructor DocBlockLayoutDiff(entries: readonly DocBlockLayoutDiffEntry[]): DocBlockLayoutDiffentries: readonly DocBlockLayoutDiffEntry[]
propertyentries readonly entries: readonly DocBlockLayoutDiffEntry[]methodgetChangedEntries getChangedEntries(): readonly DocBlockLayoutDiffEntry[]methodgetEntry getEntry(id: DocNodeId): DocBlockLayoutDiffEntry | nullid: DocNodeId
methodgetReusableRasterCopies getReusableRasterCopies(): readonly DocBlockRasterReuse[]methodgetShiftedEntries getShiftedEntries(): readonly DocBlockLayoutDiffEntry[]methodhasChanges hasChanges(): booleanmethodcomparestatic compare(previous: DocLayoutCache | null, current: DocLayoutCache, options?: DocBlockLayoutDiffOptions): DocBlockLayoutDiffprevious: DocLayoutCache | nullcurrent: DocLayoutCacheoptions: DocBlockLayoutDiffOptions
- classDocLayoutCachesource ↗
-
class DocLayoutCacheImmutable snapshot of block-level document layout used by viewport and SceneGraph projection.
constructorconstructor DocLayoutCache(snapshot: LayoutSnapshot, blocksOrIndex: IndexedSnapshot<LayoutSnapshot, DocBlockLayout, DocNodeId> | readonly DocBlockLayout[]): DocLayoutCacheCreates a layout cache from already computed block records.
snapshot: LayoutSnapshotLayout snapshot used to derive this cache.
blocksOrIndex: IndexedSnapshot<LayoutSnapshot, DocBlockLayout, DocNodeId> | readonly DocBlockLayout[]Top-level block layout records ordered by document position, or a custom indexed store.
memberblocks blocks: unknownmembersnapshot snapshot: unknownmethodgetBlockById getBlockById(id: DocNodeId): DocBlockLayout | nullReturns the cached layout record for a document block id.
id: DocNodeId
methodgetBlockByIndex getBlockByIndex(index: number): DocBlockLayout | nullReturns the cached layout record for a top-level block index.
index: number
methodgetBlockIdsByIndexes getBlockIdsByIndexes(indexes: readonly number[]): readonly DocNodeId[]Returns block ids for the supplied top-level block indexes.
indexes: readonly number[]
methodgetBlocksInVerticalRange getBlocksInVerticalRange(top: number, bottom: number): readonly DocBlockLayout[]Returns all cached block records intersecting the supplied vertical range.
top: numberbottom: number
methodgetContentLayoutReusableBlockIndexes getContentLayoutReusableBlockIndexes(previous: DocLayoutCache): readonly number[]Returns block indexes whose internal content layout can be reused from a previous cache.
A downstream flow shift changes absolute
rect.y, so the whole block record cannot be reused. The renderer can still reuse the block's measured content shape when line count, visual size and flow height are unchanged.previous: DocLayoutCache
methodhasBlockFlowLayoutChanged hasBlockFlowLayoutChanged(previous: DocLayoutCache, blockId: DocNodeId): booleanReturns whether one block's height-sensitive flow layout changed.
previous: DocLayoutCacheblockId: DocNodeId
methodhasFlowHeightChanged hasFlowHeightChanged(previous: DocLayoutCache, blockId: DocNodeId): booleanReturns whether one block's flow height changed compared with another cache.
previous: DocLayoutCacheblockId: DocNodeId
methodfromSnapshotstatic fromSnapshot(document: readonly RichDocNode[], snapshot: LayoutSnapshot, previousCache?: DocLayoutCache | null): DocLayoutCacheBuilds a block layout cache from a rich document and its layout snapshot.
document: readonly RichDocNode[]snapshot: LayoutSnapshotpreviousCache: DocLayoutCache | null
- classDocLayoutEnginesource ↗
-
class DocLayoutEngineConverts between DocCursorPos (path + char offset) and pixel coordinates (relative to the editor box top-left corner), using rich-text block measurements.
Mirrors the Y-positioning formula used by the document render layout so that cursor positions align with rendered glyphs.
constructorconstructor DocLayoutEngine(blockFlowRegistry: RichTextBlockFlowRegistry): DocLayoutEngineblockFlowRegistry: RichTextBlockFlowRegistry
propertysymbolstatic readonly symbol: symbolDI token for resolving DocLayoutEngine.
methodbuildSnapshot buildSnapshot(doc: RichDocNode[], blockManager: RichTextBlockLayoutProvider, editorWidth: number, editorHeight: number, cellPadding?: number, verticalAlign?: DocVerticalAlign): LayoutSnapshotBuild a LayoutSnapshot from the current blockManager state.
Prerequisites: callers must add all document paragraphs to
blockManagerbefore building the snapshot.doc: RichDocNode[]The current RichDocNode[] being edited.
blockManager: RichTextBlockLayoutProviderLayout provider that already holds the paragraph blocks.
editorWidth: numberTotal pixel width of the editor box (including padding).
editorHeight: numberTotal pixel height of the editor box (including padding).
cellPadding: numberPadding on each side (default 4).
verticalAlign: DocVerticalAlignVertical positioning strategy (default center for embedded cell editors).
methodbuildSnapshotForBlocks buildSnapshotForBlocks(doc: RichDocNode[], blockManager: RichTextBlockLayoutProvider, blockIndexes: readonly number[], blockTops: readonly number[], editorWidth: number, cellPadding?: number): BlockLayoutSnapshotBuilds a snapshot for selected top-level document blocks.
The returned lines keep their full-document text paths, but only the requested blocks are materialized. Callers supply each block's document Y-position from a block-height index.
doc: RichDocNode[]blockManager: RichTextBlockLayoutProviderblockIndexes: readonly number[]blockTops: readonly number[]editorWidth: numbercellPadding: number
methodcursorToPoint cursorToPoint(pos: DocCursorPos, snapshot: LayoutSnapshot): { height: number; x: number; y: number }Convert a DocCursorPos to pixel coordinates relative to the editor box top-left corner.
Returns the position of the cursor bar's horizontal anchor (i.e. the x at which to draw the vertical cursor line, and the y passed to drawCursor), plus the line height needed to size the cursor bar.
pos: DocCursorPossnapshot: LayoutSnapshot
methodfindLineIndex findLineIndex(pos: DocCursorPos, snapshot: LayoutSnapshot): numberReturns the index into
snapshot.linesfor the line containingpos. Returns 0 if not found.pos: DocCursorPossnapshot: LayoutSnapshot
methodgetSelectionRects getSelectionRects(sel: DocSelection, snapshot: LayoutSnapshot, originX: number, originY: number): { height: number; width: number; x: number; y: number }[]Compute canvas-space rectangles for a non-collapsed DocSelection.
ReturnsArray of {x,y,width,height} rectangles in canvas coordinates.
sel: DocSelectionThe current DocSelection (anchor + head).
snapshot: LayoutSnapshotLayout snapshot from buildSnapshot.
originX: numberAbsolute canvas X of the editor box top-left.
originY: numberAbsolute canvas Y of the editor box top-left.
methodpointToCursor pointToCursor(px: number, py: number, snapshot: LayoutSnapshot): DocCursorPosConvert a pixel position (relative to the editor box top-left) to the nearest DocCursorPos.
Used for click-to-position-cursor and drag-selection.
px: numberpy: numbersnapshot: LayoutSnapshot
- classDocPageMapsource ↗
-
class DocPageMapMaps document blocks to pages for viewport range queries and virtualization.
constructorconstructor DocPageMap(pageHeight: number, pageGap: number, pages: readonly DocPageLayout[]): DocPageMapCreates a page map from immutable page records.
pageHeight: numberPage height used by this map.
pageGap: numberGap between pages in document coordinates.
pages: readonly DocPageLayout[]Ordered page layout records.
propertypageGap readonly pageGap: numberGap between pages in document coordinates.
propertypageHeight readonly pageHeight: numberPage height used by this map.
propertypages readonly pages: readonly DocPageLayout[]Ordered page layout records.
methodgetPage getPage(index: number): DocPageLayout | nullReturns a page record by index.
index: number
methodgetPageIndexesForBlock getPageIndexesForBlock(blockId: DocNodeId): readonly number[]Returns page indexes that intersect a block id.
blockId: DocNodeId
methodgetPagesByIndexes getPagesByIndexes(indexes: readonly number[]): readonly DocPageLayout[]Returns pages for the supplied page indexes, preserving page order.
indexes: readonly number[]
methodgetPagesForBlock getPagesForBlock(block: DocBlockLayout): readonly DocPageLayout[]Returns all pages intersecting a block layout record.
block: DocBlockLayout
methodgetPagesInVerticalRange getPagesInVerticalRange(top: number, bottom: number): readonly DocPageLayout[]Returns all pages intersecting the supplied vertical document range.
top: numberbottom: number
methodfromLayoutCachestatic fromLayoutCache(cache: DocLayoutCache, pageHeight: number, pageGap?: number): DocPageMapBuilds a page map by intersecting cached block rectangles with fixed-height pages.
cache: DocLayoutCachepageHeight: numberpageGap: number
- classDocViewportWindowsource ↗
-
class DocViewportWindowVisible document window used to filter block and page layout ranges.
constructorconstructor DocViewportWindow(x: number, y: number, width: number, height: number): DocViewportWindowCreates a viewport window from document-space rectangle coordinates.
x: numberLeft edge in document coordinates.
y: numberTop edge in document coordinates.
width: numberVisible width in document units.
height: numberVisible height in document units.
propertyheight readonly height: numberVisible height in document units.
propertywidth readonly width: numberVisible width in document units.
propertyx readonly x: numberLeft edge in document coordinates.
propertyy readonly y: numberTop edge in document coordinates.
memberbottom bottom: unknownmethodintersects intersects(rect: DocLayoutRect): booleanReturns whether this viewport intersects another document-space rectangle.
rect: DocLayoutRect
methodfromViewportstatic fromViewport(viewport: { contentRect: DocLayoutRect }, scroll?: { x: number; y: number }): DocViewportWindowCreates a document-space window from a viewport rectangle and scroll offsets.
viewport: { contentRect: DocLayoutRect }scroll: { x: number; y: number }
- classIndexedSnapshotsource ↗
-
class IndexedSnapshot<TSnapshot, TItem, TKey>Generic immutable snapshot plus ordered, multi-key indexed item access.
propertyitems readonly items: readonly TItem[]Items in their canonical order.
propertysnapshot readonly snapshot: TSnapshotmethodgetByIndex getByIndex(index: number): TItem | nullReturns one item by its numeric index.
index: number
methodgetByKey getByKey(key: TKey): TItem | nullReturns one item by its stable key.
key: TKey
methodgetKeysByIndexes getKeysByIndexes(indexes: readonly number[]): readonly TKey[]Returns keys for the supplied numeric indexes, preserving input order.
indexes: readonly number[]
- classSearEditorsource ↗
-
class SearEditorInjectable rich-document editor service placeholder.
The service owns document-editor initialization once a document assembly root is available. It is bound by symbol so consumers do not depend on string DI tokens.
constructorconstructor SearEditor(): SearEditorConstructs the editor service.
propertysymbolstatic readonly symbol: symbolDI token for resolving the editor service.
methodinitialize initialize(): voidInitializes document-editor runtime state.
- interfaceBlockLayoutSnapshotsource ↗
-
interface BlockLayoutSnapshotMaterialized layout for a subset of top-level document blocks.
- interfaceDocBlockLayoutsource ↗
-
interface DocBlockLayoutCached layout metadata for one top-level document block.
propertyflowHeight readonly flowHeight: numberFlow height from this block top to the next block top, or visual height for the last block.
propertyid readonly id: DocNodeIdStable block identity used by retained render nodes.
propertyindex readonly index: numberZero-based top-level document block index.
propertylineEnd readonly lineEnd: numberExclusive index after the last layout line belonging to this block.
propertylineStart readonly lineStart: numberInclusive index of the first layout line belonging to this block.
propertyrect readonly rect: DocLayoutRectDocument-space rectangle occupied by this block.
- interfaceDocBlockLayoutDiffEntrysource ↗
-
interface DocBlockLayoutDiffEntry - interfaceDocBlockLayoutDiffOptionssource ↗
-
interface DocBlockLayoutDiffOptionspropertyreflowBlockIds readonly reflowBlockIds?: ReadonlySet<DocNodeId>Reflow blocks whose render output changed even if their measured layout shape did not.
propertyrepaintBlockIds readonly repaintBlockIds?: ReadonlySet<DocNodeId>Repaint blocks whose render output changed without invalidating layout cache.
- interfaceDocBlockRasterReusesource ↗
-
interface DocBlockRasterReusepropertydestination readonly destination: DocLayoutRectpropertyid readonly id: DocNodeIdpropertyindex readonly index: numberpropertysource readonly source: DocLayoutRect - interfaceDocBlockRenderDebugCopysource ↗
-
interface DocBlockRenderDebugCopypropertydestination readonly destination: DocBlockRenderDebugRectpropertysource readonly source: DocBlockRenderDebugRect - interfaceDocBlockRenderDebugRectsource ↗
-
interface DocBlockRenderDebugRect - interfaceDocBlockRenderDebugSnapshotsource ↗
-
interface DocBlockRenderDebugSnapshotpropertychangedBlocks readonly changedBlocks: readonly DocBlockRenderDebugRect[]propertycopiedPixelArea readonly copiedPixelArea: numberpropertyframeMode readonly frameMode: DocBlockRenderFrameModepropertyincrementalRenderAccepted readonly incrementalRenderAccepted: booleanpropertyincrementalRenderCandidate readonly incrementalRenderCandidate?: DocBlockRenderPolicyCandidateDebugMetricspropertyincrementalRenderReason readonly incrementalRenderReason: stringpropertyinvalidRedrawRects readonly invalidRedrawRects: readonly DocBlockRenderDebugRect[]propertyrasterCopies readonly rasterCopies: readonly DocBlockRenderDebugCopy[]propertyredrawnBlockCount readonly redrawnBlockCount: numberpropertyreusedBlocks readonly reusedBlocks: readonly DocBlockRenderDebugRect[]propertyshiftedBlocks readonly shiftedBlocks: readonly DocBlockRenderDebugRect[]propertyskippedBlockCount readonly skippedBlockCount: number - interfaceDocBlockRenderPolicyCandidateDebugMetricssource ↗
-
interface DocBlockRenderPolicyCandidateDebugMetricspropertycopiedAreaRatio readonly copiedAreaRatio: numberpropertycopiedPixelArea readonly copiedPixelArea: numberpropertycopyCount readonly copyCount: numberpropertyinvalidAreaRatio readonly invalidAreaRatio: numberpropertyinvalidPixelArea readonly invalidPixelArea: numberpropertyinvalidRectCount readonly invalidRectCount: number - interfaceDocLayoutRectsource ↗
-
interface DocLayoutRectRectangle contract used by document layout planning without binding to a render target.
- interfaceDocPageLayoutsource ↗
-
interface DocPageLayoutLayout metadata for one document page.
- interfaceDocViewportRangesource ↗
-
interface DocViewportRangeInclusive visible block/page range within the current document viewport.
propertyendBlock readonly endBlock: numberLast top-level document block index included in the buffered viewport.
propertyendPage readonly endPage: numberLast page index included in the buffered viewport.
propertystartBlock readonly startBlock: numberFirst top-level document block index included in the buffered viewport.
propertystartPage readonly startPage: numberFirst page index included in the buffered viewport.
- interfaceDocViewportScrollSourcesource ↗
-
interface DocViewportScrollSourceMinimal scroll/viewport contract needed to compute a document viewport range.
- interfaceLayoutLinesource ↗
-
interface LayoutLineA single wrapped line inside the editor, with full path metadata for bidirectional cursor ↔ pixel coordinate mapping.
propertychars chars: RichTextChar[]Per-character measurements for this line.
propertycharStartOffset charStartOffset: numberChar offset (within the text node) of the FIRST character on this line. e.g. if a text node wraps at char 20, the second line has charStartOffset=20.
propertycursorXOffsets cursorXOffsets?: number[]Cursor boundary x offsets relative to this line's x, one entry per char boundary.
propertyfontAscent fontAscent: numberFont ascent: distance from baseline to top of tallest glyph on this line.
propertyheight height: numberLine height in CSS/canvas pixels.
propertytextNodePath textNodePath: number[]Full path to the text node this line belongs to.
For a flat document (paragraph → single text node):
textNodePath = [paraIndex, 0]The path mirrors
DocCursorPos.pathsemantics: a cursor at{ path: textNodePath, offset }lives on this line whencharStartOffset <= offset <= charStartOffset + chars.length.propertyx x: numberLeft edge of text, relative to editor box top-left (includes cellPadding).
propertyy y: numberY coordinate used for fillText/cursor drawing, relative to editor box top-left. This is the baseline consumed by document render nodes so cursor pixel coordinates align with rendered text.
- interfaceLayoutSnapshotsource ↗
-
interface LayoutSnapshotPre-computed layout for the entire editing session.
propertylines lines: LayoutLine[] - typeDocBlockLayoutDiffStatussource ↗
-
type DocBlockLayoutDiffStatus = "unchanged" | "shifted" | "changed" | "added" | "removed" - typeDocBlockRenderFrameModesource ↗
-
type DocBlockRenderFrameMode = "rebuild" | "full" | "scroll" | "block-copy" | "skipped" - typeDocVerticalAlignsource ↗
-
type DocVerticalAlign = "top" | "center"Vertical positioning strategy for a laid-out document frame.
- functioncomputeViewportRangesource ↗
-
computeViewportRange(scrollSource: DocViewportScrollSource, layoutCache: DocLayoutCache, pageMap: DocPageMap, offset?: { x: number; y: number }): DocViewportRangeComputes the visible document block/page range from scroll state and cached layout.
This mirrors Sheet's viewport-range helper at the responsibility level: convert viewport bounds to inclusive start/end indexes and include a one-item buffer on each side. Consumers decide how to query blocks/pages or render.
scrollSource: DocViewportScrollSourcelayoutCache: DocLayoutCachepageMap: DocPageMapoffset: { x: number; y: number }
- functionlockLayoutSnapshotsource ↗
-
lockLayoutSnapshot(snapshot: LayoutSnapshot): LayoutSnapshotLocks a completed layout so readers cannot change cursor or render geometry.
snapshot: LayoutSnapshot
No public exports match that search.