clean up initial table attempt (linter, interfaces, etc.)
This commit is contained in:
@ -1,21 +1,22 @@
|
||||
import {XmlComponent, Attributes} from "../xml-components";
|
||||
import {Paragraph} from "../paragraph";
|
||||
import {TableProperties} from "./properties";
|
||||
import {TableGrid, GridCol} from './grid';
|
||||
import { Paragraph } from "../paragraph";
|
||||
import { XmlComponent } from "../xml-components";
|
||||
|
||||
import { GridCol, TableGrid } from "./grid";
|
||||
import { TableProperties } from "./properties";
|
||||
|
||||
export class Table extends XmlComponent {
|
||||
properties: TableProperties;
|
||||
private rows: Array<TableRow>;
|
||||
private properties: TableProperties;
|
||||
private rows: TableRow[];
|
||||
private grid: TableGrid;
|
||||
|
||||
constructor(rows: number, cols: number) {
|
||||
super('w:tbl');
|
||||
super("w:tbl");
|
||||
this.properties = new TableProperties();
|
||||
this.root.push(this.properties);
|
||||
|
||||
const gridCols = [];
|
||||
const gridCols: number[] = [];
|
||||
for (let i = 0; i++; i < cols) {
|
||||
gridCols.push(new GridCol());
|
||||
gridCols.push(0);
|
||||
}
|
||||
this.grid = new TableGrid(gridCols);
|
||||
this.root.push(this.grid);
|
||||
@ -32,43 +33,46 @@ export class Table extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
getRow(ix: number): TableRow {
|
||||
public getRow(ix: number): TableRow {
|
||||
return this.rows[ix];
|
||||
}
|
||||
|
||||
public getCell(row: number, col: number): TableCell {
|
||||
return this.getRow(row).getCell(col);
|
||||
}
|
||||
}
|
||||
|
||||
class TableRow extends XmlComponent {
|
||||
private properties: TableRowProperties;
|
||||
private cells: Array<TableCell>;
|
||||
private cells: TableCell[];
|
||||
|
||||
constructor(cells: Array<TableCell>) {
|
||||
super('w:tr');
|
||||
constructor(cells: TableCell[]) {
|
||||
super("w:tr");
|
||||
this.properties = new TableRowProperties();
|
||||
this.root.push(this.properties);
|
||||
this.cells = cells;
|
||||
cells.forEach(c => this.root.push(c))
|
||||
cells.forEach((c) => this.root.push(c));
|
||||
}
|
||||
|
||||
getCell(ix: number): TableCell {
|
||||
public getCell(ix: number): TableCell {
|
||||
return this.cells[ix];
|
||||
}
|
||||
}
|
||||
|
||||
class TableRowProperties extends XmlComponent {
|
||||
constructor() {
|
||||
super('w:trPr');
|
||||
super("w:trPr");
|
||||
}
|
||||
}
|
||||
|
||||
class TableCell extends XmlComponent {
|
||||
public content: XmlComponent;
|
||||
private properties: TableCellProperties;
|
||||
content: any;
|
||||
|
||||
constructor() {
|
||||
super('w:tc');
|
||||
super("w:tc");
|
||||
this.properties = new TableCellProperties();
|
||||
this.root.push(this.properties);
|
||||
this.root.push()
|
||||
// Table cells can have any block-level content, but for now
|
||||
// we only allow a single paragraph:
|
||||
this.content = new Paragraph();
|
||||
@ -78,6 +82,6 @@ class TableCell extends XmlComponent {
|
||||
|
||||
class TableCellProperties extends XmlComponent {
|
||||
constructor() {
|
||||
super('w:tcPr');
|
||||
super("w:tcPr");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user