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

46 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-09-22 14:46:19 +01:00
// http://officeopenxml.com/WPborders.php
import { BorderElement, BorderStyle, IBorderOptions } from "@file/border";
import { IgnoreIfEmptyXmlComponent, XmlComponent } from "@file/xml-components";
2019-06-12 01:03:36 +01:00
export type IBordersOptions = {
readonly top?: IBorderOptions;
readonly bottom?: IBorderOptions;
readonly left?: IBorderOptions;
readonly right?: IBorderOptions;
};
export class Border extends IgnoreIfEmptyXmlComponent {
2022-08-31 07:52:27 +01:00
public constructor(options: IBordersOptions) {
super("w:pBdr");
if (options.top) {
this.root.push(new BorderElement("w:top", options.top));
2019-06-12 01:03:36 +01:00
}
if (options.bottom) {
this.root.push(new BorderElement("w:bottom", options.bottom));
2019-06-12 01:03:36 +01:00
}
if (options.left) {
this.root.push(new BorderElement("w:left", options.left));
2019-06-12 01:03:36 +01:00
}
if (options.right) {
this.root.push(new BorderElement("w:right", options.right));
2019-06-12 01:03:36 +01:00
}
2016-03-29 04:50:23 +01:00
}
}
2016-04-09 20:16:35 +01:00
export class ThematicBreak extends XmlComponent {
2022-08-31 07:52:27 +01:00
public constructor() {
2016-04-09 20:16:35 +01:00
super("w:pBdr");
const bottom = new BorderElement("w:bottom", {
2019-06-12 01:03:36 +01:00
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
2019-06-12 01:03:36 +01:00
size: 6,
});
this.root.push(bottom);
2016-03-29 04:50:23 +01:00
}
2017-03-08 21:36:09 +00:00
}