Made project Prettier compliant
This commit is contained in:
@ -76,6 +76,5 @@ export class Compiler {
|
|||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,10 @@ export class ExpressPacker implements IPacker {
|
|||||||
this.res = res;
|
this.res = res;
|
||||||
|
|
||||||
this.res.on("close", () => {
|
this.res.on("close", () => {
|
||||||
return res.status(200).send("OK").end();
|
return res
|
||||||
|
.status(200)
|
||||||
|
.send("OK")
|
||||||
|
.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,5 @@ export class LocalPacker implements IPacker {
|
|||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,21 +13,22 @@ export class PdfConvertWrapper {
|
|||||||
url: "http://mirror1.convertonlinefree.com",
|
url: "http://mirror1.convertonlinefree.com",
|
||||||
encoding: null,
|
encoding: null,
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36",
|
"User-Agent":
|
||||||
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36",
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
"__EVENTTARGET": "",
|
__EVENTTARGET: "",
|
||||||
"__EVENTARGUMENT": "",
|
__EVENTARGUMENT: "",
|
||||||
"__VIEWSTATE": "",
|
__VIEWSTATE: "",
|
||||||
"ctl00$MainContent$fu": {
|
ctl00$MainContent$fu: {
|
||||||
value: fs.readFileSync(filePath),
|
value: fs.readFileSync(filePath),
|
||||||
options: {
|
options: {
|
||||||
filename: "output.docx",
|
filename: "output.docx",
|
||||||
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ctl00$MainContent$btnConvert": "Convert",
|
ctl00$MainContent$btnConvert: "Convert",
|
||||||
"ctl00$MainContent$fuZip": "",
|
ctl00$MainContent$fuZip: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ describe("Body", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should create the Section Properties", () => {
|
it("should create the Section Properties", () => {
|
||||||
const newJson = Utility.jsonify(body);
|
const newJson = Utility.jsonify(body);
|
||||||
assert.equal(newJson.root[0].rootKey, "w:sectPr");
|
assert.equal(newJson.root[0].rootKey, "w:sectPr");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Body extends XmlComponent {
|
export class Body extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:body");
|
super("w:body");
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Columns extends XmlComponent {
|
export class Columns extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:cols");
|
super("w:cols");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
space: "708",
|
space: "708",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class DocumentGrid extends XmlComponent {
|
export class DocumentGrid extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:docGrid");
|
super("w:docGrid");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
linePitch: "360",
|
linePitch: "360",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class PageMargin extends XmlComponent {
|
export class PageMargin extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:pgMar");
|
super("w:pgMar");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
top: "1440",
|
top: "1440",
|
||||||
right: "1440",
|
right: "1440",
|
||||||
bottom: "1440",
|
bottom: "1440",
|
||||||
@ -12,6 +12,7 @@ export class PageMargin extends XmlComponent {
|
|||||||
header: "708",
|
header: "708",
|
||||||
footer: "708",
|
footer: "708",
|
||||||
gutter: "0",
|
gutter: "0",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class PageSize extends XmlComponent {
|
export class PageSize extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:pgSz");
|
super("w:pgSz");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
w: "11906",
|
w: "11906",
|
||||||
h: "16838",
|
h: "16838",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,15 @@ import { PageMargin } from "./page-margin";
|
|||||||
import { PageSize } from "./page-size";
|
import { PageSize } from "./page-size";
|
||||||
|
|
||||||
export class SectionProperties extends XmlComponent {
|
export class SectionProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:sectPr");
|
super("w:sectPr");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
rsidR: "00B64E8F",
|
rsidR: "00B64E8F",
|
||||||
rsidRPr: "00D842E4",
|
rsidRPr: "00D842E4",
|
||||||
rsidSect: "000A6AD0",
|
rsidSect: "000A6AD0",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(new PageSize());
|
this.root.push(new PageSize());
|
||||||
this.root.push(new PageMargin());
|
this.root.push(new PageMargin());
|
||||||
this.root.push(new Columns());
|
this.root.push(new Columns());
|
||||||
|
@ -11,7 +11,6 @@ describe("Document", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should create valid JSON", () => {
|
it("should create valid JSON", () => {
|
||||||
const stringifiedJson = JSON.stringify(document);
|
const stringifiedJson = JSON.stringify(document);
|
||||||
let newJson;
|
let newJson;
|
||||||
@ -30,7 +29,9 @@ describe("Document", () => {
|
|||||||
const para = document.createParagraph();
|
const para = document.createParagraph();
|
||||||
expect(para).to.be.an.instanceof(docx.Paragraph);
|
expect(para).to.be.an.instanceof(docx.Paragraph);
|
||||||
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
||||||
expect(body).to.be.an("array").which.has.length.at.least(1);
|
expect(body)
|
||||||
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(body[0]).to.have.property("w:p");
|
expect(body[0]).to.have.property("w:p");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -38,12 +39,13 @@ describe("Document", () => {
|
|||||||
const para = document.createParagraph("sample paragraph text");
|
const para = document.createParagraph("sample paragraph text");
|
||||||
expect(para).to.be.an.instanceof(docx.Paragraph);
|
expect(para).to.be.an.instanceof(docx.Paragraph);
|
||||||
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
||||||
expect(body).to.be.an("array").which.has.length.at.least(1);
|
expect(body)
|
||||||
expect(body[0]).to.have.property("w:p").which.includes({
|
.to.be.an("array")
|
||||||
"w:r": [
|
.which.has.length.at.least(1);
|
||||||
{"w:rPr": []},
|
expect(body[0])
|
||||||
{"w:t": [{_attr: {"xml:space": "preserve"}}, "sample paragraph text"]},
|
.to.have.property("w:p")
|
||||||
],
|
.which.includes({
|
||||||
|
"w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, "sample paragraph text"] }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -53,15 +55,21 @@ describe("Document", () => {
|
|||||||
const table = document.createTable(2, 3);
|
const table = document.createTable(2, 3);
|
||||||
expect(table).to.be.an.instanceof(docx.Table);
|
expect(table).to.be.an.instanceof(docx.Table);
|
||||||
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
||||||
expect(body).to.be.an("array").which.has.length.at.least(1);
|
expect(body)
|
||||||
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(body[0]).to.have.property("w:tbl");
|
expect(body[0]).to.have.property("w:tbl");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create a table with the correct dimensions", () => {
|
it("should create a table with the correct dimensions", () => {
|
||||||
document.createTable(2, 3);
|
document.createTable(2, 3);
|
||||||
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
const body = new Formatter().format(document)["w:document"][1]["w:body"];
|
||||||
expect(body).to.be.an("array").which.has.length.at.least(1);
|
expect(body)
|
||||||
expect(body[0]).to.have.property("w:tbl").which.includes({
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
|
expect(body[0])
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.includes({
|
||||||
"w:tblGrid": [
|
"w:tblGrid": [
|
||||||
{ "w:gridCol": [{ _attr: { "w:w": 1 } }] },
|
{ "w:gridCol": [{ _attr: { "w:w": 1 } }] },
|
||||||
{ "w:gridCol": [{ _attr: { "w:w": 1 } }] },
|
{ "w:gridCol": [{ _attr: { "w:w": 1 } }] },
|
||||||
|
@ -11,7 +11,8 @@ export class Document extends XmlComponent {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:document");
|
super("w:document");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(
|
||||||
|
new DocumentAttributes({
|
||||||
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
||||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||||
o: "urn:schemas-microsoft-com:office:office",
|
o: "urn:schemas-microsoft-com:office:office",
|
||||||
@ -29,7 +30,8 @@ export class Document extends XmlComponent {
|
|||||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||||
Ignorable: "w14 w15 wp14",
|
Ignorable: "w14 w15 wp14",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.body = new Body();
|
this.body = new Body();
|
||||||
this.root.push(this.body);
|
this.root.push(this.body);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { Inline } from "./inline";
|
import { Inline } from "./inline";
|
||||||
|
|
||||||
export class Drawing extends XmlComponent {
|
export class Drawing extends XmlComponent {
|
||||||
|
|
||||||
constructor(imageData: IMediaData) {
|
constructor(imageData: IMediaData) {
|
||||||
super("w:drawing");
|
super("w:drawing");
|
||||||
|
|
||||||
|
@ -2,14 +2,15 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { DocPropertiesAttributes } from "./doc-properties-attributes";
|
import { DocPropertiesAttributes } from "./doc-properties-attributes";
|
||||||
|
|
||||||
export class DocProperties extends XmlComponent {
|
export class DocProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("wp:docPr");
|
super("wp:docPr");
|
||||||
|
|
||||||
this.root.push(new DocPropertiesAttributes({
|
this.root.push(
|
||||||
|
new DocPropertiesAttributes({
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
descr: "",
|
descr: "",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,16 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { EffectExtentAttributes } from "./effect-extent-attributes";
|
import { EffectExtentAttributes } from "./effect-extent-attributes";
|
||||||
|
|
||||||
export class EffectExtent extends XmlComponent {
|
export class EffectExtent extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("wp:effectExtent");
|
super("wp:effectExtent");
|
||||||
|
|
||||||
this.root.push(new EffectExtentAttributes({
|
this.root.push(
|
||||||
|
new EffectExtentAttributes({
|
||||||
b: 0,
|
b: 0,
|
||||||
l: 0,
|
l: 0,
|
||||||
r: 0,
|
r: 0,
|
||||||
t: 0,
|
t: 0,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,14 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { ExtentAttributes } from "./extent-attributes";
|
import { ExtentAttributes } from "./extent-attributes";
|
||||||
|
|
||||||
export class Extent extends XmlComponent {
|
export class Extent extends XmlComponent {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super("wp:extent");
|
super("wp:extent");
|
||||||
|
|
||||||
this.root.push(new ExtentAttributes({
|
this.root.push(
|
||||||
|
new ExtentAttributes({
|
||||||
cx: x,
|
cx: x,
|
||||||
cy: y,
|
cy: y,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,14 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { GraphicFrameLockAttributes } from "./graphic-frame-lock-attributes";
|
import { GraphicFrameLockAttributes } from "./graphic-frame-lock-attributes";
|
||||||
|
|
||||||
export class GraphicFrameLocks extends XmlComponent {
|
export class GraphicFrameLocks extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:graphicFrameLocks");
|
super("a:graphicFrameLocks");
|
||||||
|
|
||||||
this.root.push(new GraphicFrameLockAttributes({
|
this.root.push(
|
||||||
|
new GraphicFrameLockAttributes({
|
||||||
xmlns: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
xmlns: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||||
noChangeAspect: 1,
|
noChangeAspect: 1,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { GraphicFrameLocks } from "./graphic-frame-locks/graphic-frame-locks";
|
import { GraphicFrameLocks } from "./graphic-frame-locks/graphic-frame-locks";
|
||||||
|
|
||||||
export class GraphicFrameProperties extends XmlComponent {
|
export class GraphicFrameProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("wp:cNvGraphicFramePr");
|
super("wp:cNvGraphicFramePr");
|
||||||
|
|
||||||
|
@ -3,13 +3,14 @@ import { GraphicDataAttributes } from "./graphic-data-attribute";
|
|||||||
import { Pic } from "./pic";
|
import { Pic } from "./pic";
|
||||||
|
|
||||||
export class GraphicData extends XmlComponent {
|
export class GraphicData extends XmlComponent {
|
||||||
|
|
||||||
constructor(referenceId: number, x: number, y: number) {
|
constructor(referenceId: number, x: number, y: number) {
|
||||||
super("a:graphicData");
|
super("a:graphicData");
|
||||||
|
|
||||||
this.root.push(new GraphicDataAttributes({
|
this.root.push(
|
||||||
|
new GraphicDataAttributes({
|
||||||
uri: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
uri: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.root.push(new Pic(referenceId, x, y));
|
this.root.push(new Pic(referenceId, x, y));
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import { SourceRectangle } from "./source-rectangle";
|
|||||||
import { Stretch } from "./stretch";
|
import { Stretch } from "./stretch";
|
||||||
|
|
||||||
export class BlipFill extends XmlComponent {
|
export class BlipFill extends XmlComponent {
|
||||||
|
|
||||||
constructor(referenceId: number) {
|
constructor(referenceId: number) {
|
||||||
super("pic:blipFill");
|
super("pic:blipFill");
|
||||||
this.root.push(new Blip(referenceId));
|
this.root.push(new Blip(referenceId));
|
||||||
|
@ -13,12 +13,13 @@ class BlipAttributes extends XmlAttributeComponent<IBlipProperties> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Blip extends XmlComponent {
|
export class Blip extends XmlComponent {
|
||||||
|
|
||||||
constructor(referenceId: number) {
|
constructor(referenceId: number) {
|
||||||
super("a:blip");
|
super("a:blip");
|
||||||
this.root.push(new BlipAttributes({
|
this.root.push(
|
||||||
|
new BlipAttributes({
|
||||||
embed: `rId${referenceId}`,
|
embed: `rId${referenceId}`,
|
||||||
cstate: "none",
|
cstate: "none",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class SourceRectangle extends XmlComponent {
|
export class SourceRectangle extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:srcRect");
|
super("a:srcRect");
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class FillRectangle extends XmlComponent {
|
class FillRectangle extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:fillRect");
|
super("a:fillRect");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Stretch extends XmlComponent {
|
export class Stretch extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:stretch");
|
super("a:stretch");
|
||||||
this.root.push(new FillRectangle());
|
this.root.push(new FillRectangle());
|
||||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { PicLocks } from "./pic-locks/pic-locks";
|
import { PicLocks } from "./pic-locks/pic-locks";
|
||||||
|
|
||||||
export class ChildNonVisualProperties extends XmlComponent {
|
export class ChildNonVisualProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("pic:cNvPicPr");
|
super("pic:cNvPicPr");
|
||||||
|
|
||||||
|
@ -2,12 +2,13 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { PicLocksAttributes } from "./pic-locks-attributes";
|
import { PicLocksAttributes } from "./pic-locks-attributes";
|
||||||
|
|
||||||
export class PicLocks extends XmlComponent {
|
export class PicLocks extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:picLocks");
|
super("a:picLocks");
|
||||||
this.root.push(new PicLocksAttributes({
|
this.root.push(
|
||||||
|
new PicLocksAttributes({
|
||||||
noChangeAspect: 1,
|
noChangeAspect: 1,
|
||||||
noChangeArrowheads: 1,
|
noChangeArrowheads: 1,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@ import { ChildNonVisualProperties } from "./child-non-visual-pic-properties/chil
|
|||||||
import { NonVisualProperties } from "./non-visual-properties/non-visual-properties";
|
import { NonVisualProperties } from "./non-visual-properties/non-visual-properties";
|
||||||
|
|
||||||
export class NonVisualPicProperties extends XmlComponent {
|
export class NonVisualPicProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("pic:nvPicPr");
|
super("pic:nvPicPr");
|
||||||
|
|
||||||
this.root.push(new NonVisualProperties());
|
this.root.push(new NonVisualProperties());
|
||||||
this.root.push(new ChildNonVisualProperties());
|
this.root.push(new ChildNonVisualProperties());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,15 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { NonVisualPropertiesAttributes } from "./non-visual-properties-attributes";
|
import { NonVisualPropertiesAttributes } from "./non-visual-properties-attributes";
|
||||||
|
|
||||||
export class NonVisualProperties extends XmlComponent {
|
export class NonVisualProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("pic:cNvPr");
|
super("pic:cNvPr");
|
||||||
|
|
||||||
this.root.push(new NonVisualPropertiesAttributes({
|
this.root.push(
|
||||||
|
new NonVisualPropertiesAttributes({
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
descr: "",
|
descr: "",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,11 @@ export class Pic extends XmlComponent {
|
|||||||
constructor(referenceId: number, x: number, y: number) {
|
constructor(referenceId: number, x: number, y: number) {
|
||||||
super("pic:pic");
|
super("pic:pic");
|
||||||
|
|
||||||
this.root.push(new PicAttributes({
|
this.root.push(
|
||||||
|
new PicAttributes({
|
||||||
xmlns: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
xmlns: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(new NonVisualPicProperties());
|
this.root.push(new NonVisualPicProperties());
|
||||||
this.root.push(new BlipFill(referenceId));
|
this.root.push(new BlipFill(referenceId));
|
||||||
this.root.push(new ShapeProperties(x, y));
|
this.root.push(new ShapeProperties(x, y));
|
||||||
|
@ -3,13 +3,14 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { ExtentsAttributes } from "./extents-attributes";
|
import { ExtentsAttributes } from "./extents-attributes";
|
||||||
|
|
||||||
export class Extents extends XmlComponent {
|
export class Extents extends XmlComponent {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super("a:ext");
|
super("a:ext");
|
||||||
|
|
||||||
this.root.push(new ExtentsAttributes({
|
this.root.push(
|
||||||
|
new ExtentsAttributes({
|
||||||
cx: x,
|
cx: x,
|
||||||
cy: y,
|
cy: y,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import { Extents } from "./extents/extents";
|
|||||||
import { Offset } from "./offset/off";
|
import { Offset } from "./offset/off";
|
||||||
|
|
||||||
export class Form extends XmlComponent {
|
export class Form extends XmlComponent {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super("a:xfrm");
|
super("a:xfrm");
|
||||||
|
|
||||||
|
@ -3,13 +3,14 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { OffsetAttributes } from "./off-attributes";
|
import { OffsetAttributes } from "./off-attributes";
|
||||||
|
|
||||||
export class Offset extends XmlComponent {
|
export class Offset extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:off");
|
super("a:off");
|
||||||
|
|
||||||
this.root.push(new OffsetAttributes({
|
this.root.push(
|
||||||
|
new OffsetAttributes({
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class NoFill extends XmlComponent {
|
export class NoFill extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:noFill");
|
super("a:noFill");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class NoFill extends XmlComponent {
|
export class NoFill extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:noFill");
|
super("a:noFill");
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { NoFill } from "./no-fill";
|
import { NoFill } from "./no-fill";
|
||||||
|
|
||||||
export class Outline extends XmlComponent {
|
export class Outline extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:ln");
|
super("a:ln");
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class AdjustmentValues extends XmlComponent {
|
export class AdjustmentValues extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:avLst");
|
super("a:avLst");
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,14 @@ import { AdjustmentValues } from "./adjustment-values/adjustment-values";
|
|||||||
import { PresetGeometryAttributes } from "./preset-geometry-attributes";
|
import { PresetGeometryAttributes } from "./preset-geometry-attributes";
|
||||||
|
|
||||||
export class PresetGeometry extends XmlComponent {
|
export class PresetGeometry extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("a:prstGeom");
|
super("a:prstGeom");
|
||||||
|
|
||||||
this.root.push(new PresetGeometryAttributes({
|
this.root.push(
|
||||||
|
new PresetGeometryAttributes({
|
||||||
prst: "rect",
|
prst: "rect",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.root.push(new AdjustmentValues());
|
this.root.push(new AdjustmentValues());
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,14 @@ import { PresetGeometry } from "./preset-geometry/preset-geometry";
|
|||||||
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
||||||
|
|
||||||
export class ShapeProperties extends XmlComponent {
|
export class ShapeProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super("pic:spPr");
|
super("pic:spPr");
|
||||||
|
|
||||||
this.root.push(new ShapePropertiesAttributes({
|
this.root.push(
|
||||||
|
new ShapePropertiesAttributes({
|
||||||
bwMode: "auto",
|
bwMode: "auto",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.root.push(new Form(x, y));
|
this.root.push(new Form(x, y));
|
||||||
this.root.push(new PresetGeometry());
|
this.root.push(new PresetGeometry());
|
||||||
|
@ -12,12 +12,13 @@ class GraphicAttributes extends XmlAttributeComponent<IGraphicProperties> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Graphic extends XmlComponent {
|
export class Graphic extends XmlComponent {
|
||||||
|
|
||||||
constructor(referenceId: number, x: number, y: number) {
|
constructor(referenceId: number, x: number, y: number) {
|
||||||
super("a:graphic");
|
super("a:graphic");
|
||||||
this.root.push(new GraphicAttributes({
|
this.root.push(
|
||||||
|
new GraphicAttributes({
|
||||||
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(new GraphicData(referenceId, x, y));
|
this.root.push(new GraphicData(referenceId, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,17 @@ import { GraphicFrameProperties } from "./graphic-frame/graphic-frame-properties
|
|||||||
import { InlineAttributes } from "./inline-attributes";
|
import { InlineAttributes } from "./inline-attributes";
|
||||||
|
|
||||||
export class Inline extends XmlComponent {
|
export class Inline extends XmlComponent {
|
||||||
|
|
||||||
constructor(referenceId: number, dimensions: IMediaDataDimensions) {
|
constructor(referenceId: number, dimensions: IMediaDataDimensions) {
|
||||||
super("wp:inline");
|
super("wp:inline");
|
||||||
|
|
||||||
this.root.push(new InlineAttributes({
|
this.root.push(
|
||||||
|
new InlineAttributes({
|
||||||
distT: 0,
|
distT: 0,
|
||||||
distB: 0,
|
distB: 0,
|
||||||
distL: 0,
|
distL: 0,
|
||||||
distR: 0,
|
distR: 0,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.root.push(new Extent(dimensions.emus.x, dimensions.emus.y));
|
this.root.push(new Extent(dimensions.emus.x, dimensions.emus.y));
|
||||||
this.root.push(new EffectExtent());
|
this.root.push(new EffectExtent());
|
||||||
|
@ -9,7 +9,6 @@ import { DefaultStylesFactory } from "./styles/factory";
|
|||||||
import { Table } from "./table";
|
import { Table } from "./table";
|
||||||
|
|
||||||
export class File {
|
export class File {
|
||||||
|
|
||||||
private document: Document;
|
private document: Document;
|
||||||
private styles: Styles;
|
private styles: Styles;
|
||||||
private properties: Properties;
|
private properties: Properties;
|
||||||
@ -54,7 +53,11 @@ export class File {
|
|||||||
|
|
||||||
public createImage(image: string): void {
|
public createImage(image: string): void {
|
||||||
const mediaData = this.media.addMedia(image);
|
const mediaData = this.media.addMedia(image);
|
||||||
this.relationships.createRelationship(mediaData.referenceId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${mediaData.fileName}`);
|
this.relationships.createRelationship(
|
||||||
|
mediaData.referenceId,
|
||||||
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
||||||
|
`media/${mediaData.fileName}`,
|
||||||
|
);
|
||||||
this.document.createDrawing(mediaData);
|
this.document.createDrawing(mediaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,12 @@ export class AbstractNumbering extends XmlComponent {
|
|||||||
|
|
||||||
constructor(id: number) {
|
constructor(id: number) {
|
||||||
super("w:abstractNum");
|
super("w:abstractNum");
|
||||||
this.root.push(new AbstractNumberingAttributes({
|
this.root.push(
|
||||||
|
new AbstractNumberingAttributes({
|
||||||
abstractNumId: id,
|
abstractNumId: id,
|
||||||
restartNumberingAfterBreak: 0,
|
restartNumberingAfterBreak: 0,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(new MultiLevelType("hybridMultilevel"));
|
this.root.push(new MultiLevelType("hybridMultilevel"));
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
@ -17,42 +17,46 @@ class LevelAttributes extends XmlAttributeComponent<ILevelAttributesProperties>
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Start extends XmlComponent {
|
class Start extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: number) {
|
constructor(value: number) {
|
||||||
super("w:start");
|
super("w:start");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NumberFormat extends XmlComponent {
|
class NumberFormat extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:numFmt");
|
super("w:numFmt");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LevelText extends XmlComponent {
|
class LevelText extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:lvlText");
|
super("w:lvlText");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LevelJc extends XmlComponent {
|
class LevelJc extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:lvlJc");
|
super("w:lvlJc");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,10 +66,12 @@ export class LevelBase extends XmlComponent {
|
|||||||
|
|
||||||
constructor(level: number, start?: number, numberFormat?: string, levelText?: string, lvlJc?: string) {
|
constructor(level: number, start?: number, numberFormat?: string, levelText?: string, lvlJc?: string) {
|
||||||
super("w:lvl");
|
super("w:lvl");
|
||||||
this.root.push(new LevelAttributes({
|
this.root.push(
|
||||||
|
new LevelAttributes({
|
||||||
ilvl: level,
|
ilvl: level,
|
||||||
tentative: 1,
|
tentative: 1,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
if (start !== undefined) {
|
if (start !== undefined) {
|
||||||
this.root.push(new Start(start));
|
this.root.push(new Start(start));
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class MultiLevelType extends XmlComponent {
|
export class MultiLevelType extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:multiLevelType");
|
super("w:multiLevelType");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,13 @@ import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-compon
|
|||||||
import { LevelForOverride } from "./level";
|
import { LevelForOverride } from "./level";
|
||||||
|
|
||||||
class AbstractNumId extends XmlComponent {
|
class AbstractNumId extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: number) {
|
constructor(value: number) {
|
||||||
super("w:abstractNumId");
|
super("w:abstractNumId");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,9 +25,11 @@ export class Num extends XmlComponent {
|
|||||||
|
|
||||||
constructor(numId: number, abstractNumId: number) {
|
constructor(numId: number, abstractNumId: number) {
|
||||||
super("w:num");
|
super("w:num");
|
||||||
this.root.push(new NumAttributes({
|
this.root.push(
|
||||||
|
new NumAttributes({
|
||||||
numId: numId,
|
numId: numId,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(new AbstractNumId(abstractNumId));
|
this.root.push(new AbstractNumId(abstractNumId));
|
||||||
this.id = numId;
|
this.id = numId;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import { LevelForOverride } from "./level";
|
|||||||
import { Num } from "./num";
|
import { Num } from "./num";
|
||||||
|
|
||||||
describe("Numbering", () => {
|
describe("Numbering", () => {
|
||||||
|
|
||||||
let numbering: Numbering;
|
let numbering: Numbering;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -26,9 +25,7 @@ describe("Numbering", () => {
|
|||||||
|
|
||||||
abstractNums.filter((el) => el["w:lvl"]).forEach((el, ix) => {
|
abstractNums.filter((el) => el["w:lvl"]).forEach((el, ix) => {
|
||||||
expect(Object.keys(el)).to.have.lengthOf(1);
|
expect(Object.keys(el)).to.have.lengthOf(1);
|
||||||
expect(Object.keys(el["w:lvl"]).sort()).to.deep.equal([
|
expect(Object.keys(el["w:lvl"]).sort()).to.deep.equal(["_attr", "w:start", "w:lvlJc", "w:numFmt", "w:pPr", "w:rPr"]);
|
||||||
"_attr", "w:start", "w:lvlJc", "w:numFmt", "w:pPr", "w:rPr",
|
|
||||||
]);
|
|
||||||
expect(el["w:lvl"]).to.have.deep.members([
|
expect(el["w:lvl"]).to.have.deep.members([
|
||||||
{ _attr: { "w:ilvl": ix, "w15:tentative": 1 } },
|
{ _attr: { "w:ilvl": ix, "w15:tentative": 1 } },
|
||||||
{ "w:start": [{ _attr: { "w:val": 1 } }] },
|
{ "w:start": [{ _attr: { "w:val": 1 } }] },
|
||||||
@ -63,9 +60,7 @@ describe("Numbering", () => {
|
|||||||
const n = numbering.createConcreteNumbering(a2);
|
const n = numbering.createConcreteNumbering(a2);
|
||||||
expect(n).to.be.instanceof(Num);
|
expect(n).to.be.instanceof(Num);
|
||||||
const tree = new Formatter().format(numbering);
|
const tree = new Formatter().format(numbering);
|
||||||
const serializedN = tree["w:numbering"].find((obj) =>
|
const serializedN = tree["w:numbering"].find((obj) => obj["w:num"] && obj["w:num"][0]._attr["w:numId"] === n.id);
|
||||||
obj["w:num"] && obj["w:num"][0]._attr["w:numId"] === n.id,
|
|
||||||
);
|
|
||||||
expect(serializedN["w:num"][1]["w:abstractNumId"][0]._attr["w:val"]).to.equal(a2.id);
|
expect(serializedN["w:num"][1]["w:abstractNumId"][0]._attr["w:val"]).to.equal(a2.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,8 +105,7 @@ describe("AbstractNumbering", () => {
|
|||||||
describe("formatting methods: paragraph properties", () => {
|
describe("formatting methods: paragraph properties", () => {
|
||||||
it("#indent", () => {
|
it("#indent", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerLetter", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerLetter", "%0.").indent({ left: 720 });
|
||||||
.indent({ left: 720 });
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [{ "w:ind": [{ _attr: { "w:left": 720 } }] }],
|
"w:pPr": [{ "w:ind": [{ _attr: { "w:left": 720 } }] }],
|
||||||
@ -120,113 +114,104 @@ describe("AbstractNumbering", () => {
|
|||||||
|
|
||||||
it("#spacing", () => {
|
it("#spacing", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerLetter", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerLetter", "%0.").spacing({ before: 50, after: 150 });
|
||||||
.spacing({before: 50, after: 150});
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:spacing": [{ _attr: { "w:before": 50, "w:after": 150 } }] }],
|
||||||
{"w:spacing": [{_attr: {"w:before": 50, "w:after": 150}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#center", () => {
|
it("#center", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerLetter", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerLetter", "%0.").center();
|
||||||
.center();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "center" } }] }],
|
||||||
{"w:jc": [{_attr: {"w:val": "center"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#left", () => {
|
it("#left", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.", "left")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.", "left").left();
|
||||||
.left();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "left" } }] }],
|
||||||
{"w:jc": [{_attr: {"w:val": "left"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#right", () => {
|
it("#right", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").right();
|
||||||
.right();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "right" } }] }],
|
||||||
{"w:jc": [{_attr: {"w:val": "right"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#justified", () => {
|
it("#justified", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").justified();
|
||||||
.justified();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "both" } }] }],
|
||||||
{"w:jc": [{_attr: {"w:val": "both"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#thematicBreak", () => {
|
it("#thematicBreak", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").thematicBreak();
|
||||||
.thematicBreak();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [
|
||||||
{"w:pBdr": [{"w:bottom": [{_attr: {
|
{
|
||||||
|
"w:pBdr": [
|
||||||
|
{
|
||||||
|
"w:bottom": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
"w:color": "auto",
|
"w:color": "auto",
|
||||||
"w:space": "1",
|
"w:space": "1",
|
||||||
"w:val": "single",
|
"w:val": "single",
|
||||||
"w:sz": "6",
|
"w:sz": "6",
|
||||||
}}]}]},
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#leftTabStop", () => {
|
it("#leftTabStop", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").leftTabStop(1200);
|
||||||
.leftTabStop(1200);
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [
|
||||||
{"w:tabs": [
|
{
|
||||||
{"w:tab": [{_attr: {"w:val": "left", "w:pos": 1200}}]},
|
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "left", "w:pos": 1200 } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#maxRightTabStop", () => {
|
it("#maxRightTabStop", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").maxRightTabStop();
|
||||||
.maxRightTabStop();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [
|
"w:pPr": [
|
||||||
{"w:tabs": [
|
{
|
||||||
{"w:tab": [{_attr: {"w:val": "right", "w:pos": 9026}}]},
|
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "right", "w:pos": 9026 } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#keepLines", () => {
|
it("#keepLines", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").keepLines();
|
||||||
.keepLines();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [{ "w:keepLines": [] }],
|
"w:pPr": [{ "w:keepLines": [] }],
|
||||||
@ -235,8 +220,7 @@ describe("AbstractNumbering", () => {
|
|||||||
|
|
||||||
it("#keepNext", () => {
|
it("#keepNext", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").keepNext();
|
||||||
.keepNext();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:pPr": [{ "w:keepNext": [] }],
|
"w:pPr": [{ "w:keepNext": [] }],
|
||||||
@ -247,92 +231,70 @@ describe("AbstractNumbering", () => {
|
|||||||
describe("formatting methods: run properties", () => {
|
describe("formatting methods: run properties", () => {
|
||||||
it("#size", () => {
|
it("#size", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").size(24);
|
||||||
.size(24);
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:sz": [{ _attr: { "w:val": 24 } }] }],
|
||||||
{"w:sz": [{_attr: {"w:val": 24}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#smallCaps", () => {
|
it("#smallCaps", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").smallCaps();
|
||||||
.smallCaps();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:smallCaps": [{ _attr: { "w:val": true } }] }],
|
||||||
{"w:smallCaps": [{_attr: {"w:val": true}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#allCaps", () => {
|
it("#allCaps", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").allCaps();
|
||||||
.allCaps();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:caps": [{ _attr: { "w:val": true } }] }],
|
||||||
{"w:caps": [{_attr: {"w:val": true}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#strike", () => {
|
it("#strike", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").strike();
|
||||||
.strike();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:strike": [{ _attr: { "w:val": true } }] }],
|
||||||
{"w:strike": [{_attr: {"w:val": true}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#doubleStrike", () => {
|
it("#doubleStrike", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").doubleStrike();
|
||||||
.doubleStrike();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:dstrike": [{ _attr: { "w:val": true } }] }],
|
||||||
{"w:dstrike": [{_attr: {"w:val": true}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#subScript", () => {
|
it("#subScript", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").subScript();
|
||||||
.subScript();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "subscript" } }] }],
|
||||||
{"w:vertAlign": [{_attr: {"w:val": "subscript"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#superScript", () => {
|
it("#superScript", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").superScript();
|
||||||
.superScript();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "superscript" } }] }],
|
||||||
{"w:vertAlign": [{_attr: {"w:val": "superscript"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#font", () => {
|
it("#font", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").font("Times");
|
||||||
.font("Times");
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times" } }] }],
|
"w:rPr": [{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times" } }] }],
|
||||||
@ -341,75 +303,57 @@ describe("AbstractNumbering", () => {
|
|||||||
|
|
||||||
it("#bold", () => {
|
it("#bold", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").bold();
|
||||||
.bold();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:b": [{ _attr: { "w:val": true } }] }],
|
||||||
{"w:b": [{_attr: {"w:val": true}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#italics", () => {
|
it("#italics", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").italics();
|
||||||
.italics();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:i": [{ _attr: { "w:val": true } }] }],
|
||||||
{"w:i": [{_attr: {"w:val": true}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#underline", () => {
|
describe("#underline", () => {
|
||||||
it("should set underline to 'single' if no arguments are given", () => {
|
it("should set underline to 'single' if no arguments are given", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").underline();
|
||||||
.underline();
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "single" } }] }],
|
||||||
{"w:u": [{_attr: {"w:val": "single"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style if given", () => {
|
it("should set the style if given", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").underline("double");
|
||||||
.underline("double");
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double" } }] }],
|
||||||
{"w:u": [{_attr: {"w:val": "double"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style and color if given", () => {
|
it("should set the style and color if given", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").underline("double", "005599");
|
||||||
.underline("double", "005599");
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double", "w:color": "005599" } }] }],
|
||||||
{"w:u": [{_attr: {"w:val": "double", "w:color": "005599"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1);
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.")
|
const level = abstractNumbering.createLevel(0, "lowerRoman", "%0.").color("123456");
|
||||||
.color("123456");
|
|
||||||
const tree = new Formatter().format(level);
|
const tree = new Formatter().format(level);
|
||||||
expect(tree["w:lvl"]).to.include({
|
expect(tree["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [{ "w:color": [{ _attr: { "w:val": "123456" } }] }],
|
||||||
{"w:color": [{_attr: {"w:val": "123456"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -425,7 +369,6 @@ describe("concrete numbering", () => {
|
|||||||
numbering = new Numbering();
|
numbering = new Numbering();
|
||||||
abstractNumbering = numbering.createAbstractNumbering();
|
abstractNumbering = numbering.createAbstractNumbering();
|
||||||
concreteNumbering = numbering.createConcreteNumbering(abstractNumbering);
|
concreteNumbering = numbering.createConcreteNumbering(abstractNumbering);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets a new override level for the given level number", () => {
|
it("sets a new override level for the given level number", () => {
|
||||||
@ -438,10 +381,7 @@ describe("concrete numbering", () => {
|
|||||||
concreteNumbering.overrideLevel(1, 9);
|
concreteNumbering.overrideLevel(1, 9);
|
||||||
const tree = new Formatter().format(concreteNumbering);
|
const tree = new Formatter().format(concreteNumbering);
|
||||||
expect(tree["w:num"]).to.include({
|
expect(tree["w:num"]).to.include({
|
||||||
"w:lvlOverride": [
|
"w:lvlOverride": [{ _attr: { "w:ilvl": 1 } }, { "w:startOverride": [{ _attr: { "w:val": 9 } }] }],
|
||||||
{_attr: {"w:ilvl": 1}},
|
|
||||||
{"w:startOverride": [{_attr: {"w:val": 9}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -452,11 +392,9 @@ describe("concrete numbering", () => {
|
|||||||
expect(tree["w:num"]).to.include({
|
expect(tree["w:num"]).to.include({
|
||||||
"w:lvlOverride": [
|
"w:lvlOverride": [
|
||||||
{ _attr: { "w:ilvl": 1 } },
|
{ _attr: { "w:ilvl": 1 } },
|
||||||
{"w:lvl": [
|
{
|
||||||
{_attr: {"w15:tentative": 1, "w:ilvl": 1}},
|
"w:lvl": [{ _attr: { "w15:tentative": 1, "w:ilvl": 1 } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||||
{"w:pPr": []},
|
},
|
||||||
{"w:rPr": []},
|
|
||||||
]},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,8 @@ export class Numbering extends XmlComponent {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:numbering");
|
super("w:numbering");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(
|
||||||
|
new DocumentAttributes({
|
||||||
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
||||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||||
o: "urn:schemas-microsoft-com:office:office",
|
o: "urn:schemas-microsoft-com:office:office",
|
||||||
@ -28,45 +29,55 @@ export class Numbering extends XmlComponent {
|
|||||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||||
Ignorable: "w14 w15 wp14",
|
Ignorable: "w14 w15 wp14",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.nextId = 0;
|
this.nextId = 0;
|
||||||
|
|
||||||
const abstractNumbering = this.createAbstractNumbering();
|
const abstractNumbering = this.createAbstractNumbering();
|
||||||
|
|
||||||
abstractNumbering.createLevel(0, "bullet", "•", "left")
|
abstractNumbering
|
||||||
|
.createLevel(0, "bullet", "•", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 720, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 720, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Symbol", "default"));
|
.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(1, "bullet", "o", "left")
|
abstractNumbering
|
||||||
|
.createLevel(1, "bullet", "o", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 1440, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 1440, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Courier New", "default"));
|
.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(2, "bullet", "•", "left")
|
abstractNumbering
|
||||||
|
.createLevel(2, "bullet", "•", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 2160, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 2160, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Wingdings", "default"));
|
.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(3, "bullet", "•", "left")
|
abstractNumbering
|
||||||
|
.createLevel(3, "bullet", "•", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 2880, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 2880, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Symbol", "default"));
|
.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(4, "bullet", "o", "left")
|
abstractNumbering
|
||||||
|
.createLevel(4, "bullet", "o", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 3600, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 3600, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Courier New", "default"));
|
.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(5, "bullet", "•", "left")
|
abstractNumbering
|
||||||
|
.createLevel(5, "bullet", "•", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 4320, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 4320, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Wingdings", "default"));
|
.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(6, "bullet", "•", "left")
|
abstractNumbering
|
||||||
|
.createLevel(6, "bullet", "•", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 5040, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 5040, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Symbol", "default"));
|
.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(7, "bullet", "o", "left")
|
abstractNumbering
|
||||||
|
.createLevel(7, "bullet", "o", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 5760, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 5760, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Courier New", "default"));
|
.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
|
|
||||||
abstractNumbering.createLevel(8, "bullet", "•", "left")
|
abstractNumbering
|
||||||
|
.createLevel(8, "bullet", "•", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 6480, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 6480, hanging: 360 }))
|
||||||
.addRunProperty(new RunFonts("Wingdings", "default"));
|
.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ export class AlignmentAttributes extends XmlAttributeComponent<{val: AlignmentOp
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Alignment extends XmlComponent {
|
export class Alignment extends XmlComponent {
|
||||||
|
|
||||||
constructor(type: AlignmentOptions) {
|
constructor(type: AlignmentOptions) {
|
||||||
super("w:jc");
|
super("w:jc");
|
||||||
this.root.push(new AlignmentAttributes({ val: type }));
|
this.root.push(new AlignmentAttributes({ val: type }));
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class Border extends XmlComponent {
|
class Border extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:bottom");
|
super("w:bottom");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
color: "auto",
|
color: "auto",
|
||||||
space: "1",
|
space: "1",
|
||||||
val: "single",
|
val: "single",
|
||||||
sz: "6",
|
sz: "6",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThematicBreak extends XmlComponent {
|
export class ThematicBreak extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:pBdr");
|
super("w:pBdr");
|
||||||
this.root.push(new Border());
|
this.root.push(new Border());
|
||||||
|
@ -20,7 +20,6 @@ class IndentAttributes extends XmlAttributeComponent<IIndentAttributesProperties
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Indent extends XmlComponent {
|
export class Indent extends XmlComponent {
|
||||||
|
|
||||||
constructor(attrs: object) {
|
constructor(attrs: object) {
|
||||||
super("w:ind");
|
super("w:ind");
|
||||||
this.root.push(new IndentAttributes(attrs));
|
this.root.push(new IndentAttributes(attrs));
|
||||||
|
@ -3,17 +3,17 @@ import { Attributes, XmlComponent } from "file/xml-components";
|
|||||||
import { Run } from "../run";
|
import { Run } from "../run";
|
||||||
|
|
||||||
class Break extends XmlComponent {
|
class Break extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:br");
|
super("w:br");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
type: "page",
|
type: "page",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PageBreak extends Run {
|
export class PageBreak extends Run {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.root.push(new Break());
|
this.root.push(new Break());
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Style extends XmlComponent {
|
export class Style extends XmlComponent {
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super("w:pStyle");
|
super("w:pStyle");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: type,
|
val: type,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class TabStop extends XmlComponent {
|
export class TabStop extends XmlComponent {
|
||||||
|
|
||||||
constructor(tab: Tab) {
|
constructor(tab: Tab) {
|
||||||
super("w:tabs");
|
super("w:tabs");
|
||||||
this.root.push(tab);
|
this.root.push(tab);
|
||||||
@ -11,18 +10,19 @@ export class TabStop extends XmlComponent {
|
|||||||
|
|
||||||
export type TabValue = "left" | "right" | "center" | "bar" | "clear" | "decimal" | "end" | "num" | "start";
|
export type TabValue = "left" | "right" | "center" | "bar" | "clear" | "decimal" | "end" | "num" | "start";
|
||||||
|
|
||||||
export class TabAttributes extends XmlAttributeComponent<{val: TabValue, pos: string | number}> {
|
export class TabAttributes extends XmlAttributeComponent<{ val: TabValue; pos: string | number }> {
|
||||||
protected xmlKeys = { val: "w:val", pos: "w:pos" };
|
protected xmlKeys = { val: "w:val", pos: "w:pos" };
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Tab extends XmlComponent {
|
export class Tab extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: TabValue, position: string | number) {
|
constructor(value: TabValue, position: string | number) {
|
||||||
super("w:tab");
|
super("w:tab");
|
||||||
this.root.push(new TabAttributes({
|
this.root.push(
|
||||||
|
new TabAttributes({
|
||||||
val: value,
|
val: value,
|
||||||
pos: position,
|
pos: position,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class NumberProperties extends XmlComponent {
|
export class NumberProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor(numberId: number, indentLevel: number) {
|
constructor(numberId: number, indentLevel: number) {
|
||||||
super("w:numPr");
|
super("w:numPr");
|
||||||
this.root.push(new IndentLevel(indentLevel));
|
this.root.push(new IndentLevel(indentLevel));
|
||||||
@ -10,20 +9,23 @@ export class NumberProperties extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IndentLevel extends XmlComponent {
|
class IndentLevel extends XmlComponent {
|
||||||
|
|
||||||
constructor(level: number) {
|
constructor(level: number) {
|
||||||
super("w:ilvl");
|
super("w:ilvl");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: level,
|
val: level,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NumberId extends XmlComponent {
|
class NumberId extends XmlComponent {
|
||||||
constructor(id: number) {
|
constructor(id: number) {
|
||||||
super("w:numId");
|
super("w:numId");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: id,
|
val: id,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ describe("Paragraph", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should create valid JSON", () => {
|
it("should create valid JSON", () => {
|
||||||
const stringifiedJson = JSON.stringify(paragraph);
|
const stringifiedJson = JSON.stringify(paragraph);
|
||||||
let newJson;
|
let newJson;
|
||||||
@ -37,11 +36,10 @@ describe("Paragraph", () => {
|
|||||||
const run = paragraph.createTextRun("this is a test run");
|
const run = paragraph.createTextRun("this is a test run");
|
||||||
expect(run).to.be.instanceof(file.TextRun);
|
expect(run).to.be.instanceof(file.TextRun);
|
||||||
const tree = new Formatter().format(paragraph)["w:p"];
|
const tree = new Formatter().format(paragraph)["w:p"];
|
||||||
expect(tree).to.be.an("array").which.includes({
|
expect(tree)
|
||||||
"w:r": [
|
.to.be.an("array")
|
||||||
{"w:rPr": []},
|
.which.includes({
|
||||||
{"w:t": [{_attr: {"xml:space": "preserve"}}, "this is a test run"]},
|
"w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, "this is a test run"] }],
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -121,20 +119,28 @@ describe("Paragraph", () => {
|
|||||||
paragraph.thematicBreak();
|
paragraph.thematicBreak();
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:p": [{
|
"w:p": [
|
||||||
"w:pPr": [{
|
{
|
||||||
"w:pBdr": [{
|
"w:pPr": [
|
||||||
"w:bottom": [{
|
{
|
||||||
|
"w:pBdr": [
|
||||||
|
{
|
||||||
|
"w:bottom": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
"w:val": "single",
|
"w:val": "single",
|
||||||
"w:color": "auto",
|
"w:color": "auto",
|
||||||
"w:space": "1",
|
"w:space": "1",
|
||||||
"w:sz": "6",
|
"w:sz": "6",
|
||||||
},
|
},
|
||||||
}],
|
},
|
||||||
}],
|
],
|
||||||
}],
|
},
|
||||||
}],
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -144,14 +150,14 @@ describe("Paragraph", () => {
|
|||||||
paragraph.pageBreak();
|
paragraph.pageBreak();
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:p": [{
|
"w:p": [
|
||||||
|
{
|
||||||
"w:pPr": [],
|
"w:pPr": [],
|
||||||
}, {
|
},
|
||||||
"w:r": [
|
{
|
||||||
{"w:rPr": []},
|
"w:r": [{ "w:rPr": [] }, { "w:br": [{ _attr: { "w:type": "page" } }] }],
|
||||||
{"w:br": [{_attr: {"w:type": "page"}}]},
|
},
|
||||||
],
|
],
|
||||||
}],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -160,8 +166,14 @@ describe("Paragraph", () => {
|
|||||||
it("should add list paragraph style to JSON", () => {
|
it("should add list paragraph style to JSON", () => {
|
||||||
paragraph.bullet();
|
paragraph.bullet();
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1);
|
expect(tree)
|
||||||
expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(1);
|
.to.have.property("w:p")
|
||||||
|
.which.is.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
|
expect(tree["w:p"][0])
|
||||||
|
.to.have.property("w:pPr")
|
||||||
|
.which.is.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({
|
expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({
|
||||||
"w:pStyle": [{ _attr: { "w:val": "ListParagraph" } }],
|
"w:pStyle": [{ _attr: { "w:val": "ListParagraph" } }],
|
||||||
});
|
});
|
||||||
@ -170,13 +182,16 @@ describe("Paragraph", () => {
|
|||||||
it("it should add numbered properties", () => {
|
it("it should add numbered properties", () => {
|
||||||
paragraph.bullet();
|
paragraph.bullet();
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1);
|
expect(tree)
|
||||||
expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(2);
|
.to.have.property("w:p")
|
||||||
|
.which.is.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
|
expect(tree["w:p"][0])
|
||||||
|
.to.have.property("w:pPr")
|
||||||
|
.which.is.an("array")
|
||||||
|
.which.has.length.at.least(2);
|
||||||
expect(tree["w:p"][0]["w:pPr"][1]).to.deep.equal({
|
expect(tree["w:p"][0]["w:pPr"][1]).to.deep.equal({
|
||||||
"w:numPr": [
|
"w:numPr": [{ "w:ilvl": [{ _attr: { "w:val": 0 } }] }, { "w:numId": [{ _attr: { "w:val": 1 } }] }],
|
||||||
{"w:ilvl": [{_attr: {"w:val": 0}}]},
|
|
||||||
{"w:numId": [{_attr: {"w:val": 1}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -190,8 +205,14 @@ describe("Paragraph", () => {
|
|||||||
|
|
||||||
paragraph.setNumbering(letterNumbering, 0);
|
paragraph.setNumbering(letterNumbering, 0);
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1);
|
expect(tree)
|
||||||
expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(1);
|
.to.have.property("w:p")
|
||||||
|
.which.is.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
|
expect(tree["w:p"][0])
|
||||||
|
.to.have.property("w:pPr")
|
||||||
|
.which.is.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({
|
expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({
|
||||||
"w:pStyle": [{ _attr: { "w:val": "ListParagraph" } }],
|
"w:pStyle": [{ _attr: { "w:val": "ListParagraph" } }],
|
||||||
});
|
});
|
||||||
@ -230,9 +251,7 @@ describe("Paragraph", () => {
|
|||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:p": [
|
"w:p": [
|
||||||
{
|
{
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:pStyle": [{ _attr: { "w:val": "myFancyStyle" } }] }],
|
||||||
{"w:pStyle": [{_attr: {"w:val": "myFancyStyle"}}]},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -246,9 +265,7 @@ describe("Paragraph", () => {
|
|||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:p": [
|
"w:p": [
|
||||||
{
|
{
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:ind": [{ _attr: { "w:left": 720 } }] }],
|
||||||
{"w:ind": [{_attr: {"w:left": 720}}]},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -262,9 +279,7 @@ describe("Paragraph", () => {
|
|||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:p": [
|
"w:p": [
|
||||||
{
|
{
|
||||||
"w:pPr": [
|
"w:pPr": [{ "w:spacing": [{ _attr: { "w:before": 90, "w:line": 50 } }] }],
|
||||||
{"w:spacing": [{_attr: {"w:before": 90, "w:line": 50}}]},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class ParagraphProperties extends XmlComponent {
|
export class ParagraphProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:pPr");
|
super("w:pPr");
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Break extends XmlComponent {
|
export class Break extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:br");
|
super("w:br");
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class SmallCaps extends XmlComponent {
|
export class SmallCaps extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:smallCaps");
|
super("w:smallCaps");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Caps extends XmlComponent {
|
export class Caps extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:caps");
|
super("w:caps");
|
||||||
}
|
}
|
||||||
|
@ -4,111 +4,122 @@ export { SubScript, SuperScript } from "./script";
|
|||||||
export { RunFonts } from "./run-fonts";
|
export { RunFonts } from "./run-fonts";
|
||||||
|
|
||||||
export class Bold extends XmlComponent {
|
export class Bold extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:b");
|
super("w:b");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Italics extends XmlComponent {
|
export class Italics extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:i");
|
super("w:i");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Caps extends XmlComponent {
|
export class Caps extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:caps");
|
super("w:caps");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Color extends XmlComponent {
|
export class Color extends XmlComponent {
|
||||||
|
|
||||||
constructor(color: string) {
|
constructor(color: string) {
|
||||||
super("w:color");
|
super("w:color");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: color,
|
val: color,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DoubleStrike extends XmlComponent {
|
export class DoubleStrike extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:dstrike");
|
super("w:dstrike");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Emboss extends XmlComponent {
|
export class Emboss extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:emboss");
|
super("w:emboss");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Imprint extends XmlComponent {
|
export class Imprint extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:imprint");
|
super("w:imprint");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Shadow extends XmlComponent {
|
export class Shadow extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:shadow");
|
super("w:shadow");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SmallCaps extends XmlComponent {
|
export class SmallCaps extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:smallCaps");
|
super("w:smallCaps");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Strike extends XmlComponent {
|
export class Strike extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:strike");
|
super("w:strike");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: true,
|
val: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Size extends XmlComponent {
|
export class Size extends XmlComponent {
|
||||||
|
|
||||||
constructor(size: number) {
|
constructor(size: number) {
|
||||||
super("w:sz");
|
super("w:sz");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: size,
|
val: size,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import { IMediaData } from "../../media/data";
|
|||||||
import { Run } from "../run";
|
import { Run } from "../run";
|
||||||
|
|
||||||
export class PictureRun extends Run {
|
export class PictureRun extends Run {
|
||||||
|
|
||||||
constructor(imageData: IMediaData) {
|
constructor(imageData: IMediaData) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class RunProperties extends XmlComponent {
|
export class RunProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:rPr");
|
super("w:rPr");
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,9 @@ describe("Text", () => {
|
|||||||
it("adds the passed in text to the component", () => {
|
it("adds the passed in text to the component", () => {
|
||||||
const t = new Text(" this is\n text");
|
const t = new Text(" this is\n text");
|
||||||
const f = new Formatter().format(t);
|
const f = new Formatter().format(t);
|
||||||
expect(f).to.deep.equal({"w:t": [
|
expect(f).to.deep.equal({
|
||||||
{_attr: {"xml:space": "preserve"}},
|
"w:t": [{ _attr: { "xml:space": "preserve" } }, " this is\n text"],
|
||||||
" this is\n text",
|
});
|
||||||
]});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,6 @@ import { Formatter } from "../../../export/formatter";
|
|||||||
import { RunFonts } from "./run-fonts";
|
import { RunFonts } from "./run-fonts";
|
||||||
|
|
||||||
describe("RunFonts", () => {
|
describe("RunFonts", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("uses the font name for both ascii and hAnsi", () => {
|
it("uses the font name for both ascii and hAnsi", () => {
|
||||||
const tree = new Formatter().format(new RunFonts("Times"));
|
const tree = new Formatter().format(new RunFonts("Times"));
|
||||||
|
@ -15,13 +15,14 @@ class RunFontAttributes extends XmlAttributeComponent<IRunFontAttributesProperti
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class RunFonts extends XmlComponent {
|
export class RunFonts extends XmlComponent {
|
||||||
|
|
||||||
constructor(ascii: string, hint?: string) {
|
constructor(ascii: string, hint?: string) {
|
||||||
super("w:rFonts");
|
super("w:rFonts");
|
||||||
this.root.push(new RunFontAttributes({
|
this.root.push(
|
||||||
|
new RunFontAttributes({
|
||||||
ascii: ascii,
|
ascii: ascii,
|
||||||
hAnsi: ascii,
|
hAnsi: ascii,
|
||||||
hint: hint,
|
hint: hint,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,7 @@ describe("Run", () => {
|
|||||||
run.underline();
|
run.underline();
|
||||||
const tree = new Formatter().format(run);
|
const tree = new Formatter().format(run);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:r": [
|
"w:r": [{ "w:rPr": [{ "w:u": [{ _attr: { "w:val": "single" } }] }] }],
|
||||||
{"w:rPr": [{"w:u": [{_attr: {"w:val": "single"}}]}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,9 +46,7 @@ describe("Run", () => {
|
|||||||
run.underline("double", "990011");
|
run.underline("double", "990011");
|
||||||
const tree = new Formatter().format(run);
|
const tree = new Formatter().format(run);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:r": [
|
"w:r": [{ "w:rPr": [{ "w:u": [{ _attr: { "w:val": "double", "w:color": "990011" } }] }] }],
|
||||||
{"w:rPr": [{"w:u": [{_attr: {"w:val": "double", "w:color": "990011"}}]}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -112,9 +108,7 @@ describe("Run", () => {
|
|||||||
run.font("Times");
|
run.font("Times");
|
||||||
const tree = new Formatter().format(run);
|
const tree = new Formatter().format(run);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:r": [
|
"w:r": [{ "w:rPr": [{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times" } }] }] }],
|
||||||
{"w:rPr": [{"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}]}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -124,9 +118,7 @@ describe("Run", () => {
|
|||||||
run.color("001122");
|
run.color("001122");
|
||||||
const tree = new Formatter().format(run);
|
const tree = new Formatter().format(run);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:r": [
|
"w:r": [{ "w:rPr": [{ "w:color": [{ _attr: { "w:val": "001122" } }] }] }],
|
||||||
{"w:rPr": [{"w:color": [{_attr: {"w:val": "001122"}}]}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -136,9 +128,7 @@ describe("Run", () => {
|
|||||||
run.size(24);
|
run.size(24);
|
||||||
const tree = new Formatter().format(run);
|
const tree = new Formatter().format(run);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:r": [
|
"w:r": [{ "w:rPr": [{ "w:sz": [{ _attr: { "w:val": 24 } }] }] }],
|
||||||
{"w:rPr": [{"w:sz": [{_attr: {"w:val": 24}}]}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -148,9 +138,7 @@ describe("Run", () => {
|
|||||||
run.style("myRunStyle");
|
run.style("myRunStyle");
|
||||||
const tree = new Formatter().format(run);
|
const tree = new Formatter().format(run);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:r": [
|
"w:r": [{ "w:rPr": [{ "w:rStyle": [{ _attr: { "w:val": "myRunStyle" } }] }] }],
|
||||||
{"w:rPr": [{"w:rStyle": [{_attr: {"w:val": "myRunStyle"}}]}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export abstract class VerticalAlign extends XmlComponent {
|
export abstract class VerticalAlign extends XmlComponent {
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super("w:vertAlign");
|
super("w:vertAlign");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: type,
|
val: type,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SuperScript extends VerticalAlign {
|
export class SuperScript extends VerticalAlign {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("superscript");
|
super("superscript");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SubScript extends VerticalAlign {
|
export class SubScript extends VerticalAlign {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("subscript");
|
super("subscript");
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ class StyleAttributes extends XmlAttributeComponent<{val: string}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Style extends XmlComponent {
|
export class Style extends XmlComponent {
|
||||||
|
|
||||||
constructor(styleId: string) {
|
constructor(styleId: string) {
|
||||||
super("w:rStyle");
|
super("w:rStyle");
|
||||||
this.root.push(new StyleAttributes({ val: styleId }));
|
this.root.push(new StyleAttributes({ val: styleId }));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Tab extends XmlComponent {
|
export class Tab extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:tab");
|
super("w:tab");
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,12 @@ describe("TextRun", () => {
|
|||||||
let run: TextRun;
|
let run: TextRun;
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should add text into run", () => {
|
it("should add text into run", () => {
|
||||||
run = new TextRun("test");
|
run = new TextRun("test");
|
||||||
const f = new Formatter().format(run);
|
const f = new Formatter().format(run);
|
||||||
expect(f).to.deep.equal({"w:r": [
|
expect(f).to.deep.equal({
|
||||||
{"w:rPr": []},
|
"w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, "test"] }],
|
||||||
{"w:t": [{_attr: {"xml:space": "preserve"}}, "test"]},
|
});
|
||||||
]});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,6 @@ import { Run } from "../run";
|
|||||||
import { Text } from "./run-components/text";
|
import { Text } from "./run-components/text";
|
||||||
|
|
||||||
export class TextRun extends Run {
|
export class TextRun extends Run {
|
||||||
|
|
||||||
constructor(text: string) {
|
constructor(text: string) {
|
||||||
super();
|
super();
|
||||||
this.root.push(new Text(text));
|
this.root.push(new Text(text));
|
||||||
|
@ -5,9 +5,7 @@ import { Utility } from "../../../tests/utility";
|
|||||||
import * as u from "./underline";
|
import * as u from "./underline";
|
||||||
|
|
||||||
describe("Underline", () => {
|
describe("Underline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should create a new Underline object with u:u as the rootKey", () => {
|
it("should create a new Underline object with u:u as the rootKey", () => {
|
||||||
const underline = new u.Underline();
|
const underline = new u.Underline();
|
||||||
const newJson = Utility.jsonify(underline);
|
const newJson = Utility.jsonify(underline);
|
||||||
@ -33,7 +31,6 @@ describe("Underline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should have u:u as the rootKey", () => {
|
it("should have u:u as the rootKey", () => {
|
||||||
const underline = new u.DashDotDotHeavyUnderline();
|
const underline = new u.DashDotDotHeavyUnderline();
|
||||||
@ -50,7 +47,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DashDotHeavyUnderline();
|
const underline = new u.DashDotHeavyUnderline();
|
||||||
@ -61,7 +57,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DashLongHeavyUnderline();
|
const underline = new u.DashLongHeavyUnderline();
|
||||||
@ -72,7 +67,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DashLongUnderline();
|
const underline = new u.DashLongUnderline();
|
||||||
@ -83,7 +77,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DashUnderline();
|
const underline = new u.DashUnderline();
|
||||||
@ -94,7 +87,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DotDashUnderline();
|
const underline = new u.DotDashUnderline();
|
||||||
@ -105,7 +97,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DotDotDashUnderline();
|
const underline = new u.DotDotDashUnderline();
|
||||||
@ -116,7 +107,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DottedHeavyUnderline();
|
const underline = new u.DottedHeavyUnderline();
|
||||||
@ -127,7 +117,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DottedUnderline();
|
const underline = new u.DottedUnderline();
|
||||||
@ -138,7 +127,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.DoubleUnderline();
|
const underline = new u.DoubleUnderline();
|
||||||
@ -149,7 +137,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.SingleUnderline();
|
const underline = new u.SingleUnderline();
|
||||||
@ -160,7 +147,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.ThickUnderline();
|
const underline = new u.ThickUnderline();
|
||||||
@ -171,7 +157,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.WaveUnderline();
|
const underline = new u.WaveUnderline();
|
||||||
@ -182,7 +167,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.WavyDoubleUnderline();
|
const underline = new u.WavyDoubleUnderline();
|
||||||
@ -193,7 +177,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.WavyHeavyUnderline();
|
const underline = new u.WavyHeavyUnderline();
|
||||||
@ -204,7 +187,6 @@ describe("DashDotDotHeavyUnderline", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("DashDotDotHeavyUnderline", () => {
|
describe("DashDotDotHeavyUnderline", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should put value in attribute", () => {
|
it("should put value in attribute", () => {
|
||||||
const underline = new u.WordsUnderline();
|
const underline = new u.WordsUnderline();
|
||||||
|
@ -1,130 +1,114 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export abstract class BaseUnderline extends XmlComponent {
|
export abstract class BaseUnderline extends XmlComponent {
|
||||||
|
|
||||||
constructor(underlineType: string, color?: string) {
|
constructor(underlineType: string, color?: string) {
|
||||||
super("w:u");
|
super("w:u");
|
||||||
this.root.push(new Attributes({
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
val: underlineType,
|
val: underlineType,
|
||||||
color: color,
|
color: color,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Underline extends BaseUnderline {
|
export class Underline extends BaseUnderline {
|
||||||
|
|
||||||
constructor(underlineType: string = "single", color?: string) {
|
constructor(underlineType: string = "single", color?: string) {
|
||||||
super(underlineType, color);
|
super(underlineType, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DashUnderline extends BaseUnderline {
|
export class DashUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dash");
|
super("dash");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DashDotDotHeavyUnderline extends BaseUnderline {
|
export class DashDotDotHeavyUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dashDotDotHeavy");
|
super("dashDotDotHeavy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DashDotHeavyUnderline extends BaseUnderline {
|
export class DashDotHeavyUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dashDotHeavy");
|
super("dashDotHeavy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DashLongUnderline extends BaseUnderline {
|
export class DashLongUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dashLong");
|
super("dashLong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DashLongHeavyUnderline extends BaseUnderline {
|
export class DashLongHeavyUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dashLongHeavy");
|
super("dashLongHeavy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DotDashUnderline extends BaseUnderline {
|
export class DotDashUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dotDash");
|
super("dotDash");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DotDotDashUnderline extends BaseUnderline {
|
export class DotDotDashUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dotDotDash");
|
super("dotDotDash");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DottedUnderline extends BaseUnderline {
|
export class DottedUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dotted");
|
super("dotted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DottedHeavyUnderline extends BaseUnderline {
|
export class DottedHeavyUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dottedHeavy");
|
super("dottedHeavy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DoubleUnderline extends BaseUnderline {
|
export class DoubleUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("double");
|
super("double");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SingleUnderline extends BaseUnderline {
|
export class SingleUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("single");
|
super("single");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThickUnderline extends BaseUnderline {
|
export class ThickUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("thick");
|
super("thick");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WaveUnderline extends BaseUnderline {
|
export class WaveUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("wave");
|
super("wave");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WavyDoubleUnderline extends BaseUnderline {
|
export class WavyDoubleUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("wavyDouble");
|
super("wavyDouble");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WavyHeavyUnderline extends BaseUnderline {
|
export class WavyHeavyUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("wavyHeavy");
|
super("wavyHeavy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WordsUnderline extends BaseUnderline {
|
export class WordsUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("words");
|
super("words");
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { DocumentAttributes } from "../document/document-attributes";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
|
|
||||||
export class Title extends XmlComponent {
|
export class Title extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("dc:title");
|
super("dc:title");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -10,7 +9,6 @@ export class Title extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Subject extends XmlComponent {
|
export class Subject extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("dc:subject");
|
super("dc:subject");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -18,7 +16,6 @@ export class Subject extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Creator extends XmlComponent {
|
export class Creator extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("dc:creator");
|
super("dc:creator");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -26,7 +23,6 @@ export class Creator extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Keywords extends XmlComponent {
|
export class Keywords extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("cp:keywords");
|
super("cp:keywords");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -34,7 +30,6 @@ export class Keywords extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Description extends XmlComponent {
|
export class Description extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("dc:description");
|
super("dc:description");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -42,7 +37,6 @@ export class Description extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LastModifiedBy extends XmlComponent {
|
export class LastModifiedBy extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("cp:lastModifiedBy");
|
super("cp:lastModifiedBy");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -50,7 +44,6 @@ export class LastModifiedBy extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Revision extends XmlComponent {
|
export class Revision extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("cp:revision");
|
super("cp:revision");
|
||||||
this.root.push(value);
|
this.root.push(value);
|
||||||
@ -72,23 +65,25 @@ export abstract class DateComponent extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Created extends DateComponent {
|
export class Created extends DateComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dcterms:created");
|
super("dcterms:created");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(
|
||||||
|
new DocumentAttributes({
|
||||||
type: "dcterms:W3CDTF",
|
type: "dcterms:W3CDTF",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(this.getCurrentDate());
|
this.root.push(this.getCurrentDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Modified extends DateComponent {
|
export class Modified extends DateComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("dcterms:modified");
|
super("dcterms:modified");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(
|
||||||
|
new DocumentAttributes({
|
||||||
type: "dcterms:W3CDTF",
|
type: "dcterms:W3CDTF",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
this.root.push(this.getCurrentDate());
|
this.root.push(this.getCurrentDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import { Formatter } from "../../export/formatter";
|
|||||||
import { Properties } from "./properties";
|
import { Properties } from "./properties";
|
||||||
|
|
||||||
describe("Properties", () => {
|
describe("Properties", () => {
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("sets the appropriate attributes on the top-level", () => {
|
it("sets the appropriate attributes on the top-level", () => {
|
||||||
const properties = new Properties({});
|
const properties = new Properties({});
|
||||||
@ -28,9 +27,7 @@ describe("Properties", () => {
|
|||||||
expect(Object.keys(tree)).to.deep.equal(["cp:coreProperties"]);
|
expect(Object.keys(tree)).to.deep.equal(["cp:coreProperties"]);
|
||||||
expect(tree["cp:coreProperties"]).to.be.an.instanceof(Array);
|
expect(tree["cp:coreProperties"]).to.be.an.instanceof(Array);
|
||||||
expect(Object.keys(tree["cp:coreProperties"][0])).to.deep.equal(["_attr"]);
|
expect(Object.keys(tree["cp:coreProperties"][0])).to.deep.equal(["_attr"]);
|
||||||
expect(tree["cp:coreProperties"][1]).to.deep.equal(
|
expect(tree["cp:coreProperties"][1]).to.deep.equal({ "dc:title": ["test document"] });
|
||||||
{"dc:title": ["test document"]},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create properties with all the attributes given", () => {
|
it("should create properties with all the attributes given", () => {
|
||||||
@ -60,7 +57,7 @@ describe("Properties", () => {
|
|||||||
"dcterms:created",
|
"dcterms:created",
|
||||||
"dcterms:modified",
|
"dcterms:modified",
|
||||||
]);
|
]);
|
||||||
expect(tree["cp:coreProperties"].slice(1, -2).sort((a, b) => key(a) < key(b) ? -1 : 1)).to.deep.equal([
|
expect(tree["cp:coreProperties"].slice(1, -2).sort((a, b) => (key(a) < key(b) ? -1 : 1))).to.deep.equal([
|
||||||
{ "cp:keywords": ["test docx"] },
|
{ "cp:keywords": ["test docx"] },
|
||||||
{ "cp:lastModifiedBy": ["the author"] },
|
{ "cp:lastModifiedBy": ["the author"] },
|
||||||
{ "cp:revision": ["123"] },
|
{ "cp:revision": ["123"] },
|
||||||
|
@ -13,16 +13,17 @@ export interface IPropertiesOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Properties extends XmlComponent {
|
export class Properties extends XmlComponent {
|
||||||
|
|
||||||
constructor(options: IPropertiesOptions) {
|
constructor(options: IPropertiesOptions) {
|
||||||
super("cp:coreProperties");
|
super("cp:coreProperties");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(
|
||||||
|
new DocumentAttributes({
|
||||||
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
||||||
dc: "http://purl.org/dc/elements/1.1/",
|
dc: "http://purl.org/dc/elements/1.1/",
|
||||||
dcterms: "http://purl.org/dc/terms/",
|
dcterms: "http://purl.org/dc/terms/",
|
||||||
dcmitype: "http://purl.org/dc/dcmitype/",
|
dcmitype: "http://purl.org/dc/dcmitype/",
|
||||||
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
if (options.title) {
|
if (options.title) {
|
||||||
this.root.push(new Title(options.title));
|
this.root.push(new Title(options.title));
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,12 @@ export class Relationship extends XmlComponent {
|
|||||||
constructor(id: string, type: RelationshipType, target: string) {
|
constructor(id: string, type: RelationshipType, target: string) {
|
||||||
super("Relationship");
|
super("Relationship");
|
||||||
|
|
||||||
this.root.push(new RelationshipAttributes({
|
this.root.push(
|
||||||
|
new RelationshipAttributes({
|
||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
target,
|
target,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,13 @@ import { RelationshipsAttributes } from "./attributes";
|
|||||||
import { Relationship, RelationshipType } from "./relationship/relationship";
|
import { Relationship, RelationshipType } from "./relationship/relationship";
|
||||||
|
|
||||||
export class Relationships extends XmlComponent {
|
export class Relationships extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Relationships");
|
super("Relationships");
|
||||||
this.root.push(new RelationshipsAttributes({
|
this.root.push(
|
||||||
|
new RelationshipsAttributes({
|
||||||
xmlns: "http://schemas.openxmlformats.org/package/2006/relationships",
|
xmlns: "http://schemas.openxmlformats.org/package/2006/relationships",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.createRelationship(1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", "styles.xml");
|
this.createRelationship(1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", "styles.xml");
|
||||||
this.createRelationship(2, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", "numbering.xml");
|
this.createRelationship(2, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", "numbering.xml");
|
||||||
|
@ -3,7 +3,6 @@ import { ParagraphPropertiesDefaults } from "./paragraph-properties";
|
|||||||
import { RunPropertiesDefaults } from "./run-properties";
|
import { RunPropertiesDefaults } from "./run-properties";
|
||||||
|
|
||||||
export class DocumentDefaults extends XmlComponent {
|
export class DocumentDefaults extends XmlComponent {
|
||||||
|
|
||||||
private runPropertiesDefaults: RunPropertiesDefaults;
|
private runPropertiesDefaults: RunPropertiesDefaults;
|
||||||
private paragraphPropertiesDefaults: ParagraphPropertiesDefaults;
|
private paragraphPropertiesDefaults: ParagraphPropertiesDefaults;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { ParagraphProperties } from "../../paragraph/properties";
|
import { ParagraphProperties } from "../../paragraph/properties";
|
||||||
|
|
||||||
export class ParagraphPropertiesDefaults extends XmlComponent {
|
export class ParagraphPropertiesDefaults extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:pPrDefault");
|
super("w:pPrDefault");
|
||||||
this.root.push(new ParagraphProperties());
|
this.root.push(new ParagraphProperties());
|
||||||
|
@ -3,12 +3,17 @@ import { Color, Italics, Size } from "../paragraph/run/formatting";
|
|||||||
import { Styles } from "./";
|
import { Styles } from "./";
|
||||||
// import { DocumentDefaults } from "./defaults";
|
// import { DocumentDefaults } from "./defaults";
|
||||||
import {
|
import {
|
||||||
Heading1Style, Heading2Style, Heading3Style, Heading4Style, Heading5Style, Heading6Style,
|
Heading1Style,
|
||||||
ListParagraph, TitleStyle,
|
Heading2Style,
|
||||||
|
Heading3Style,
|
||||||
|
Heading4Style,
|
||||||
|
Heading5Style,
|
||||||
|
Heading6Style,
|
||||||
|
ListParagraph,
|
||||||
|
TitleStyle,
|
||||||
} from "./style";
|
} from "./style";
|
||||||
|
|
||||||
export class DefaultStylesFactory {
|
export class DefaultStylesFactory {
|
||||||
|
|
||||||
public newInstance(): Styles {
|
public newInstance(): Styles {
|
||||||
const styles = new Styles();
|
const styles = new Styles();
|
||||||
styles.createDocumentDefaults();
|
styles.createDocumentDefaults();
|
||||||
|
@ -4,18 +4,18 @@ import { DocumentDefaults } from "./defaults";
|
|||||||
import { ParagraphStyle } from "./style";
|
import { ParagraphStyle } from "./style";
|
||||||
|
|
||||||
export class Styles extends XmlComponent {
|
export class Styles extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:styles");
|
super("w:styles");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(
|
||||||
|
new DocumentAttributes({
|
||||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||||
Ignorable: "w14 w15",
|
Ignorable: "w14 w15",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public push(style: XmlComponent): Styles {
|
public push(style: XmlComponent): Styles {
|
||||||
|
@ -19,7 +19,6 @@ export class LatentStyleExceptionAttributes extends XmlAttributeComponent<ILaten
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LatentStyleException extends XmlComponent {
|
export class LatentStyleException extends XmlComponent {
|
||||||
|
|
||||||
constructor(attributes: ILatentStyleExceptionAttributesProperties) {
|
constructor(attributes: ILatentStyleExceptionAttributesProperties) {
|
||||||
super("w:lsdException");
|
super("w:lsdException");
|
||||||
this.root.push(new LatentStyleExceptionAttributes(attributes));
|
this.root.push(new LatentStyleExceptionAttributes(attributes));
|
||||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
|||||||
import { LatentStyleException } from "./exceptions";
|
import { LatentStyleException } from "./exceptions";
|
||||||
|
|
||||||
export class LatentStyles extends XmlComponent {
|
export class LatentStyles extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:latentStyles");
|
super("w:latentStyles");
|
||||||
}
|
}
|
||||||
|
@ -1,149 +1,211 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
|
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
return [{
|
return [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:name': name,
|
"w:name": name,
|
||||||
'w:uiPriority': uiPriority,
|
"w:uiPriority": uiPriority,
|
||||||
'w:qFormat': qFormat,
|
"w:qFormat": qFormat,
|
||||||
'w:semiHidden': semiHidden,
|
"w:semiHidden": semiHidden,
|
||||||
'w:unhideWhenUsed': unhideWhenUsed
|
"w:unhideWhenUsed": unhideWhenUsed,
|
||||||
}
|
},
|
||||||
}];
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DefaultStyle() {
|
export function DefaultStyle() {
|
||||||
var style = {
|
var style = {
|
||||||
'w:styles': [{
|
"w:styles": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||||
'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||||
'xmlns:w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||||
'xmlns:w14': 'http://schemas.microsoft.com/office/word/2010/wordml',
|
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||||
'xmlns:w15': 'http://schemas.microsoft.com/office/word/2012/wordml',
|
"xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||||
'mc:Ignorable': 'w14 w15'
|
"mc:Ignorable": "w14 w15",
|
||||||
}
|
},
|
||||||
}, {
|
},
|
||||||
'w:docDefaults': [{
|
{
|
||||||
'w:rPrDefault': [{
|
"w:docDefaults": [
|
||||||
'w:rPr': [{
|
{
|
||||||
'w:rFonts': [{
|
"w:rPrDefault": [
|
||||||
|
{
|
||||||
|
"w:rPr": [
|
||||||
|
{
|
||||||
|
"w:rFonts": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:asciiTheme': "minorHAnsi",
|
"w:asciiTheme": "minorHAnsi",
|
||||||
'w:eastAsiaTheme': "minorHAnsi",
|
"w:eastAsiaTheme": "minorHAnsi",
|
||||||
'w:hAnsiTheme': "minorHAnsi",
|
"w:hAnsiTheme": "minorHAnsi",
|
||||||
'w:cstheme': "minorBidi"
|
"w:cstheme": "minorBidi",
|
||||||
}
|
},
|
||||||
}]
|
},
|
||||||
}, {
|
],
|
||||||
'w:sz': [{
|
},
|
||||||
|
{
|
||||||
|
"w:sz": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:val': "22"
|
"w:val": "22",
|
||||||
}
|
},
|
||||||
}]
|
},
|
||||||
}, {
|
],
|
||||||
'w:szCs': [{
|
},
|
||||||
|
{
|
||||||
|
"w:szCs": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:val': "22"
|
"w:val": "22",
|
||||||
}
|
},
|
||||||
}]
|
},
|
||||||
}, {
|
],
|
||||||
'w:lang': [{
|
},
|
||||||
|
{
|
||||||
|
"w:lang": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:val': "en-GB",
|
"w:val": "en-GB",
|
||||||
'w:eastAsia': "en-US",
|
"w:eastAsia": "en-US",
|
||||||
'w:bidi': "ar-SA"
|
"w:bidi": "ar-SA",
|
||||||
}
|
},
|
||||||
}]
|
},
|
||||||
}]
|
],
|
||||||
}]
|
},
|
||||||
}, {
|
],
|
||||||
'w:pPrDefault': [{
|
},
|
||||||
'w:pPr': [{
|
],
|
||||||
'w:spacing': [{
|
},
|
||||||
|
{
|
||||||
|
"w:pPrDefault": [
|
||||||
|
{
|
||||||
|
"w:pPr": [
|
||||||
|
{
|
||||||
|
"w:spacing": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:after': "160",
|
"w:after": "160",
|
||||||
'w:line': "259",
|
"w:line": "259",
|
||||||
'w:lineRule': "auto"
|
"w:lineRule": "auto",
|
||||||
}
|
},
|
||||||
}]
|
},
|
||||||
}]
|
],
|
||||||
}]
|
},
|
||||||
}]
|
],
|
||||||
}, {
|
},
|
||||||
'w:latentStyles': [{
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:latentStyles": [
|
||||||
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
'w:defLockedState': "0",
|
"w:defLockedState": "0",
|
||||||
'w:defUIPriority': "99",
|
"w:defUIPriority": "99",
|
||||||
'w:defSemiHidden': "0",
|
"w:defSemiHidden": "0",
|
||||||
'w:defUnhideWhenUsed': "0",
|
"w:defUnhideWhenUsed": "0",
|
||||||
'w:defQFormat': "0",
|
"w:defQFormat": "0",
|
||||||
'w:count': "371"
|
"w:count": "371",
|
||||||
}
|
},
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException('Normal', 0, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("Normal", 0, 1),
|
||||||
'w:lsdException': createLsdException("heading 1", 9, 1, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("heading 2", 9, 1, 1, 1)
|
"w:lsdException": createLsdException("heading 1", 9, 1, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("heading 3", 9, 1, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("heading 2", 9, 1, 1, 1),
|
||||||
'w:lsdException': createLsdException("heading 4", 9, 1, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("heading 5", 9, 1, 1, 1)
|
"w:lsdException": createLsdException("heading 3", 9, 1, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("heading 6", 9, 1, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("heading 4", 9, 1, 1, 1),
|
||||||
'w:lsdException': createLsdException("heading 7", 9, 1, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("heading 8", 9, 1, 1, 1)
|
"w:lsdException": createLsdException("heading 5", 9, 1, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("heading 9", 9, 1, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("heading 6", 9, 1, 1, 1),
|
||||||
'w:lsdException': createLsdException("index 1", undefined, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("index 2", undefined, undefined, 1, 1)
|
"w:lsdException": createLsdException("heading 7", 9, 1, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("index 3", undefined, undefined, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("heading 8", 9, 1, 1, 1),
|
||||||
'w:lsdException': createLsdException("index 4", undefined, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("index 5", undefined, undefined, 1, 1)
|
"w:lsdException": createLsdException("heading 9", 9, 1, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("index 6", undefined, undefined, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("index 1", undefined, undefined, 1, 1),
|
||||||
'w:lsdException': createLsdException("index 7", undefined, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("index 8", undefined, undefined, 1, 1)
|
"w:lsdException": createLsdException("index 2", undefined, undefined, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("index 9", undefined, undefined, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("index 3", undefined, undefined, 1, 1),
|
||||||
'w:lsdException': createLsdException("toc 1", 39, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("toc 2", 39, undefined, 1, 1)
|
"w:lsdException": createLsdException("index 4", undefined, undefined, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("toc 3", 39, undefined, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("index 5", undefined, undefined, 1, 1),
|
||||||
'w:lsdException': createLsdException("toc 4", 39, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("toc 5", 39, undefined, 1, 1)
|
"w:lsdException": createLsdException("index 6", undefined, undefined, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("toc 6", 39, undefined, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("index 7", undefined, undefined, 1, 1),
|
||||||
'w:lsdException': createLsdException("toc 7", 39, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("toc 8", 39, undefined, 1, 1)
|
"w:lsdException": createLsdException("index 8", undefined, undefined, 1, 1),
|
||||||
}, {
|
},
|
||||||
'w:lsdException': createLsdException("toc 9", 39, undefined, 1, 1)
|
{
|
||||||
}, {
|
"w:lsdException": createLsdException("index 9", undefined, undefined, 1, 1),
|
||||||
'w:lsdException': createLsdException("Normal Indent", undefined, undefined, 1, 1)
|
},
|
||||||
}, {
|
{
|
||||||
'w:lsdException': createLsdException("footnote text", undefined, undefined, 1, 1)
|
"w:lsdException": createLsdException("toc 1", 39, undefined, 1, 1),
|
||||||
}]
|
},
|
||||||
}]
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 2", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 3", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 4", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 5", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 6", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 7", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 8", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("toc 9", 39, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("Normal Indent", undefined, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:lsdException": createLsdException("footnote text", undefined, undefined, 1, 1),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
};
|
}
|
||||||
|
@ -9,7 +9,6 @@ class ComponentAttributes extends XmlAttributeComponent<IComponentAttributes> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Name extends XmlComponent {
|
export class Name extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:name");
|
super("w:name");
|
||||||
this.root.push(new ComponentAttributes({ val: value }));
|
this.root.push(new ComponentAttributes({ val: value }));
|
||||||
@ -17,7 +16,6 @@ export class Name extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class BasedOn extends XmlComponent {
|
export class BasedOn extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:basedOn");
|
super("w:basedOn");
|
||||||
this.root.push(new ComponentAttributes({ val: value }));
|
this.root.push(new ComponentAttributes({ val: value }));
|
||||||
@ -25,7 +23,6 @@ export class BasedOn extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Next extends XmlComponent {
|
export class Next extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:next");
|
super("w:next");
|
||||||
this.root.push(new ComponentAttributes({ val: value }));
|
this.root.push(new ComponentAttributes({ val: value }));
|
||||||
@ -33,7 +30,6 @@ export class Next extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Link extends XmlComponent {
|
export class Link extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:link");
|
super("w:link");
|
||||||
this.root.push(new ComponentAttributes({ val: value }));
|
this.root.push(new ComponentAttributes({ val: value }));
|
||||||
@ -41,7 +37,6 @@ export class Link extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class UiPriority extends XmlComponent {
|
export class UiPriority extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:uiPriority");
|
super("w:uiPriority");
|
||||||
// TODO: this value should be a ST_DecimalNumber
|
// TODO: this value should be a ST_DecimalNumber
|
||||||
@ -49,25 +44,16 @@ export class UiPriority extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UnhideWhenUsed extends XmlComponent {
|
export class UnhideWhenUsed extends XmlComponent {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class QuickFormat extends XmlComponent {
|
export class QuickFormat extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:qFormat");
|
super("w:qFormat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TableProperties extends XmlComponent {
|
export class TableProperties extends XmlComponent {}
|
||||||
|
|
||||||
}
|
export class RsId extends XmlComponent {}
|
||||||
|
|
||||||
export class RsId extends XmlComponent {
|
export class SemiHidden extends XmlComponent {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SemiHidden extends XmlComponent {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -22,7 +22,6 @@ class StyleAttributes extends XmlAttributeComponent<IStyleAttributes> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Style extends XmlComponent {
|
export class Style extends XmlComponent {
|
||||||
|
|
||||||
constructor(attributes: IStyleAttributes, name?: string) {
|
constructor(attributes: IStyleAttributes, name?: string) {
|
||||||
super("w:style");
|
super("w:style");
|
||||||
this.root.push(new StyleAttributes(attributes));
|
this.root.push(new StyleAttributes(attributes));
|
||||||
@ -37,7 +36,6 @@ export class Style extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ParagraphStyle extends Style {
|
export class ParagraphStyle extends Style {
|
||||||
|
|
||||||
private paragraphProperties: paragraph.ParagraphProperties;
|
private paragraphProperties: paragraph.ParagraphProperties;
|
||||||
private runProperties: RunProperties;
|
private runProperties: RunProperties;
|
||||||
|
|
||||||
@ -193,7 +191,6 @@ export class ParagraphStyle extends Style {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class HeadingStyle extends ParagraphStyle {
|
export class HeadingStyle extends ParagraphStyle {
|
||||||
|
|
||||||
constructor(styleId: string, name: string) {
|
constructor(styleId: string, name: string) {
|
||||||
super(styleId, name);
|
super(styleId, name);
|
||||||
this.basedOn("Normal");
|
this.basedOn("Normal");
|
||||||
@ -203,56 +200,48 @@ export class HeadingStyle extends ParagraphStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TitleStyle extends HeadingStyle {
|
export class TitleStyle extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Title", "Title");
|
super("Title", "Title");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Heading1Style extends HeadingStyle {
|
export class Heading1Style extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Heading1", "Heading 1");
|
super("Heading1", "Heading 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Heading2Style extends HeadingStyle {
|
export class Heading2Style extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Heading2", "Heading 2");
|
super("Heading2", "Heading 2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Heading3Style extends HeadingStyle {
|
export class Heading3Style extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Heading3", "Heading 3");
|
super("Heading3", "Heading 3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Heading4Style extends HeadingStyle {
|
export class Heading4Style extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Heading4", "Heading 4");
|
super("Heading4", "Heading 4");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Heading5Style extends HeadingStyle {
|
export class Heading5Style extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Heading5", "Heading 5");
|
super("Heading5", "Heading 5");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Heading6Style extends HeadingStyle {
|
export class Heading6Style extends HeadingStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Heading6", "Heading 6");
|
super("Heading6", "Heading 6");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ListParagraph extends ParagraphStyle {
|
export class ListParagraph extends ParagraphStyle {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("ListParagraph");
|
super("ListParagraph");
|
||||||
this.root.push(new Name("List Paragraph"));
|
this.root.push(new Name("List Paragraph"));
|
||||||
|
@ -22,26 +22,26 @@ describe("Styles", () => {
|
|||||||
it("should create a new paragraph style and push it onto this collection", () => {
|
it("should create a new paragraph style and push it onto this collection", () => {
|
||||||
styles.createParagraphStyle("pStyleId");
|
styles.createParagraphStyle("pStyleId");
|
||||||
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
||||||
expect(tree).to.deep.equal([{
|
expect(tree).to.deep.equal([
|
||||||
"w:style": [
|
{
|
||||||
{_attr: {"w:type": "paragraph", "w:styleId": "pStyleId"}},
|
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||||
{"w:pPr": []},
|
},
|
||||||
{"w:rPr": []},
|
]);
|
||||||
],
|
|
||||||
}]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the paragraph name if given", () => {
|
it("should set the paragraph name if given", () => {
|
||||||
styles.createParagraphStyle("pStyleId", "Paragraph Style");
|
styles.createParagraphStyle("pStyleId", "Paragraph Style");
|
||||||
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
||||||
expect(tree).to.deep.equal([{
|
expect(tree).to.deep.equal([
|
||||||
|
{
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } },
|
||||||
{ "w:name": [{ _attr: { "w:val": "Paragraph Style" } }] },
|
{ "w:name": [{ _attr: { "w:val": "Paragraph Style" } }] },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
}]);
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -56,17 +56,18 @@ describe("Style", () => {
|
|||||||
});
|
});
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true } }],
|
||||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true}},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the name of the style, if given", () => {
|
it("should set the name of the style, if given", () => {
|
||||||
const style = new Style({
|
const style = new Style(
|
||||||
|
{
|
||||||
type: "paragraph",
|
type: "paragraph",
|
||||||
styleId: "myStyleId",
|
styleId: "myStyleId",
|
||||||
}, "Style Name");
|
},
|
||||||
|
"Style Name",
|
||||||
|
);
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -116,11 +117,7 @@ describe("ParagraphStyle", () => {
|
|||||||
const style = new ParagraphStyle("myStyleId");
|
const style = new ParagraphStyle("myStyleId");
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
|
||||||
{"w:pPr": []},
|
|
||||||
{"w:rPr": []},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -140,8 +137,7 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("formatting methods: style attributes", () => {
|
describe("formatting methods: style attributes", () => {
|
||||||
it("#basedOn", () => {
|
it("#basedOn", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").basedOn("otherId");
|
||||||
.basedOn("otherId");
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -154,8 +150,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#quickFormat", () => {
|
it("#quickFormat", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").quickFormat();
|
||||||
.quickFormat();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -168,8 +163,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#next", () => {
|
it("#next", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").next("otherId");
|
||||||
.next("otherId");
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -184,152 +178,158 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("formatting methods: paragraph properties", () => {
|
describe("formatting methods: paragraph properties", () => {
|
||||||
it("#indent", () => {
|
it("#indent", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").indent({ left: 720 });
|
||||||
.indent({ left: 720 });
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:ind": [{_attr: {"w:left": 720}}]},
|
"w:pPr": [{ "w:ind": [{ _attr: { "w:left": 720 } }] }],
|
||||||
]},
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#spacing", () => {
|
it("#spacing", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").spacing({ before: 50, after: 150 });
|
||||||
.spacing({before: 50, after: 150});
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:spacing": [{_attr: {"w:before": 50, "w:after": 150}}]},
|
"w:pPr": [{ "w:spacing": [{ _attr: { "w:before": 50, "w:after": 150 } }] }],
|
||||||
]},
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#center", () => {
|
it("#center", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").center();
|
||||||
.center();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:jc": [{_attr: {"w:val": "center"}}]},
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "center" } }] }],
|
||||||
]},
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#left", () => {
|
it("#left", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").left();
|
||||||
.left();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:jc": [{_attr: {"w:val": "left"}}]},
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "left" } }] }],
|
||||||
]},
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#right", () => {
|
it("#right", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").right();
|
||||||
.right();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:jc": [{_attr: {"w:val": "right"}}]},
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "right" } }] }],
|
||||||
]},
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#justified", () => {
|
it("#justified", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").justified();
|
||||||
.justified();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:jc": [{_attr: {"w:val": "both"}}]},
|
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "both" } }] }],
|
||||||
]},
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#thematicBreak", () => {
|
it("#thematicBreak", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").thematicBreak();
|
||||||
.thematicBreak();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:pBdr": [{"w:bottom": [{_attr: {
|
"w:pPr": [
|
||||||
|
{
|
||||||
|
"w:pBdr": [
|
||||||
|
{
|
||||||
|
"w:bottom": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
"w:color": "auto",
|
"w:color": "auto",
|
||||||
"w:space": "1",
|
"w:space": "1",
|
||||||
"w:val": "single",
|
"w:val": "single",
|
||||||
"w:sz": "6",
|
"w:sz": "6",
|
||||||
}}]}]},
|
},
|
||||||
]},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#leftTabStop", () => {
|
it("#leftTabStop", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").leftTabStop(1200);
|
||||||
.leftTabStop(1200);
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:tabs": [
|
"w:pPr": [
|
||||||
{"w:tab": [{_attr: {"w:val": "left", "w:pos": 1200}}]},
|
{
|
||||||
]},
|
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "left", "w:pos": 1200 } }] }],
|
||||||
]},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#maxRightTabStop", () => {
|
it("#maxRightTabStop", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").maxRightTabStop();
|
||||||
.maxRightTabStop();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{"w:pPr": [
|
{
|
||||||
{"w:tabs": [
|
"w:pPr": [
|
||||||
{"w:tab": [{_attr: {"w:val": "right", "w:pos": 9026}}]},
|
{
|
||||||
]},
|
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "right", "w:pos": 9026 } }] }],
|
||||||
]},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{ "w:rPr": [] },
|
{ "w:rPr": [] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#keepLines", () => {
|
it("#keepLines", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").keepLines();
|
||||||
.keepLines();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -341,8 +341,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#keepNext", () => {
|
it("#keepNext", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").keepNext();
|
||||||
.keepNext();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -356,113 +355,105 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("formatting methods: run properties", () => {
|
describe("formatting methods: run properties", () => {
|
||||||
it("#size", () => {
|
it("#size", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").size(24);
|
||||||
.size(24);
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:sz": [{_attr: {"w:val": 24}}]},
|
"w:rPr": [{ "w:sz": [{ _attr: { "w:val": 24 } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#smallCaps", () => {
|
it("#smallCaps", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").smallCaps();
|
||||||
.smallCaps();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:smallCaps": [{_attr: {"w:val": true}}]},
|
"w:rPr": [{ "w:smallCaps": [{ _attr: { "w:val": true } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#allCaps", () => {
|
it("#allCaps", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").allCaps();
|
||||||
.allCaps();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:caps": [{_attr: {"w:val": true}}]},
|
"w:rPr": [{ "w:caps": [{ _attr: { "w:val": true } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#strike", () => {
|
it("#strike", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").strike();
|
||||||
.strike();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:strike": [{_attr: {"w:val": true}}]},
|
"w:rPr": [{ "w:strike": [{ _attr: { "w:val": true } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#doubleStrike", () => {
|
it("#doubleStrike", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").doubleStrike();
|
||||||
.doubleStrike();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:dstrike": [{_attr: {"w:val": true}}]},
|
"w:rPr": [{ "w:dstrike": [{ _attr: { "w:val": true } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#subScript", () => {
|
it("#subScript", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").subScript();
|
||||||
.subScript();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:vertAlign": [{_attr: {"w:val": "subscript"}}]},
|
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "subscript" } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#superScript", () => {
|
it("#superScript", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").superScript();
|
||||||
.superScript();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:vertAlign": [{_attr: {"w:val": "superscript"}}]},
|
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "superscript" } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#font", () => {
|
it("#font", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").font("Times");
|
||||||
.font("Times");
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -474,93 +465,87 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#bold", () => {
|
it("#bold", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").bold();
|
||||||
.bold();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:b": [{_attr: {"w:val": true}}]},
|
"w:rPr": [{ "w:b": [{ _attr: { "w:val": true } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#italics", () => {
|
it("#italics", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").italics();
|
||||||
.italics();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:i": [{_attr: {"w:val": true}}]},
|
"w:rPr": [{ "w:i": [{ _attr: { "w:val": true } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#underline", () => {
|
describe("#underline", () => {
|
||||||
it("should set underline to 'single' if no arguments are given", () => {
|
it("should set underline to 'single' if no arguments are given", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").underline();
|
||||||
.underline();
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:u": [{_attr: {"w:val": "single"}}]},
|
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "single" } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style if given", () => {
|
it("should set the style if given", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").underline("double");
|
||||||
.underline("double");
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:u": [{_attr: {"w:val": "double"}}]},
|
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double" } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style and color if given", () => {
|
it("should set the style and color if given", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").underline("double", "005599");
|
||||||
.underline("double", "005599");
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:u": [{_attr: {"w:val": "double", "w:color": "005599"}}]},
|
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double", "w:color": "005599" } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId").color("123456");
|
||||||
.color("123456");
|
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:rPr": [
|
{
|
||||||
{"w:color": [{_attr: {"w:val": "123456"}}]},
|
"w:rPr": [{ "w:color": [{ _attr: { "w:val": "123456" } }] }],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -17,9 +17,7 @@ describe("TableProperties", () => {
|
|||||||
const tp = new TableProperties().setWidth("dxa", 1234);
|
const tp = new TableProperties().setWidth("dxa", 1234);
|
||||||
const tree = new Formatter().format(tp);
|
const tree = new Formatter().format(tp);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:tblPr": [
|
"w:tblPr": [{ "w:tblW": [{ _attr: { "w:type": "dxa", "w:w": 1234 } }] }],
|
||||||
{"w:tblW": [{_attr: {"w:type": "dxa", "w:w": 1234}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -29,9 +27,7 @@ describe("TableProperties", () => {
|
|||||||
const tp = new TableProperties().fixedWidthLayout();
|
const tp = new TableProperties().fixedWidthLayout();
|
||||||
const tree = new Formatter().format(tp);
|
const tree = new Formatter().format(tp);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:tblPr": [
|
"w:tblPr": [{ "w:tblLayout": [{ _attr: { "w:type": "fixed" } }] }],
|
||||||
{"w:tblLayout": [{_attr: {"w:type": "fixed"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,10 +14,9 @@ describe("Table", () => {
|
|||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:tbl": [
|
"w:tbl": [
|
||||||
{ "w:tblPr": [] },
|
{ "w:tblPr": [] },
|
||||||
{"w:tblGrid": [
|
{
|
||||||
{"w:gridCol": [{_attr: {"w:w": 1}}]},
|
"w:tblGrid": [{ "w:gridCol": [{ _attr: { "w:w": 1 } }] }, { "w:gridCol": [{ _attr: { "w:w": 1 } }] }],
|
||||||
{"w:gridCol": [{_attr: {"w:w": 1}}]},
|
},
|
||||||
]},
|
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell, cell] },
|
{ "w:tr": [{ "w:trPr": [] }, cell, cell] },
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell, cell] },
|
{ "w:tr": [{ "w:trPr": [] }, cell, cell] },
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell, cell] },
|
{ "w:tr": [{ "w:trPr": [] }, cell, cell] },
|
||||||
@ -29,25 +28,37 @@ describe("Table", () => {
|
|||||||
describe("#getRow and Row#getCell", () => {
|
describe("#getRow and Row#getCell", () => {
|
||||||
it("returns the correct row", () => {
|
it("returns the correct row", () => {
|
||||||
const table = new Table(2, 2);
|
const table = new Table(2, 2);
|
||||||
table.getRow(0).getCell(0).addContent(new Paragraph("A1"));
|
table
|
||||||
table.getRow(0).getCell(1).addContent(new Paragraph("B1"));
|
.getRow(0)
|
||||||
table.getRow(1).getCell(0).addContent(new Paragraph("A2"));
|
.getCell(0)
|
||||||
table.getRow(1).getCell(1).addContent(new Paragraph("B2"));
|
.addContent(new Paragraph("A1"));
|
||||||
|
table
|
||||||
|
.getRow(0)
|
||||||
|
.getCell(1)
|
||||||
|
.addContent(new Paragraph("B1"));
|
||||||
|
table
|
||||||
|
.getRow(1)
|
||||||
|
.getCell(0)
|
||||||
|
.addContent(new Paragraph("A2"));
|
||||||
|
table
|
||||||
|
.getRow(1)
|
||||||
|
.getCell(1)
|
||||||
|
.addContent(new Paragraph("B2"));
|
||||||
const tree = new Formatter().format(table);
|
const tree = new Formatter().format(table);
|
||||||
const cell = (c) => ({"w:tc": [
|
const cell = (c) => ({
|
||||||
|
"w:tc": [
|
||||||
{ "w:tcPr": [] },
|
{ "w:tcPr": [] },
|
||||||
{"w:p": [
|
{
|
||||||
{"w:pPr": []},
|
"w:p": [{ "w:pPr": [] }, { "w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, c] }] }],
|
||||||
{"w:r": [{"w:rPr": []}, {"w:t": [{_attr: {"xml:space": "preserve"}}, c]}]},
|
},
|
||||||
]},
|
],
|
||||||
]});
|
});
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:tbl": [
|
"w:tbl": [
|
||||||
{ "w:tblPr": [] },
|
{ "w:tblPr": [] },
|
||||||
{"w:tblGrid": [
|
{
|
||||||
{"w:gridCol": [{_attr: {"w:w": 1}}]},
|
"w:tblGrid": [{ "w:gridCol": [{ _attr: { "w:w": 1 } }] }, { "w:gridCol": [{ _attr: { "w:w": 1 } }] }],
|
||||||
{"w:gridCol": [{_attr: {"w:w": 1}}]},
|
},
|
||||||
]},
|
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell("A1"), cell("B1")] },
|
{ "w:tr": [{ "w:trPr": [] }, cell("A1"), cell("B1")] },
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell("A2"), cell("B2")] },
|
{ "w:tr": [{ "w:trPr": [] }, cell("A2"), cell("B2")] },
|
||||||
],
|
],
|
||||||
@ -63,20 +74,20 @@ describe("Table", () => {
|
|||||||
table.getCell(1, 0).addContent(new Paragraph("A2"));
|
table.getCell(1, 0).addContent(new Paragraph("A2"));
|
||||||
table.getCell(1, 1).addContent(new Paragraph("B2"));
|
table.getCell(1, 1).addContent(new Paragraph("B2"));
|
||||||
const tree = new Formatter().format(table);
|
const tree = new Formatter().format(table);
|
||||||
const cell = (c) => ({"w:tc": [
|
const cell = (c) => ({
|
||||||
|
"w:tc": [
|
||||||
{ "w:tcPr": [] },
|
{ "w:tcPr": [] },
|
||||||
{"w:p": [
|
{
|
||||||
{"w:pPr": []},
|
"w:p": [{ "w:pPr": [] }, { "w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, c] }] }],
|
||||||
{"w:r": [{"w:rPr": []}, {"w:t": [{_attr: {"xml:space": "preserve"}}, c]}]},
|
},
|
||||||
]},
|
],
|
||||||
]});
|
});
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:tbl": [
|
"w:tbl": [
|
||||||
{ "w:tblPr": [] },
|
{ "w:tblPr": [] },
|
||||||
{"w:tblGrid": [
|
{
|
||||||
{"w:gridCol": [{_attr: {"w:w": 1}}]},
|
"w:tblGrid": [{ "w:gridCol": [{ _attr: { "w:w": 1 } }] }, { "w:gridCol": [{ _attr: { "w:w": 1 } }] }],
|
||||||
{"w:gridCol": [{_attr: {"w:w": 1}}]},
|
},
|
||||||
]},
|
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell("A1"), cell("B1")] },
|
{ "w:tr": [{ "w:trPr": [] }, cell("A1"), cell("B1")] },
|
||||||
{ "w:tr": [{ "w:trPr": [] }, cell("A2"), cell("B2")] },
|
{ "w:tr": [{ "w:trPr": [] }, cell("A2"), cell("B2")] },
|
||||||
],
|
],
|
||||||
@ -88,11 +99,12 @@ describe("Table", () => {
|
|||||||
it("sets the preferred width on the table", () => {
|
it("sets the preferred width on the table", () => {
|
||||||
const table = new Table(2, 2).setWidth("pct", 1000);
|
const table = new Table(2, 2).setWidth("pct", 1000);
|
||||||
const tree = new Formatter().format(table);
|
const tree = new Formatter().format(table);
|
||||||
expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1);
|
expect(tree)
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.is.an("array")
|
||||||
|
.with.has.length.at.least(1);
|
||||||
expect(tree["w:tbl"][0]).to.deep.equal({
|
expect(tree["w:tbl"][0]).to.deep.equal({
|
||||||
"w:tblPr": [
|
"w:tblPr": [{ "w:tblW": [{ _attr: { "w:type": "pct", "w:w": 1000 } }] }],
|
||||||
{"w:tblW": [{_attr: {"w:type": "pct", "w:w": 1000}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -101,11 +113,12 @@ describe("Table", () => {
|
|||||||
it("sets the table to fixed width layout", () => {
|
it("sets the table to fixed width layout", () => {
|
||||||
const table = new Table(2, 2).fixedWidthLayout();
|
const table = new Table(2, 2).fixedWidthLayout();
|
||||||
const tree = new Formatter().format(table);
|
const tree = new Formatter().format(table);
|
||||||
expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1);
|
expect(tree)
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.is.an("array")
|
||||||
|
.with.has.length.at.least(1);
|
||||||
expect(tree["w:tbl"][0]).to.deep.equal({
|
expect(tree["w:tbl"][0]).to.deep.equal({
|
||||||
"w:tblPr": [
|
"w:tblPr": [{ "w:tblLayout": [{ _attr: { "w:type": "fixed" } }] }],
|
||||||
{"w:tblLayout": [{_attr: {"w:type": "fixed"}}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -115,15 +128,16 @@ describe("Table", () => {
|
|||||||
it("inserts a paragraph at the end of the cell if it is empty", () => {
|
it("inserts a paragraph at the end of the cell if it is empty", () => {
|
||||||
const table = new Table(1, 1);
|
const table = new Table(1, 1);
|
||||||
const tree = new Formatter().format(table);
|
const tree = new Formatter().format(table);
|
||||||
expect(tree).to.have.property("w:tbl").which.is.an("array");
|
expect(tree)
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.is.an("array");
|
||||||
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
||||||
expect(row).not.to.be.undefined;
|
expect(row).not.to.be.undefined;
|
||||||
expect(row["w:tr"]).to.be.an("array").which.has.length.at.least(1);
|
expect(row["w:tr"])
|
||||||
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
|
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
|
||||||
"w:tc": [
|
"w:tc": [{ "w:tcPr": [] }, { "w:p": [{ "w:pPr": [] }] }],
|
||||||
{"w:tcPr": []},
|
|
||||||
{"w:p": [{"w:pPr": []}]},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -131,10 +145,14 @@ describe("Table", () => {
|
|||||||
const parentTable = new Table(1, 1);
|
const parentTable = new Table(1, 1);
|
||||||
parentTable.getCell(0, 0).addContent(new Table(1, 1));
|
parentTable.getCell(0, 0).addContent(new Table(1, 1));
|
||||||
const tree = new Formatter().format(parentTable);
|
const tree = new Formatter().format(parentTable);
|
||||||
expect(tree).to.have.property("w:tbl").which.is.an("array");
|
expect(tree)
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.is.an("array");
|
||||||
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
||||||
expect(row).not.to.be.undefined;
|
expect(row).not.to.be.undefined;
|
||||||
expect(row["w:tr"]).to.be.an("array").which.has.length.at.least(1);
|
expect(row["w:tr"])
|
||||||
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
const cell = row["w:tr"].find((x) => x["w:tc"]);
|
const cell = row["w:tr"].find((x) => x["w:tc"]);
|
||||||
expect(cell).not.to.be.undefined;
|
expect(cell).not.to.be.undefined;
|
||||||
expect(cell["w:tc"][cell["w:tc"].length - 1]).to.deep.equal({
|
expect(cell["w:tc"][cell["w:tc"].length - 1]).to.deep.equal({
|
||||||
@ -146,17 +164,23 @@ describe("Table", () => {
|
|||||||
const parentTable = new Table(1, 1);
|
const parentTable = new Table(1, 1);
|
||||||
parentTable.getCell(0, 0).addContent(new Paragraph("Hello"));
|
parentTable.getCell(0, 0).addContent(new Paragraph("Hello"));
|
||||||
const tree = new Formatter().format(parentTable);
|
const tree = new Formatter().format(parentTable);
|
||||||
expect(tree).to.have.property("w:tbl").which.is.an("array");
|
expect(tree)
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.is.an("array");
|
||||||
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
||||||
expect(row).not.to.be.undefined;
|
expect(row).not.to.be.undefined;
|
||||||
expect(row["w:tr"]).to.be.an("array").which.has.length.at.least(1);
|
expect(row["w:tr"])
|
||||||
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
|
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
|
||||||
"w:tc": [
|
"w:tc": [
|
||||||
{ "w:tcPr": [] },
|
{ "w:tcPr": [] },
|
||||||
{"w:p": [
|
{
|
||||||
|
"w:p": [
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{ "w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, "Hello"] }] },
|
{ "w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, "Hello"] }] },
|
||||||
]},
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -168,20 +192,25 @@ describe("Table", () => {
|
|||||||
const para = table.getCell(0, 0).createParagraph("Test paragraph");
|
const para = table.getCell(0, 0).createParagraph("Test paragraph");
|
||||||
expect(para).to.be.an.instanceof(Paragraph);
|
expect(para).to.be.an.instanceof(Paragraph);
|
||||||
const tree = new Formatter().format(table);
|
const tree = new Formatter().format(table);
|
||||||
expect(tree).to.have.property("w:tbl").which.is.an("array");
|
expect(tree)
|
||||||
|
.to.have.property("w:tbl")
|
||||||
|
.which.is.an("array");
|
||||||
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
const row = tree["w:tbl"].find((x) => x["w:tr"]);
|
||||||
expect(row).not.to.be.undefined;
|
expect(row).not.to.be.undefined;
|
||||||
expect(row["w:tr"]).to.be.an("array").which.has.length.at.least(1);
|
expect(row["w:tr"])
|
||||||
|
.to.be.an("array")
|
||||||
|
.which.has.length.at.least(1);
|
||||||
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
|
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
|
||||||
"w:tc": [
|
"w:tc": [
|
||||||
{ "w:tcPr": [] },
|
{ "w:tcPr": [] },
|
||||||
{"w:p": [
|
{
|
||||||
|
"w:p": [
|
||||||
{ "w:pPr": [] },
|
{ "w:pPr": [] },
|
||||||
{"w:r": [
|
{
|
||||||
{"w:rPr": []},
|
"w:r": [{ "w:rPr": [] }, { "w:t": [{ _attr: { "xml:space": "preserve" } }, "Test paragraph"] }],
|
||||||
{"w:t": [{_attr: {"xml:space": "preserve"}}, "Test paragraph"]},
|
},
|
||||||
]},
|
],
|
||||||
]},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,6 @@ import { Attributes } from "./";
|
|||||||
|
|
||||||
describe("Attribute", () => {
|
describe("Attribute", () => {
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should have val as defined with populated constructor", () => {
|
it("should have val as defined with populated constructor", () => {
|
||||||
const newAttrs = new Attributes({
|
const newAttrs = new Attributes({
|
||||||
val: "test",
|
val: "test",
|
||||||
|
@ -3,9 +3,7 @@ import { assert } from "chai";
|
|||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../tests/utility";
|
||||||
import { XmlComponent } from "./";
|
import { XmlComponent } from "./";
|
||||||
|
|
||||||
class TestComponent extends XmlComponent {
|
class TestComponent extends XmlComponent {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("XmlComponent", () => {
|
describe("XmlComponent", () => {
|
||||||
let xmlComponent: TestComponent;
|
let xmlComponent: TestComponent;
|
||||||
@ -15,7 +13,6 @@ describe("XmlComponent", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should create an Xml Component which has the correct rootKey", () => {
|
it("should create an Xml Component which has the correct rootKey", () => {
|
||||||
const newJson = Utility.jsonify(xmlComponent);
|
const newJson = Utility.jsonify(xmlComponent);
|
||||||
assert.equal(newJson.rootKey, "w:test");
|
assert.equal(newJson.rootKey, "w:test");
|
||||||
|
@ -11,12 +11,14 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public prepForXml(): IXmlableObject {
|
public prepForXml(): IXmlableObject {
|
||||||
const children = this.root.map((comp) => {
|
const children = this.root
|
||||||
|
.map((comp) => {
|
||||||
if (comp instanceof BaseXmlComponent) {
|
if (comp instanceof BaseXmlComponent) {
|
||||||
return comp.prepForXml();
|
return comp.prepForXml();
|
||||||
}
|
}
|
||||||
return comp;
|
return comp;
|
||||||
}).filter((comp) => comp); // Exclude null, undefined, and empty strings
|
})
|
||||||
|
.filter((comp) => comp); // Exclude null, undefined, and empty strings
|
||||||
return {
|
return {
|
||||||
[this.rootKey]: children,
|
[this.rootKey]: children,
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export interface IXmlableObject extends Object {
|
export interface IXmlableObject extends Object {
|
||||||
_attr?: { [key: string]: (string | number | boolean) };
|
_attr?: { [key: string]: string | number | boolean };
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user