diff --git a/ts/docx/paragraph/index.ts b/ts/docx/paragraph/index.ts index dc991b911b..d9bdd8e085 100644 --- a/ts/docx/paragraph/index.ts +++ b/ts/docx/paragraph/index.ts @@ -1,7 +1,7 @@ import {XmlComponent, Attributes} from "../xml-components"; import {ThematicBreak} from "./border"; import {PageBreak} from "./page-break"; -import {TextRun} from "./text-run"; +import {TextRun} from "../run/text-run"; import {ParagraphProperties} from "./properties"; import {TabStop} from "../tab-stop"; import {Style} from "./style"; diff --git a/ts/docx/paragraph/page-break.ts b/ts/docx/paragraph/page-break.ts index ab0444c2ad..2d13cd7b5f 100644 --- a/ts/docx/paragraph/page-break.ts +++ b/ts/docx/paragraph/page-break.ts @@ -1,4 +1,5 @@ -import {XmlComponent, Attributes, Run} from "../xml-components"; +import {XmlComponent, Attributes} from "../xml-components"; +import {Run} from "../run"; class Break implements XmlComponent { private br: Array; diff --git a/ts/docx/paragraph/text-run.ts b/ts/docx/paragraph/text-run.ts deleted file mode 100644 index d619823830..0000000000 --- a/ts/docx/paragraph/text-run.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {Run, Text} from "../xml-components"; -import {ParagraphProperties} from "./properties"; - -export class TextRun extends Run { - - constructor(text: string) { - super(); - this.r.push(new ParagraphProperties()); - this.r.push(new Text(text)); - } -} \ No newline at end of file diff --git a/ts/docx/run/index.ts b/ts/docx/run/index.ts new file mode 100644 index 0000000000..8d33527488 --- /dev/null +++ b/ts/docx/run/index.ts @@ -0,0 +1,15 @@ +import {XmlComponent, Attributes} from "../xml-components"; +import {RunProperties} from "./properties"; + +export class Run implements XmlComponent { + protected r: Array; + private properties: RunProperties; + + constructor() { + this.r = new Array(); + this.properties = new RunProperties(); + this.r.push(this.properties); + } + + +} \ No newline at end of file diff --git a/ts/docx/run/properties.ts b/ts/docx/run/properties.ts new file mode 100644 index 0000000000..30e9631da8 --- /dev/null +++ b/ts/docx/run/properties.ts @@ -0,0 +1,9 @@ +import {XmlComponent, Attributes} from "../xml-components"; + +export class RunProperties { + private rPr: Array; + + constructor() { + this.rPr = new Array(); + } +} diff --git a/ts/docx/run/text-run.ts b/ts/docx/run/text-run.ts new file mode 100644 index 0000000000..2b46a802f6 --- /dev/null +++ b/ts/docx/run/text-run.ts @@ -0,0 +1,10 @@ +import {Text} from "../xml-components"; +import {Run} from "../run"; + +export class TextRun extends Run { + + constructor(text: string) { + super(); + this.r.push(new Text(text)); + } +} \ No newline at end of file diff --git a/ts/docx/xml-components/index.ts b/ts/docx/xml-components/index.ts index ccdea9d198..66665cd3e2 100644 --- a/ts/docx/xml-components/index.ts +++ b/ts/docx/xml-components/index.ts @@ -22,14 +22,6 @@ export class Attributes implements XmlComponent { } } -export class Run implements XmlComponent { - protected r: Array; - - constructor() { - this.r = new Array(); - } -} - export class Text implements XmlComponent { private t: string; diff --git a/ts/tests/attributeTest.ts b/ts/tests/attributeTest.ts index 24eb317eee..33d915b891 100644 --- a/ts/tests/attributeTest.ts +++ b/ts/tests/attributeTest.ts @@ -27,5 +27,14 @@ describe('Attribute', () => { var newJson = JSON.parse(stringifiedJson); assert(newJson._attrs.val === "test"); }); + + it("should have space value as defined with populated constructor", () => { + var newAttrs = new Attributes({ + space: "spaceTest" + }); + var stringifiedJson = JSON.stringify(newAttrs); + var newJson = JSON.parse(stringifiedJson); + assert(newJson._attrs.space === "spaceTest"); + }); }); }); \ No newline at end of file diff --git a/ts/tests/paragraphTest.ts b/ts/tests/paragraphTest.ts index 281958f9bd..13d585ed14 100644 --- a/ts/tests/paragraphTest.ts +++ b/ts/tests/paragraphTest.ts @@ -90,13 +90,13 @@ describe('Paragraph', () => { it("should add page break to JSON", () => { paragraph.pageBreak(); var newJson = jsonify(paragraph); - assert.isDefined(newJson.p[1].pPr[1].r[0].br); + assert.isDefined(newJson.p[1].pPr[1].r[1].br); }); it("should add page break with 'page' type", () => { paragraph.pageBreak(); var newJson = jsonify(paragraph); - assert(newJson.p[1].pPr[1].r[0].br[0]._attrs.type === "page"); + assert(newJson.p[1].pPr[1].r[1].br[0]._attrs.type === "page"); }); });