Options
All
  • Public
  • Public/Protected
  • All
Menu

A virtual table class, represent an HTML table, by expand all merged cells to each separated cells

Hierarchy

  • VTable

Index

Constructors

constructor

  • new VTable(node: HTMLTableElement | HTMLTableCellElement, normalizeSize?: boolean, zoomScale?: number | SizeTransformer): VTable
  • Create a new instance of VTable object using HTML TABLE or TD node

    Parameters

    • node: HTMLTableElement | HTMLTableCellElement

      The HTML Table or TD node

    • Optional normalizeSize: boolean

      Whether table size needs to be normalized

    • Optional zoomScale: number | SizeTransformer

      When the table is under a zoomed container, pass in the zoom scale here

    Returns VTable

Properties

cells

cells: VCell[][] = null

Virtual cells

col

col: number

Current column index

formatInfo

formatInfo: Required<TableFormat> = null

Current format of the table

row

row: number

Current row index

table

table: HTMLTableElement

The HTML table object

Accessors

selection

Methods

applyFormat

edit

forEachCellOfCurrentColumn

  • forEachCellOfCurrentColumn(callback: (cell: VCell, row: VCell[], i: number) => any): void

forEachCellOfCurrentRow

  • forEachCellOfCurrentRow(callback: (cell: VCell, i: number) => any): void

getCell

  • getCell(row: number, col: number): VCell
  • Get a table cell using its row and column index. This function will always return an object even if the given indexes don't exist in table.

    Parameters

    • row: number

      The row index

    • col: number

      The column index

    Returns VCell

getCellsWithBorder

  • getCellsWithBorder(borderPos: number, getLeftCells: boolean): HTMLTableCellElement[]
  • Loop each table cell and get all the cells that share the same border from one side The result is an array of table cell elements

    Parameters

    • borderPos: number

      The position of the border

    • getLeftCells: boolean

      Get left-hand-side or right-hand-side cells of the border

      Example, consider having a 3 by 4 table as below with merged and split cells

      | 1 | 4 | 7 | 8 |
      |   5   |   9   |
      |   3   |   10  |
      

      input => borderPos: the 3rd border, getLeftCells: true output => [4, 5, 3]

      input => borderPos: the 3rd border, getLeftCells: false output => [7, 9, 10]

      input => borderPos: the 2nd border, getLeftCells: true output => [1]

      input => borderPos: the 2nd border, getLeftCells: false output => [4]

    Returns HTMLTableCellElement[]

getCurrentTd

  • getCurrentTd(): HTMLTableCellElement

getTd

  • getTd(row: number, col: number): HTMLTableCellElement

normalizeTableCellSize

setAlignmentToSelectedCells

  • setAlignmentToSelectedCells(firstRow: number, lastRow: number, firstColumn: number, lastColumn: number, alignmentType: string, isVertical?: boolean): void

writeBack

  • writeBack(skipApplyFormat?: boolean, darkColorHandler?: DarkColorHandler): void
  • Write the virtual table back to DOM tree to represent the change of VTable

    Parameters

    • Optional skipApplyFormat: boolean

      Do not reapply table format when write back. Only use this parameter when you are pretty sure there is no format or table structure change during the process.

    • Optional darkColorHandler: DarkColorHandler

      An object to handle dark background colors, if not passed the cell background color will not be set

    Returns void

Generated using TypeDoc