Files
docx-js/src/file/table/table-cell/cell-margin/cell-margin.ts
2019-04-18 13:55:18 +10:00

64 lines
1.4 KiB
TypeScript

// http://officeopenxml.com/WPtableCellProperties-Margins.php
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
export interface ICellMarginProperties {
readonly type: string;
readonly width: number;
}
class CellMarginAttributes extends XmlAttributeComponent<ICellMarginProperties> {
protected readonly xmlKeys = { width: "w:w", type: "w:type" };
}
export class TopCellMargin extends XmlComponent {
constructor(value: number) {
super("w:top");
this.root.push(
new CellMarginAttributes({
width: value,
type: "dxa",
}),
);
}
}
export class BottomCellMargin extends XmlComponent {
constructor(value: number) {
super("w:bottom");
this.root.push(
new CellMarginAttributes({
width: value,
type: "dxa",
}),
);
}
}
export class LeftCellMargin extends XmlComponent {
constructor(value: number) {
super("w:start");
this.root.push(
new CellMarginAttributes({
width: value,
type: "dxa",
}),
);
}
}
export class RightCellMargin extends XmlComponent {
constructor(value: number) {
super("w:end");
this.root.push(
new CellMarginAttributes({
width: value,
type: "dxa",
}),
);
}
}