Merge branch 'master' into add-table-option-styleId

# Conflicts:
#	src/file/table/table.ts
This commit is contained in:
Dolan
2021-03-07 21:40:42 +00:00
319 changed files with 20572 additions and 2876 deletions

View File

@ -1,55 +1,68 @@
// http://officeopenxml.com/WPtableProperties.php
import { IgnoreIfEmptyXmlComponent } from "file/xml-components";
import { Alignment, AlignmentType } from "../../paragraph";
import { ITableShadingAttributesProperties, TableShading } from "../shading";
import { WidthType } from "../table-cell";
import { TableBorders } from "./table-borders";
import { TableCellMargin } from "./table-cell-margin";
import { ITableBordersOptions, TableBorders } from "./table-borders";
import { ITableCellMarginOptions, TableCellMargin } from "./table-cell-margin";
import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties";
import { TableLayout, TableLayoutType } from "./table-layout";
import { TableStyle } from "./table-style";
import { PreferredTableWidth } from "./table-width";
import { VisuallyRightToLeft } from "./visually-right-to-left";
export interface ITablePropertiesOptions {
readonly width?: {
readonly size: number;
readonly type?: WidthType;
};
readonly layout?: TableLayoutType;
readonly borders?: ITableBordersOptions;
readonly float?: ITableFloatOptions;
readonly shading?: ITableShadingAttributesProperties;
readonly style?: string;
readonly alignment?: AlignmentType;
readonly cellMargin?: ITableCellMarginOptions;
readonly visuallyRightToLeft?: boolean;
}
export class TableProperties extends IgnoreIfEmptyXmlComponent {
private readonly cellMargin: TableCellMargin;
constructor() {
constructor(options: ITablePropertiesOptions) {
super("w:tblPr");
this.cellMargin = new TableCellMargin();
this.root.push(this.cellMargin);
}
this.root.push(new TableCellMargin(options.cellMargin || {}));
public setWidth(width: number, type: WidthType = WidthType.AUTO): TableProperties {
this.root.push(new PreferredTableWidth(type, width));
return this;
}
if (options.borders) {
this.root.push(new TableBorders(options.borders));
}
public setLayout(type: TableLayoutType): void {
this.root.push(new TableLayout(type));
}
if (options.width) {
this.root.push(new PreferredTableWidth(options.width.type, options.width.size));
}
public setBorder(): TableProperties {
this.root.push(new TableBorders());
return this;
}
if (options.float) {
this.root.push(new TableFloatProperties(options.float));
}
public get CellMargin(): TableCellMargin {
return this.cellMargin;
}
if (options.layout) {
this.root.push(new TableLayout(options.layout));
}
public setTableFloatProperties(tableFloatOptions: ITableFloatOptions): TableProperties {
this.root.push(new TableFloatProperties(tableFloatOptions));
return this;
}
if (options.alignment) {
this.root.push(new Alignment(options.alignment));
}
public setShading(attrs: ITableShadingAttributesProperties): TableProperties {
this.root.push(new TableShading(attrs));
if (options.shading) {
this.root.push(new TableShading(options.shading));
}
return this;
}
if (options.visuallyRightToLeft) {
this.root.push(new VisuallyRightToLeft());
}
public setStyle(styleId: string): TableProperties {
this.root.push(new TableStyle(styleId));
return this;
if (options.style) {
this.root.push(new TableStyle(options.style));
}
}
}