diff --git a/ts/docx/xml-components/base-attributes.ts b/ts/docx/xml-components/base-attributes.ts new file mode 100644 index 0000000000..7a7615fea3 --- /dev/null +++ b/ts/docx/xml-components/base-attributes.ts @@ -0,0 +1,16 @@ +import {XmlComponent} from "./"; + +export abstract class BaseAttributes implements XmlComponent { + private _attr: Object; + + xmlKeys = {}; + + constructor(xmlKeys: Object, properties?: any) { + this._attr = properties + + if (!properties) { + this._attr = {}; + } + this._attr["xmlKeys"] = this.xmlKeys; + } +} \ No newline at end of file diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts index b8a34d678e..c8c4c2a845 100644 --- a/ts/export/packer/packer.ts +++ b/ts/export/packer/packer.ts @@ -3,7 +3,7 @@ import * as fs from "fs"; import * as xml from "xml"; import {Formatter} from "../formatter"; import {Document} from "../../docx"; -import {Style} from "../../style"; +import {Styles} from "../../styles"; import {Properties} from "../../properties"; var appRoot = require('app-root-path'); @@ -11,7 +11,7 @@ export abstract class Packer { protected archive: any; private formatter: Formatter; protected document: Document; - private style: Style; + private style: Styles; private properties: Properties; constructor(document: Document, style: any, properties: Properties) { diff --git a/ts/styles/index.ts b/ts/styles/index.ts index 6419bc4155..f54231f7c5 100644 --- a/ts/styles/index.ts +++ b/ts/styles/index.ts @@ -5,7 +5,7 @@ import {LatentStyles} from "./latent-styles"; import {LatentStyleException} from "./latent-styles/exceptions"; import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes"; -export class Style implements XmlComponent { +export class Styles implements XmlComponent { private styles: Array; xmlKeys = { diff --git a/ts/styles/style/attributes.ts b/ts/styles/style/attributes.ts new file mode 100644 index 0000000000..32fd27baa5 --- /dev/null +++ b/ts/styles/style/attributes.ts @@ -0,0 +1,28 @@ +import {XmlComponent} from "../../docx/xml-components"; + +interface StyleAttributesProperties { + type?: string; + styleId?: string; + default?: string; + customStyle?: string; +} + +export class StyleAttributes implements XmlComponent { + private _attr: Object; + + xmlKeys = { + type: "w:type", + styleId: "w:styleId", + default: "w:default", + customStyle: "w:customStyle" + }; + + constructor(properties?: StyleAttributesProperties) { + this._attr = properties + + if (!properties) { + this._attr = {}; + } + this._attr["xmlKeys"] = this.xmlKeys; + } +} \ No newline at end of file diff --git a/ts/styles/style/components.ts b/ts/styles/style/components.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ts/styles/style/index.ts b/ts/styles/style/index.ts new file mode 100644 index 0000000000..b212311584 --- /dev/null +++ b/ts/styles/style/index.ts @@ -0,0 +1,19 @@ +import {XmlComponent} from "../../docx/xml-components"; +import {StyleAttributes} from "./attributes"; + +export class Style implements XmlComponent { + private style: Array; + + xmlKeys = { + style: "w:style" + } + + constructor(attributes: StyleAttributes) { + this.style = new Array(); + this.style.push(attributes); + } + + push(styleSegment: XmlComponent): void { + this.style.push(styleSegment); + } +} \ No newline at end of file diff --git a/ts/tests/localPackerTest.ts b/ts/tests/localPackerTest.ts index aed29338d1..c8f65001d0 100644 --- a/ts/tests/localPackerTest.ts +++ b/ts/tests/localPackerTest.ts @@ -7,10 +7,10 @@ import {LocalPacker} from "../export/packer/local"; import {assert} from "chai"; import {Document} from "../docx/document" import {Properties} from "../properties" -import {DefaultStyle} from "../style/default" +import {DefaultStyle} from "../styles/sample" import {Paragraph} from "../docx/paragraph" -describe.only("Packer", () => { +describe("Packer", () => { var packer: LocalPacker; beforeEach(() => {