Skip to content

Latest commit

 

History

History
646 lines (361 loc) · 13 KB

Table.md

File metadata and controls

646 lines (361 loc) · 13 KB

@felisdiligens/md-table-tools / Exports / Table

Class: Table

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Table(rowNum?, colNum?)

Parameters

Name Type Default value
rowNum number 0
colNum number 0

Defined in

tables/table.ts:181

Properties

afterTable

afterTable: string

Text after the table

Defined in

tables/table.ts:179


beforeTable

beforeTable: string

Text before the table

Defined in

tables/table.ts:176


caption

caption: TableCaption

Defined in

tables/table.ts:173


cells

Private cells: TableCell[]

Defined in

tables/table.ts:170


columns

Private columns: TableColumn[]

Defined in

tables/table.ts:172


rows

Private rows: TableRow[]

Defined in

tables/table.ts:171

Methods

addCell

addCell(cell): void

Adds the cell to the Table and the cell's respective TableRow and TableColumn.
(Be careful not to add a cell with row/column that already exist. Otherwise, the added cell will be overshadowed and not be used.)

Parameters

Name Type
cell TableCell

Returns

void

Defined in

tables/table.ts:368


addColumn

addColumn(index?, col?): TableColumn

Adds a TableColumn to the table.

Parameters

Name Type Default value Description
index number -1 Insert column at index. -1 means it's appended.
col TableColumn undefined (optional)

Returns

TableColumn

The added column.

Defined in

tables/table.ts:212


addRow

addRow(index?, row?): TableRow

Adds a TableRow to the table.

Parameters

Name Type Default value Description
index number -1 Insert row at index. -1 means it's appended.
row TableRow undefined (optional)

Returns

TableRow

The added row.

Defined in

tables/table.ts:196


columnCount

columnCount(): number

Returns the total amount of columns in the table.

Returns

number

Defined in

tables/table.ts:380


getCell

getCell(row, column): TableCell

Returns the cell at row and column. If the cell doesn't already exist, it will be created.

Parameters

Name Type Description
row number | TableRow Either index or object reference.
column number | TableColumn Either index or object reference.

Returns

TableCell

The cell at row and column.

Defined in

tables/table.ts:357


getCellByObjs

Private getCellByObjs(rowObj, columnObj): TableCell

Returns the cell at row and column.

Parameters

Name Type
rowObj TableRow
columnObj TableColumn

Returns

TableCell

Defined in

tables/table.ts:338


getCells

getCells(): TableCell[]

Returns all cells in the table. Isn't necessarily sorted!

Returns

TableCell[]

Defined in

tables/table.ts:315


getCellsInColumn

getCellsInColumn(column): TableCell[]

Returns all cells within the given column. See also: ()

Parameters

Name Type Description
column number | TableColumn Either index or object reference.

Returns

TableCell[]

Defined in

tables/table.ts:333


getCellsInRow

getCellsInRow(row): TableCell[]

Returns all cells within the given row. See also: ()

Parameters

Name Type Description
row number | TableRow Either index or object reference.

Returns

TableCell[]

Defined in

tables/table.ts:324


getColumn

getColumn(index): TableColumn

Gets the column at index. Negative index counts back from the end. Returns undefined if out-of-bounds.

Parameters

Name Type
index number

Returns

TableColumn

Defined in

tables/table.ts:233


getColumns

getColumns(): TableColumn[]

Returns all columns in the table, from left to right.

Returns

TableColumn[]

Defined in

tables/table.ts:310


getHeaderRows

getHeaderRows(): TableRow[]

Returns a list of all rows that are headers.

Returns

TableRow[]

Defined in

tables/table.ts:295


getNormalRows

getNormalRows(): TableRow[]

Returns a list of all rows that aren't headers.

Returns

TableRow[]

Defined in

tables/table.ts:300


getRow

getRow(index): TableRow

Gets the row at index. Negative index counts back from the end. Returns undefined if out-of-bounds.

Parameters

Name Type
index number

Returns

TableRow

Defined in

tables/table.ts:223


getRows

getRows(): TableRow[]

Retruns all rows in the table, from top to bottom, including header rows.

Returns

TableRow[]

Defined in

tables/table.ts:305


indexOfColumn

indexOfColumn(col): number

Gets the index of the column. -1 if it hasn't been found.

Parameters

Name Type
col TableColumn

Returns

number

Defined in

tables/table.ts:238


indexOfRow

indexOfRow(row): number

Gets the index of the row. -1 if it hasn't been found.

Parameters

Name Type
row TableRow

Returns

number

Defined in

tables/table.ts:228


mergeMultilineRows

mergeMultilineRows(): Table

Merges multiline rows (from MultiMarkdown feature) into "normal" rows.
This will destroy MultiMarkdown formatting! Only use when rendering into different formats.

Returns

Table

Defined in

tables/table.ts:451


moveColumn

moveColumn(col, newIndex): void

Moves the given column to the new index.

Throws

Can't move column outside of table.

Parameters

Name Type Description
col number | TableColumn Either index or object reference.
newIndex number The new index of the given column.

Returns

void

Defined in

tables/table.ts:270


moveRow

moveRow(row, newIndex): void

Moves the given row to the new index.

Throws

Can't move row outside of table.

Parameters

Name Type Description
row number | TableRow Either index or object reference.
newIndex number The new index of the given row.

Returns

void

Defined in

tables/table.ts:285


removeColumn

removeColumn(col): void

Removes the given column. Also removes all cells within the column.

Parameters

Name Type Description
col number | TableColumn Either index or object reference.

Returns

void

Defined in

tables/table.ts:246


removeRow

removeRow(row): void

Removes the given row. Also removes all cells within the row.

Parameters

Name Type Description
row number | TableRow Either index or object reference.

Returns

void

Defined in

tables/table.ts:257


rowCount

rowCount(): number

Returns the total amount of rows in the table, including the header rows.

Returns

number

Defined in

tables/table.ts:375


sanitize

Private sanitize(): Table

Tries to find invalid configurations and sanitize them.

Returns

Table

Defined in

tables/table.ts:423


update

update(): Table

→ Ensures that all table cells exist.
→ Updates indices and sorts the cells within rows and columns.
→ Tries to find invalid configurations and sanitize them.

Call this method after altering the table.

Returns

Table

Defined in

tables/table.ts:391