diff --git a/ts/docx/run/run-components/drawing/index.ts b/ts/docx/run/run-components/drawing/index.ts index 668f45c612..3e9d1a883d 100644 --- a/ts/docx/run/run-components/drawing/index.ts +++ b/ts/docx/run/run-components/drawing/index.ts @@ -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)); } } diff --git a/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts index b9e8267e0d..c717a1098c 100644 --- a/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts +++ b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts @@ -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)); } } diff --git a/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts new file mode 100644 index 0000000000..2b4370a58b --- /dev/null +++ b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts @@ -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)); + } +} diff --git a/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip.ts b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip.ts new file mode 100644 index 0000000000..12ae6b01e2 --- /dev/null +++ b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip.ts @@ -0,0 +1,21 @@ +import { XmlAttributeComponent, XmlComponent } from "../../../../../../../../xml-components"; + +export interface IBlipProperties { + embed?: string; +} + +class BlipAttributes extends XmlAttributeComponent { + protected xmlKeys = { + embed: "r:embed", + }; +} + +export class Blip extends XmlComponent { + + constructor(referenceId: number) { + super("a:blip"); + this.root.push(new BlipAttributes({ + embed: `rId${referenceId}`, + })); + } +} diff --git a/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/index.ts b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/index.ts new file mode 100644 index 0000000000..54628facf8 --- /dev/null +++ b/ts/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/index.ts @@ -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)); + } +} diff --git a/ts/docx/run/run-components/drawing/inline/graphic/index.ts b/ts/docx/run/run-components/drawing/inline/graphic/index.ts index d922f44f58..f512e8ad5a 100644 --- a/ts/docx/run/run-components/drawing/inline/graphic/index.ts +++ b/ts/docx/run/run-components/drawing/inline/graphic/index.ts @@ -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)); } } diff --git a/ts/docx/run/run-components/drawing/inline/index.ts b/ts/docx/run/run-components/drawing/inline/index.ts index be38ec1836..8f752edfcc 100644 --- a/ts/docx/run/run-components/drawing/inline/index.ts +++ b/ts/docx/run/run-components/drawing/inline/index.ts @@ -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)); } } diff --git a/ts/tests/docx/run/run-components/drawingTests.ts b/ts/tests/docx/run/run-components/drawingTests.ts index dcc06bc361..20215a0931 100644 --- a/ts/tests/docx/run/run-components/drawingTests.ts +++ b/ts/tests/docx/run/run-components/drawingTests.ts @@ -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)); }); }); });