Ace API Reference
    Preparing search index...
    Index

    Constructors

    • Parameters

      • parentEl: HTMLElement
      • textLayer: any
      • renderer: any

      Returns FontMetrics

    Properties

    $characterSize: { height: number; width: number }
    $main: HTMLDivElement
    $measureNode: HTMLDivElement
    $observer: ResizeObserver
    $pollSizeChangesTimer: number
    $scratchRange: Range
    allowBoldFonts: boolean
    charSizes: any
    config: { characterWidth: number }
    el: HTMLDivElement
    els: any
    renderer: any
    textLayer: any

    Methods

    • Finds the position of a specific column within a line element.

      This method traverses the text nodes within the given line element to locate the node and offset corresponding to the specified screen column. If the column exceeds the total length of the text, it returns the last node and its length.

      Parameters

      • lineElement: HTMLElement

        The DOM element representing the line of text.

      • screenColumn: number

        The target column position within the line (0-based).

      Returns { node: Node; offset: number; overflow: number }

      An object containing the text node and the offset within that node corresponding to the column position, or null if no nodes are found.

    • Finds and returns the DOM element corresponding to a given screen row.

      Parameters

      • screenRow: number

        The screen row number for which to find the element.

      Returns HTMLElement

      The DOM element corresponding to the screen row, or null if not found.

    • Measures the horizontal position (in pixels) of a specific screen column within a given line element. This method calculates the pixel offset from the left edge of the text layer's container to the specified column.

      Parameters

      • lineElement: HTMLElement

        The DOM element representing the line of text.

      • screenColumn: number

        The screen column index to measure.

      Returns number

      The horizontal position (in pixels) of the specified column relative to the left edge of the text layer's container. If the position cannot be determined, it falls back to an approximation based on the character width.

    • Parameters

      • node: any

      Returns { height: any; width: number }

    • Converts a pixel position (x-coordinate) to a screen column index within a given row.

      Parameters

      • screenRow: number

        The row index on the screen.

      • screenColumnMonospace: number

        Screen column if text was monospace.

      • x: number

        The x-coordinate (in pixels) to convert to a column index.

      • blockCursor: boolean

        Whether the cursor is in block mode.

      • OptionalisTextWidthCoordinate: boolean

        Whether x is in the same coordinate space as textWidth().

      Returns number

      The calculated screen column index corresponding to the x-coordinate.

    • Parameters

      • Optionalsize: { height: number; width: number }

      Returns void

    • Calculates and returns an array of rectangles representing the visual positions of a range of text between two screen positions within a text layer.

      Parameters

      • startScreenPos: { column: number; row: number }

        The starting screen position of the range.

        • column: number

          The column index of the starting position.

        • row: number

          The row index of the starting position.

      • endScreenPos: { column: number; row: number }

        The ending screen position of the range.

        • column: number

          The column index of the ending position.

        • row: number

          The row index of the ending position.

      Returns any[]

      An array of rectangle objects representing the visual positions of the text range. Each rectangle object contains:

      • left {number}: The left offset of the rectangle relative to the text layer.
      • width {number}: The width of the rectangle. If an error occurs or the line element is not found, a fallback rectangle is returned based on character width and column positions.
    • Parameters

      • transform: { M: number[]; t: number[] }
      • bbox: { height: number; left: number; top: number; width: number }

      Returns
          | {
              bottom: any;
              height: any;
              left: any;
              mappingIdx: number;
              right: any;
              top: any;
              width: any;
          }
          | {
              bottom: number;
              height: any;
              left: number;
              right: number;
              top: number;
              width: number;
          }

    • Calculates the width of the text up to a specific screenColumn on a given screen row.

      Parameters

      • screenRow: number

        The row index on the screen for which the text width is calculated.

      • screenColumn: number

        The column index up to which the text width is measured.

      Returns number

      The width of the text in pixels up to the specified column.