PreviewUpdateService.getSourceSyncData
How to read this API
These are TypeScript APIs compiled into SnapTeX; a .tex project cannot load them at runtime.
function name(...)is a helper that your rule imports and calls.apply(...),render(...),extract(...), andcollect(...)are callbacks that your rule implements and SnapTeX calls.renderer.name(...),context.name(...),input.name(...), anddeps.name(...)are methods SnapTeX supplies to callbacks; do not import or construct them.service.name(...)is an instance method called after your host or test constructsPreviewUpdateService.
Register extension declarations through SNAP_TEX_RULES in src/rules.ts. See Source API Scope for imports, value ownership, output safety, rebuilds, and testing.
Maps a preview position back to source synchronization data.
Signature
ts
service.getSourceSyncData(
blockIndex: number,
ratio: number,
options?: {
anchors?: readonly string[];
sourceStart?: number;
sourceEnd?: number;
}
)Parameters
ratio is the vertical position within the rendered block. options.sourceStart and options.sourceEnd provide an exact AST source span; when no span is available, options.anchors refines the ratio estimate with nearby text.
Call relationships
- Delegates to:
SmartRenderer.getSourceSyncData. - Reads: current block map and stored sync hints.
- Does not: trigger parsing or rendering.
Call it after render, using a block index from the current payload.
Returns
A SourceLocation containing file and line; returns null when no current mapping exists.