Function findDataEdge

  • The target of Ctrl+arrow (⌘+arrow on macOS) in Excel-style editing – Excel's rule for jumping to the edge of the data: if the cell next to the start is empty, the next filled cell in that direction (or the last cell); if it is filled, the last filled cell of that block. Empty = null, undefined or "" (not 0, not false). DOM-free; hidden columns (isShownColumn → false) are skipped.

    Parameters

    • isEmpty: ((row, column) => boolean)

      true for an empty cell

        • (row, column): boolean
        • Parameters

          • row: number
          • column: number

          Returns boolean

    • rowCount: number

      rows (display order)

    • columnCount: number

      columns (model indices)

    • row: number

      start row

    • column: number

      start column

    • dRow: number

      1, 0 or 1

    • dColumn: number

      1, 0 or 1

    • Optional isShownColumn: ((column) => boolean) = ...

      false for a hidden column

        • (column): boolean
        • Parameters

          • column: number

          Returns boolean

    Returns [number, number]

    the target cell (the start if there is nothing to move to)

    Example

    const data = [[1], [2], [""], [""], [5]];
    const isEmpty = (r: number, c: number) => data[r][c] === "";
    findDataEdge(isEmpty, 5, 1, 0, 0, 1, 0); // [1, 0] – end of the block 1, 2
    findDataEdge(isEmpty, 5, 1, 1, 0, 1, 0); // [4, 0] – next filled cell

    Since

    1.1.99