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

    Class InkCanvas

    InkCanvas is the core canvas variant focused on freeform ink input, rendering, and recognition. It provides a rich API for managing strokes, exports, and canvas state, and serves as the foundation for more specialized canvas variants.

    Key features include:

    • Stroke management: Add, remove, and style ink strokes with real-time rendering.
    • Recognition integration: Seamlessly send ink data to the client and handle results.
    • Export capabilities: Support for exporting recognized content in various formats.
    • History management: Undo/redo functionality for stroke modifications and exports.
    • Tool support: Built-in tools for writing and erasing with customizable styles.

    The InkCanvas is designed for extensibility, allowing developers to override core components like the client or input grabber for custom behavior.

    Index
    client: HTTPClientV2
    eraser: EraseManager

    Event bus for subscribing to canvas lifecycle and content events.

    info?: TApiInfos

    Server API information (version, etc.) loaded on first connection.

    layers: CanvasLayer

    DOM layer manager handling rendering, UI, and modal elements.

    logger: Logger = ...

    Logger instance for this canvas.

    renderer: SVGRenderer
    • get initializationPromise(): Promise<void>

      Returns Promise<void>

    • get model(): IModel

      Returns IModel

    • get penStyle(): TStyle

      Returns TStyle

    • set penStyle(
          penStyle: {
              color?: string;
              fill?: string;
              opacity?: number;
              width?: number;
              [key: string]: string | number | undefined;
          },
      ): void

      Parameters

      • penStyle: {
            color?: string;
            fill?: string;
            opacity?: number;
            width?: number;
            [key: string]: string | number | undefined;
        }

      Returns void

    • Returns Promise<void>

    • Force label fully inactive regardless of how many startOperation calls are pending. For level-triggered signals with a single external "done" event (e.g. the client's idle event) rather than one end call per start call.

      Parameters

      Returns void

    • Returns Promise<void>

    • Mark one occurrence of label as finished. Must be paired with a prior startOperation.

      Parameters

      Returns void

    • Parameters

      • OptionalrequestedMimeTypes: string[]

      Returns Promise<TExportV2>

    • Whether label is currently active (at least one unmatched startOperation call).

      Parameters

      Returns boolean

    • Returns Promise<void>

    • Only relevant for WebSocket-backed canvas; other variants never call this.

      Parameters

      Returns void

    • Parameters

      • idle: boolean

      Returns void

      The client's idle event only fires in response to an explicit client.waitForIdle() call (a request/response pair, not a push notification) — it does NOT fire automatically after every addStrokes()/transform/etc. So it cannot be used to end a "Recognizing" operation reliably. This only preserves the public event.emitIdle passthrough for consumers who call waitForIdle() themselves.

    • Called once the canvas has connected to its backend for the first time.

      Returns void

    • Returns Promise<void>

    • Parameters

      • strokeIds: string[]

      Returns Promise<void>

    • Parameters

      • __namedParameters: { height?: number; width?: number } = {}

      Returns Promise<void>

    • Mark label as active. Prefer trackOperation unless the operation isn't promise-shaped.

      Parameters

      Returns void

    • Returns void

    • Returns void

    • Run fn, marking label as an active operation for the duration (shown on the canvas state badge tooltip). Safe against overlapping/concurrent calls with the same or different labels, and against fn throwing (the operation is always ended).

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

    • Returns Promise<void>

    • Parameters

      • symbolIds: string[]
      • style: {
            color?: string;
            fill?: string;
            opacity?: number;
            width?: number;
            [key: string]: string | number | undefined;
        }

      Returns void