import { Node } from "prosemirror-model"; import { Bias, CartesianAxis, TableNode, TablePosOfCell } from "../types"; import { EdgeRect } from "./EdgeRect"; export declare const enum TableMapProblemType { COLLISION = 0, COLWIDTH_MISMATCH = 1, MISSING = 2, OVERLONG_ROWSPAN = 3 } export interface CollisionProblem { type: TableMapProblemType.COLLISION; row: number; pos: number; n: number; } export interface ColWidthMismatchProblem { type: TableMapProblemType.COLWIDTH_MISMATCH; pos: number; colwidth: Array; } export interface MissingProblem { type: TableMapProblemType.MISSING; row: number; n: number; } export interface OverlongRowspanProblem { type: TableMapProblemType.OVERLONG_ROWSPAN; pos: number; n: number; } export declare type TableMapProblem = CollisionProblem | ColWidthMismatchProblem | MissingProblem | OverlongRowspanProblem; export declare class TableMap { readonly width: number; readonly height: number; readonly map: ReadonlyArray; problems: Array | null; /** * A table map describes the structore of a given table. To avoid recomputing * them all the time, they are cached per table node. To be able to do that, * positions saved in the map are relative to the start of the table (i.e. * first position in the table), rather than the start of the document. * * @param width The width of the table * @param height The table's height * @param map A width * height array with the start position of the cell * covering that part of the table in each slot * @param problems An optional array of problems (cell overlap or * non-rectangular shape) for the table, used by the table normalizer. */ constructor(width: number, height: number, map: ReadonlyArray, problems: Array | null); /** * Find the dimensions of the cell at the given position. */ findCell(pos: TablePosOfCell): EdgeRect; /** * Find the column index for a cell. * * @param pos Position of a cell. */ columnIndex(pos: TablePosOfCell): number; /** * Find the row index for a cell. * * @param pos Position of a cell. */ rowIndex(pos: TablePosOfCell): number; /** * Find the next cell in the given direction, starting from the cell at `pos`, if any. */ nextCell(pos: TablePosOfCell, axis: CartesianAxis, bias: Bias): number | null | undefined; /** * Get the rectangle spanning the two given cells. */ rectBetween(a: TablePosOfCell, b: TablePosOfCell): EdgeRect; /** * Return the position of all cells that have the top left corner in the given rectangle. */ cellsInRect(rect: EdgeRect): Array; /** * Return the position at which the cell at the given row and column starts, * or would start, if a cell started there. */ positionAt(row: number, col: number, table: Node): number; /** * Find the table map for the given table node. */ static get(table: TableNode): TableMap; }