docx-rs/docx-wasm/js/table-cell-borders.ts

66 lines
1.8 KiB
TypeScript
Raw Normal View History

import { BorderPosition, TableCellBorder } from "./table-cell-border";
2020-04-30 07:39:56 +03:00
export type PositionKeys =
| "top"
| "left"
| "bottom"
| "right"
| "insideH"
| "insideV";
export class TableCellBorders {
2020-04-30 08:38:56 +03:00
top: TableCellBorder | null = new TableCellBorder("top");
left: TableCellBorder | null = new TableCellBorder("left");
bottom: TableCellBorder | null = new TableCellBorder("bottom");
right: TableCellBorder | null = new TableCellBorder("right");
insideH: TableCellBorder | null = new TableCellBorder("insideH");
insideV: TableCellBorder | null = new TableCellBorder("insideV");
set(border: TableCellBorder) {
switch (border.position) {
2020-04-30 08:38:56 +03:00
case "top":
this.top = border;
2020-04-30 08:38:56 +03:00
case "left":
this.left = border;
2020-04-30 08:38:56 +03:00
case "bottom":
this.bottom = border;
2020-04-30 08:38:56 +03:00
case "right":
this.right = border;
2020-04-30 08:38:56 +03:00
case "insideH":
this.insideH = border;
2020-04-30 08:38:56 +03:00
case "insideV":
this.insideV = border;
}
return this;
}
clear(position: BorderPosition) {
let nil = new TableCellBorder(position).border_type("nil");
switch (position) {
2020-04-30 08:38:56 +03:00
case "top":
this.top = nil;
2020-04-30 08:38:56 +03:00
case "left":
this.left = nil;
2020-04-30 08:38:56 +03:00
case "bottom":
this.bottom = nil;
2020-04-30 08:38:56 +03:00
case "right":
this.right = nil;
2020-04-30 08:38:56 +03:00
case "insideH":
this.insideH = nil;
2020-04-30 08:38:56 +03:00
case "insideV":
this.insideV = nil;
}
return this;
}
clearAll() {
this.top = new TableCellBorder("top").border_type("nil");
this.left = new TableCellBorder("left").border_type("nil");
this.bottom = new TableCellBorder("bottom").border_type("nil");
this.right = new TableCellBorder("right").border_type("nil");
this.insideH = new TableCellBorder("insideH").border_type("nil");
this.insideV = new TableCellBorder("insideV").border_type("nil");
return this;
}
}