Export new ColumnBreak
class via more generic Break
class
This commit is contained in:
@ -2,7 +2,7 @@ import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { PageBreak, PageBreakBefore } from "./page-break";
|
||||
import { ColumnBreak, PageBreak, PageBreakBefore } from "./break";
|
||||
|
||||
describe("PageBreak", () => {
|
||||
let pageBreak: PageBreak;
|
||||
@ -29,6 +29,31 @@ describe("PageBreak", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("ColumnBreak", () => {
|
||||
let columnBreak: ColumnBreak;
|
||||
|
||||
beforeEach(() => {
|
||||
columnBreak = new ColumnBreak();
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Column Break with correct attributes", () => {
|
||||
const tree = new Formatter().format(columnBreak);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
"w:br": {
|
||||
_attr: {
|
||||
"w:type": "column",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("PageBreakBefore", () => {
|
||||
it("should create page break before", () => {
|
||||
const pageBreakBefore = new PageBreakBefore();
|
@ -2,12 +2,18 @@
|
||||
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() {
|
||||
constructor(type: BreakType) {
|
||||
super("w:br");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
type: "page",
|
||||
type,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@ -16,7 +22,14 @@ class Break extends XmlComponent {
|
||||
export class PageBreak extends Run {
|
||||
constructor() {
|
||||
super({});
|
||||
this.root.push(new Break());
|
||||
this.root.push(new Break(BreakType.PAGE));
|
||||
}
|
||||
}
|
||||
|
||||
export class ColumnBreak extends Run {
|
||||
constructor() {
|
||||
super({});
|
||||
this.root.push(new Break(BreakType.COLUMN));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
export * from "./alignment";
|
||||
export * from "./border";
|
||||
export * from "./indent";
|
||||
export * from "./page-break";
|
||||
export * from "./break";
|
||||
export * from "./spacing";
|
||||
export * from "./style";
|
||||
export * from "./tab-stop";
|
||||
|
Reference in New Issue
Block a user