Export new ColumnBreak class via more generic Break class

This commit is contained in:
askoufis
2021-07-08 17:39:21 +10:00
parent bde4aa4657
commit 439ab8441e
6 changed files with 74 additions and 7 deletions

View File

@ -0,0 +1,43 @@
// http://officeopenxml.com/WPtextSpecialContent-break.php
import { Attributes, XmlComponent } from "file/xml-components";
import { Run } from "../run";
enum BreakType {
COLUMN = "column",
PAGE = "page",
// textWrapping breaks are the default and already exposed via the "Run" class
}
class Break extends XmlComponent {
constructor(type: BreakType) {
super("w:br");
this.root.push(
new Attributes({
type,
}),
);
}
}
export class PageBreak extends Run {
constructor() {
super({});
this.root.push(new Break(BreakType.PAGE));
}
}
export class ColumnBreak extends Run {
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 {
constructor() {
super("w:pageBreakBefore");
}
}