Change docx folder to more appropriate "file" folder
This commit is contained in:
50
src/file/document/body/body.spec.ts
Normal file
50
src/file/document/body/body.spec.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { assert } from "chai";
|
||||
|
||||
import { Utility } from "../../../tests/utility";
|
||||
import { Body } from "./";
|
||||
import { Columns } from "./columns";
|
||||
import { DocumentGrid } from "./doc-grid";
|
||||
import { PageMargin } from "./page-margin";
|
||||
import { PageSize } from "./page-size";
|
||||
import { SectionProperties } from "./section-properties";
|
||||
|
||||
describe("Body", () => {
|
||||
let body: Body;
|
||||
|
||||
beforeEach(() => {
|
||||
body = new Body();
|
||||
body.push(new SectionProperties());
|
||||
body.push(new PageSize());
|
||||
body.push(new PageMargin());
|
||||
body.push(new Columns());
|
||||
body.push(new DocumentGrid());
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
|
||||
it("should create the Section Properties", () => {
|
||||
const newJson = Utility.jsonify(body);
|
||||
assert.equal(newJson.root[0].rootKey, "w:sectPr");
|
||||
});
|
||||
|
||||
it("should create the Page Size", () => {
|
||||
const newJson = Utility.jsonify(body);
|
||||
assert.equal(newJson.root[1].rootKey, "w:pgSz");
|
||||
});
|
||||
|
||||
it("should create the Page Margin", () => {
|
||||
const newJson = Utility.jsonify(body);
|
||||
assert.equal(newJson.root[2].rootKey, "w:pgMar");
|
||||
});
|
||||
|
||||
it("should create the Columns", () => {
|
||||
const newJson = Utility.jsonify(body);
|
||||
assert.equal(newJson.root[3].rootKey, "w:cols");
|
||||
});
|
||||
|
||||
it("should create the Document Grid", () => {
|
||||
const newJson = Utility.jsonify(body);
|
||||
assert.equal(newJson.root[4].rootKey, "w:docGrid");
|
||||
});
|
||||
});
|
||||
});
|
12
src/file/document/body/body.ts
Normal file
12
src/file/document/body/body.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { XmlComponent } from "../../xml-components";
|
||||
|
||||
export class Body extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:body");
|
||||
}
|
||||
|
||||
public push(component: XmlComponent): void {
|
||||
this.root.push(component);
|
||||
}
|
||||
}
|
11
src/file/document/body/columns.ts
Normal file
11
src/file/document/body/columns.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Attributes, XmlComponent } from "../../xml-components";
|
||||
|
||||
export class Columns extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:cols");
|
||||
this.root.push(new Attributes({
|
||||
space: "708",
|
||||
}));
|
||||
}
|
||||
}
|
11
src/file/document/body/doc-grid.ts
Normal file
11
src/file/document/body/doc-grid.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Attributes, XmlComponent } from "../../xml-components";
|
||||
|
||||
export class DocumentGrid extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:docGrid");
|
||||
this.root.push(new Attributes({
|
||||
linePitch: "360",
|
||||
}));
|
||||
}
|
||||
}
|
1
src/file/document/body/index.ts
Normal file
1
src/file/document/body/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./body";
|
17
src/file/document/body/page-margin.ts
Normal file
17
src/file/document/body/page-margin.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { Attributes, XmlComponent } from "../../xml-components";
|
||||
|
||||
export class PageMargin extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:pgMar");
|
||||
this.root.push(new Attributes({
|
||||
top: "1440",
|
||||
right: "1440",
|
||||
bottom: "1440",
|
||||
left: "1440",
|
||||
header: "708",
|
||||
footer: "708",
|
||||
gutter: "0",
|
||||
}));
|
||||
}
|
||||
}
|
12
src/file/document/body/page-size.ts
Normal file
12
src/file/document/body/page-size.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Attributes, XmlComponent } from "../../xml-components";
|
||||
|
||||
export class PageSize extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:pgSz");
|
||||
this.root.push(new Attributes({
|
||||
w: "11906",
|
||||
h: "16838",
|
||||
}));
|
||||
}
|
||||
}
|
21
src/file/document/body/section-properties.ts
Normal file
21
src/file/document/body/section-properties.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Attributes, XmlComponent } from "../../xml-components";
|
||||
import { Columns } from "./columns";
|
||||
import { DocumentGrid } from "./doc-grid";
|
||||
import { PageMargin } from "./page-margin";
|
||||
import { PageSize } from "./page-size";
|
||||
|
||||
export class SectionProperties extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:sectPr");
|
||||
this.root.push(new Attributes({
|
||||
rsidR: "00B64E8F",
|
||||
rsidRPr: "00D842E4",
|
||||
rsidSect: "000A6AD0",
|
||||
}));
|
||||
this.root.push(new PageSize());
|
||||
this.root.push(new PageMargin());
|
||||
this.root.push(new Columns());
|
||||
this.root.push(new DocumentGrid());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user