/
break.ts
43 lines (38 loc) · 1.02 KB
/
break.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// http://officeopenxml.com/WPtextSpecialContent-break.php
import { Attributes, XmlComponent } from "@file/xml-components";
import { Run } from "../run";
const BreakType = {
COLUMN: "column",
PAGE: "page",
// textWrapping breaks are the default and already exposed via the "Run" class
} as const;
class Break extends XmlComponent {
public constructor(type: (typeof BreakType)[keyof typeof BreakType]) {
super("w:br");
this.root.push(
new Attributes({
type,
}),
);
}
}
export class PageBreak extends Run {
public constructor() {
super({});
this.root.push(new Break(BreakType.PAGE));
}
}
export class ColumnBreak extends Run {
public constructor() {
super({});
this.root.push(new Break(BreakType.COLUMN));
}
}
/**
* Add page break before the paragraph if there is no one added before.
*/
export class PageBreakBefore extends XmlComponent {
public constructor() {
super("w:pageBreakBefore");
}
}