added the remaining classes required

This commit is contained in:
Dolan Miu
2017-03-13 00:02:56 +00:00
parent 34ce662f70
commit fa44acca1b
8 changed files with 58 additions and 5 deletions

View File

@ -1,8 +1,13 @@
import { XmlComponent } from "../../../xml-components";
import { Inline } from "./inline";
export class Drawing extends XmlComponent {
constructor(imagePath: string) {
super("w:drawing");
// store in the document, then get Id
this.root.push(new Inline(5));
}
}

View File

@ -1,8 +1,10 @@
import { XmlComponent } from "../../../../../../xml-components";
import { Pic } from "./pic";
export class Graphic extends XmlComponent {
export class GraphicData extends XmlComponent {
constructor() {
constructor(referenceId: number) {
super("a:graphicData");
this.root.push(new Pic(referenceId));
}
}

View File

@ -0,0 +1,10 @@
import { XmlComponent } from "../../../../../../../../xml-components";
import { Blip } from "./blip";
export class BlipFill extends XmlComponent {
constructor(referenceId: number) {
super("pic:blipFill");
this.root.push(new Blip(referenceId));
}
}

View File

@ -0,0 +1,21 @@
import { XmlAttributeComponent, XmlComponent } from "../../../../../../../../xml-components";
export interface IBlipProperties {
embed?: string;
}
class BlipAttributes extends XmlAttributeComponent<IBlipProperties> {
protected xmlKeys = {
embed: "r:embed",
};
}
export class Blip extends XmlComponent {
constructor(referenceId: number) {
super("a:blip");
this.root.push(new BlipAttributes({
embed: `rId${referenceId}`,
}));
}
}

View File

@ -0,0 +1,10 @@
import { XmlComponent } from "../../../../../../../xml-components";
import { BlipFill } from "./blip/blip-fill";
export class Pic extends XmlComponent {
constructor(referenceId: number) {
super("pic:pic");
this.root.push(new BlipFill(referenceId));
}
}

View File

@ -1,8 +1,10 @@
import { XmlComponent } from "../../../../../xml-components";
import { GraphicData } from "./graphic-data";
export class Graphic extends XmlComponent {
constructor() {
constructor(referenceId: number) {
super("a:graphic");
this.root.push(new GraphicData(referenceId));
}
}

View File

@ -1,8 +1,10 @@
import { XmlComponent } from "../../../../xml-components";
import { Graphic } from "./graphic";
export class Inline extends XmlComponent {
constructor() {
constructor(referenceId: number) {
super("wp:inline");
this.root.push(new Graphic(referenceId));
}
}

View File

@ -1,4 +1,4 @@
import { assert, expect } from "chai";
import { assert } from "chai";
import { Drawing } from "../../../../docx/run/run-components/drawing";
import { Utility } from "../../../utility";
@ -13,6 +13,7 @@ describe.only("Drawing", () => {
it("should create a Drawing with correct root key", () => {
const newJson = Utility.jsonify(currentBreak);
assert.equal(newJson.rootKey, "w:drawing");
console.log(JSON.stringify(newJson, null, 2));
});
});
});