Improve API
This commit is contained in:
@ -5,7 +5,7 @@ import { Formatter } from "../../export/formatter";
|
||||
import { Paragraph } from "../paragraph";
|
||||
import { Table } from "./";
|
||||
import { WidthType } from "./table-cell";
|
||||
import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType, TableFloatProperties } from "./table-float-properties";
|
||||
import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType } from "./table-float-properties";
|
||||
|
||||
const DEFAULT_TABLE_PROPERTIES = {
|
||||
"w:tblBorders": [
|
||||
@ -296,22 +296,20 @@ describe("Table", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setTableFloatProperties", () => {
|
||||
describe("#float", () => {
|
||||
it("sets the table float properties", () => {
|
||||
const table = new Table(1, 1).setTableFloatProperties(
|
||||
new TableFloatProperties({
|
||||
horizontalAnchor: TableAnchorType.MARGIN,
|
||||
verticalAnchor: TableAnchorType.PAGE,
|
||||
absoluteHorizontalPosition: 10,
|
||||
relativeHorizontalPosition: RelativeHorizontalPosition.CENTER,
|
||||
absoluteVerticalPosition: 20,
|
||||
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
|
||||
bottomFromText: 30,
|
||||
topFromText: 40,
|
||||
leftFromText: 50,
|
||||
rightFromText: 60,
|
||||
}),
|
||||
);
|
||||
const table = new Table(1, 1).float({
|
||||
horizontalAnchor: TableAnchorType.MARGIN,
|
||||
verticalAnchor: TableAnchorType.PAGE,
|
||||
absoluteHorizontalPosition: 10,
|
||||
relativeHorizontalPosition: RelativeHorizontalPosition.CENTER,
|
||||
absoluteVerticalPosition: 20,
|
||||
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
|
||||
bottomFromText: 30,
|
||||
topFromText: 40,
|
||||
leftFromText: 50,
|
||||
rightFromText: 60,
|
||||
});
|
||||
const tree = new Formatter().format(table);
|
||||
expect(tree)
|
||||
.to.have.property("w:tbl")
|
||||
|
@ -14,7 +14,7 @@ import { IXmlableObject, XmlComponent } from "file/xml-components";
|
||||
import { Paragraph } from "../paragraph";
|
||||
import { TableGrid } from "./grid";
|
||||
import { TableProperties } from "./properties";
|
||||
import { TableFloatProperties } from "./table-float-properties";
|
||||
import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties";
|
||||
|
||||
export class Table extends XmlComponent {
|
||||
private readonly properties: TableProperties;
|
||||
@ -85,13 +85,13 @@ export class Table extends XmlComponent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public get Properties(): TableProperties {
|
||||
return this.properties;
|
||||
public float(tableFloatProperties: ITableFloatOptions): Table {
|
||||
this.properties.setTableFloatProperties(new TableFloatProperties(tableFloatProperties));
|
||||
return this;
|
||||
}
|
||||
|
||||
public setTableFloatProperties(tableFloatProperties: TableFloatProperties): Table {
|
||||
this.properties.setTableFloatProperties(tableFloatProperties);
|
||||
return this;
|
||||
public get Properties(): TableProperties {
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user