added run
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import {XmlComponent, Attributes} from "../xml-components";
|
||||||
import {ThematicBreak} from "./border";
|
import {ThematicBreak} from "./border";
|
||||||
import {PageBreak} from "./page-break";
|
import {PageBreak} from "./page-break";
|
||||||
import {TextRun} from "./text-run";
|
import {TextRun} from "../run/text-run";
|
||||||
import {ParagraphProperties} from "./properties";
|
import {ParagraphProperties} from "./properties";
|
||||||
import {TabStop} from "../tab-stop";
|
import {TabStop} from "../tab-stop";
|
||||||
import {Style} from "./style";
|
import {Style} from "./style";
|
||||||
|
@ -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 {
|
class Break implements XmlComponent {
|
||||||
private br: Array<XmlComponent>;
|
private br: Array<XmlComponent>;
|
||||||
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
15
ts/docx/run/index.ts
Normal file
15
ts/docx/run/index.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import {XmlComponent, Attributes} from "../xml-components";
|
||||||
|
import {RunProperties} from "./properties";
|
||||||
|
|
||||||
|
export class Run implements XmlComponent {
|
||||||
|
protected r: Array<XmlComponent>;
|
||||||
|
private properties: RunProperties;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.r = new Array<XmlComponent>();
|
||||||
|
this.properties = new RunProperties();
|
||||||
|
this.r.push(this.properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
9
ts/docx/run/properties.ts
Normal file
9
ts/docx/run/properties.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import {XmlComponent, Attributes} from "../xml-components";
|
||||||
|
|
||||||
|
export class RunProperties {
|
||||||
|
private rPr: Array<XmlComponent>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.rPr = new Array<XmlComponent>();
|
||||||
|
}
|
||||||
|
}
|
10
ts/docx/run/text-run.ts
Normal file
10
ts/docx/run/text-run.ts
Normal file
@ -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));
|
||||||
|
}
|
||||||
|
}
|
@ -22,14 +22,6 @@ export class Attributes implements XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Run implements XmlComponent {
|
|
||||||
protected r: Array<XmlComponent>;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.r = new Array<XmlComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Text implements XmlComponent {
|
export class Text implements XmlComponent {
|
||||||
private t: string;
|
private t: string;
|
||||||
|
|
||||||
|
@ -27,5 +27,14 @@ describe('Attribute', () => {
|
|||||||
var newJson = JSON.parse(stringifiedJson);
|
var newJson = JSON.parse(stringifiedJson);
|
||||||
assert(newJson._attrs.val === "test");
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -90,13 +90,13 @@ describe('Paragraph', () => {
|
|||||||
it("should add page break to JSON", () => {
|
it("should add page break to JSON", () => {
|
||||||
paragraph.pageBreak();
|
paragraph.pageBreak();
|
||||||
var newJson = jsonify(paragraph);
|
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", () => {
|
it("should add page break with 'page' type", () => {
|
||||||
paragraph.pageBreak();
|
paragraph.pageBreak();
|
||||||
var newJson = jsonify(paragraph);
|
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");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user