2017-09-21 14:56:46 +01:00
|
|
|
// http://officeopenxml.com/WPtextSpecialContent-break.php
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Attributes, XmlComponent } from "@file/xml-components";
|
2017-12-19 23:13:11 +00:00
|
|
|
import { Run } from "../run";
|
2016-03-30 00:28:05 +01:00
|
|
|
|
2023-12-22 10:25:00 +09:00
|
|
|
const BreakType = {
|
|
|
|
COLUMN: "column",
|
|
|
|
PAGE: "page",
|
2021-07-08 17:39:21 +10:00
|
|
|
// textWrapping breaks are the default and already exposed via the "Run" class
|
2023-12-22 10:25:00 +09:00
|
|
|
} as const;
|
2021-07-08 17:39:21 +10:00
|
|
|
|
2016-04-09 20:16:35 +01:00
|
|
|
class Break extends XmlComponent {
|
2023-12-22 10:25:00 +09:00
|
|
|
public constructor(type: (typeof BreakType)[keyof typeof BreakType]) {
|
2016-04-09 20:16:35 +01:00
|
|
|
super("w:br");
|
2018-01-23 01:33:12 +00:00
|
|
|
this.root.push(
|
|
|
|
new Attributes({
|
2021-07-08 17:39:21 +10:00
|
|
|
type,
|
2018-01-23 01:33:12 +00:00
|
|
|
}),
|
|
|
|
);
|
2016-03-30 00:28:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PageBreak extends Run {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor() {
|
2019-06-17 01:51:57 +01:00
|
|
|
super({});
|
2021-07-08 17:39:21 +10:00
|
|
|
this.root.push(new Break(BreakType.PAGE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ColumnBreak extends Run {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor() {
|
2021-07-08 17:39:21 +10:00
|
|
|
super({});
|
|
|
|
this.root.push(new Break(BreakType.COLUMN));
|
2016-03-30 00:28:05 +01:00
|
|
|
}
|
2017-03-08 21:36:09 +00:00
|
|
|
}
|
2018-05-10 19:43:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add page break before the paragraph if there is no one added before.
|
|
|
|
*/
|
|
|
|
export class PageBreakBefore extends XmlComponent {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor() {
|
2018-05-10 19:43:58 +02:00
|
|
|
super("w:pageBreakBefore");
|
|
|
|
}
|
|
|
|
}
|