Files
docx-js/src/file/paragraph/formatting/border.ts

64 lines
2.0 KiB
TypeScript
Raw Normal View History

2017-09-22 14:46:19 +01:00
// http://officeopenxml.com/WPborders.php
import { Attributes, XmlComponent } from "file/xml-components";
2016-03-29 04:50:23 +01:00
class BorderProperty extends XmlComponent {
public setProperties(color: string, space: string, value: string, size: string): XmlComponent {
const attrs = new Attributes({
color: color,
space: space,
val: value,
sz: size,
});
this.root.push(attrs);
return this;
}
}
export class Border extends XmlComponent {
2016-03-29 04:50:23 +01:00
constructor() {
super("w:pBdr");
}
public addTopBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
const top = new BorderProperty("w:top");
top.setProperties(color, space, value, size);
this.root.push(top);
return this;
}
public addBottomBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
const bottom = new BorderProperty("w:bottom");
bottom.setProperties(color, space, value, size);
this.root.push(bottom);
return this;
}
public addLeftBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
const left = new BorderProperty("w:left");
left.setProperties(color, space, value, size);
this.root.push(left);
return this;
}
public addRightBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
const right = new BorderProperty("w:right");
right.setProperties(color, space, value, size);
this.root.push(right);
return this;
2016-03-29 04:50:23 +01:00
}
}
2016-04-09 20:16:35 +01:00
export class ThematicBreak extends XmlComponent {
2016-03-29 04:50:23 +01:00
constructor() {
2016-04-09 20:16:35 +01:00
super("w:pBdr");
const bottom = new BorderProperty("w:bottom");
bottom.setProperties("auto", "1", "single", "6");
this.root.push(bottom);
2016-03-29 04:50:23 +01:00
}
2017-03-08 21:36:09 +00:00
}