Files
docx-js/src/file/paragraph/formatting/break.ts
Stepan Svechnikov a756a7697c Change all project enums to objects with as const (#2445)
* feat: change all enums to as const objects

* Add word to dictionary

---------

Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
2023-12-22 01:25:00 +00:00

44 lines
1.0 KiB
TypeScript

// 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");
}
}