iink-ts - v4.0.0
    Preparing search index...

    Class IIJiixQueryManager

    Manager for querying JIIX export data efficiently Provides fast lookups for strokes, labels, and element groupings Automatically indexes JIIX data on first access and invalidates cache when model changes

    Hierarchy (View Summary)

    Index

    The Interactive Ink Canvas instance

    logger: Logger

    Logger instance for this manager Automatically uses LoggerCategory.MANAGER

    managerName: string = "IIJiixQueryManager"

    Name of the manager for logging purposes Must be overridden in concrete classes

    "IITypesetManager", "IIMathManager"
    
    • get client(): WebSocketClient

      Get the client from the canvas Convenience getter to avoid accessing canvas.client everywhere

      Returns WebSocketClient

    • get model(): IIModel

      Get the model from the canvas Convenience getter to avoid accessing canvas.model everywhere

      Returns IIModel

    • get renderer(): SVGRenderer

      Get the renderer from the canvas Convenience getter to avoid accessing canvas.renderer everywhere

      Returns SVGRenderer

    • Build or rebuild the JIIX index Called automatically when index is stale

      Returns void

    • Clear text metadata for a stroke (called when stroke is deleted)

      Parameters

      • strokeId: string

      Returns void

    • Recursively collect math expression groups with pixel bboxes

      Parameters

      Returns void

    • Destroy the manager and cleanup resources Calls the onDestroy hook if defined

      Returns void

    • Ensure index is up to date. When model.exports is absent (cleared by updateSymbol etc.) but a valid index exists, preserve it rather than overwriting with an empty rebuild.

      Returns void

    • Get all math blocks with their strokes

      Returns { mathBlock: TJIIXMathElement; strokeIds: string[]; strokes: TStroke[] }[]

      Array of math blocks with their JIIX element and stroke IDs

    • Get all text blocks with their strokes

      Returns { strokeIds: string[]; strokes: TStroke[]; textBlock: TJIIXTextElement }[]

      Array of text blocks with their JIIX element and stroke IDs

    • Get the label of a JIIX block by its ID

      Parameters

      • jiixBlockId: string

        The JIIX element ID

      Returns string | undefined

      The label of the block, or undefined if not found

    • Get the JIIX element containing a stroke

      Parameters

      • strokeId: string

        The stroke ID

      Returns TJIIXElement | undefined

      The JIIX element or undefined

    • Get statistics about the indexed JIIX

      Returns {
          byType: Record<string, number>;
          indexed: boolean;
          totalElements: number;
          totalStrokes: number;
      }

      Index statistics

    • Get the precise label for a stroke For text: returns char label if available, word label otherwise For math: returns expression label or type

      Parameters

      • strokeId: string

        The stroke ID

      Returns string | undefined

      The label or undefined

    • Get the pixel-space vertical center of the JIIX line containing the given stroke. Uses the line's bounding-box center, not baseline-y (baseline sits low within a line, not comparable to a symbol's bounds.center.y — mixing the two anchors misclassifies strokes near a line boundary as belonging to the wrong row). Returns null when the stroke isn't (yet) part of a recognized text word, so callers can fall back to a geometric row calculation.

      Parameters

      • strokeId: string

      Returns number | null

    • Get stroke groups with pixel bboxes for math selection. Only groups with valid bounding boxes are returned.

      Parameters

      • level: "operand" | "element"

        Selection granularity: "element" or "operand"

      Returns { bounds: TBox; strokeIds: string[] }[]

    • Get stroke groups with pixel bboxes for shape (Node/Edge) selection. "element" level: one group per Node/Edge element. "stroke" level: returns empty (signals fallback to stroke overlap).

      Parameters

      • level: "stroke" | "element"

        Selection granularity: "element" or "stroke"

      Returns { bounds: TBox; strokeIds: string[] }[]

    • Get the ids of the strokes that make up a given block

      Parameters

      • blockId: string

        The id of the JIIX element (block)

      Returns string[]

      Array of stroke ids, or an empty array if the block is unknown

    • Get detailed query result for a stroke

      Parameters

      • strokeId: string

        The stroke ID

      Returns TStrokeQueryResult | undefined

      Full query result with element, label, and context

    • Get all stroke IDs belonging to an element

      Parameters

      • elementId: string

        The JIIX element ID

      Returns string[]

      Array of stroke IDs

    • Get all strokes grouped by character (for text elements)

      Parameters

      • elementId: string

        The text element ID

      Returns { label: string; strokeIds: string[]; wordIndex: number }[]

      Array of char groups, each containing stroke IDs and label

    • Get all strokes grouped by word (for text elements)

      Parameters

      • elementId: string

        The text element ID

      Returns { label: string; strokeIds: string[] }[]

      Array of word groups, each containing stroke IDs and label

    • Get all TStroke objects belonging to an element

      Parameters

      • elementId: string

        The JIIX element ID

      Returns TStroke[]

      Array of TStroke symbols

    • Get pixel-converted text metadata for a stroke

      Parameters

      • strokeId: string

      Returns TBlockTextMetadata | undefined

    • Get stroke groups with pixel bboxes for text selection. Only groups with valid bounding boxes are returned.

      Parameters

      • level: "char" | "element" | "word"

        Selection granularity: "element", "word", or "char"

      Returns { bounds: TBox; strokeIds: string[] }[]

    • Get the JIIX word group for a stroke (for word-level decorator spanning). Returns all stroke IDs in the same word and the word's pixel bounding box.

      Parameters

      • strokeId: string

      Returns
          | {
              allStrokeIds: string[];
              baseline: number
              | null;
              wordBounds: TBox | null;
              wordKey: string;
              xHeight: number | null;
          }
          | null

    • Index a single JIIX element and its strokes

      Parameters

      Returns void

    • Index a math element

      Parameters

      Returns void

    • Index a text element

      Parameters

      Returns void

    • Invalidate and immediately rebuild the index from current exports. Called after mergeExport so the rebuild happens while exports are still set, before any subsequent updateSymbol calls clear them.

      Returns void

    • Lifecycle hook called when the manager is being destroyed Override in subclasses to cleanup resources

      Returns void

      protected onDestroy(): void {
      this.logger.info(`${this.managerName} destroyed`)
      // Remove event listeners, clear intervals, etc.
      }
    • Lifecycle hook called after manager initialization Override in subclasses if needed

      This is called at the end of the constructor, allowing subclasses to perform initialization that requires access to this.managerName or other properties set in the subclass constructor.

      Returns void

      protected onInit(): void {
      this.logger.info(`${this.managerName} initialized`)
      // Setup event listeners, etc.
      }
    • Search strokes by label

      Parameters

      • label: string

        The label to search for (case-insensitive partial match)

      Returns TStrokeQueryResult[]

      Array of matching stroke query results

    • Update pixel-converted text metadata for a stroke (called during sync)

      Parameters

      Returns void