Files
docx-js/src/file/table/table-cell/cell-margin/cell-margin.ts

64 lines
1.4 KiB
TypeScript
Raw Normal View History

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