diff --git a/template/[Content_Types].xml b/template/[Content_Types].xml index 7baf58a03b..419d57897f 100644 --- a/template/[Content_Types].xml +++ b/template/[Content_Types].xml @@ -6,4 +6,5 @@ + diff --git a/template/word/_rels/document.xml.rels b/template/word/_rels/document.xml.rels index 6a6fbde4c2..50d83cc54c 100644 --- a/template/word/_rels/document.xml.rels +++ b/template/word/_rels/document.xml.rels @@ -1,4 +1,5 @@ + diff --git a/ts/docx/xml-components/default-attributes.ts b/ts/docx/xml-components/default-attributes.ts index d7110f2ac9..4834502de5 100644 --- a/ts/docx/xml-components/default-attributes.ts +++ b/ts/docx/xml-components/default-attributes.ts @@ -1,4 +1,5 @@ import {BaseXmlComponent} from "./base"; +import * as _ from "lodash"; export abstract class XmlAttributeComponent extends BaseXmlComponent { protected root: Object; diff --git a/ts/export/formatter.ts b/ts/export/formatter.ts index 106d2db39e..b9fc323bd7 100644 --- a/ts/export/formatter.ts +++ b/ts/export/formatter.ts @@ -32,7 +32,7 @@ export class Formatter { } }); - return newJson + return newJson; } private jsonify(obj: Object): Object { diff --git a/ts/export/packer/express.ts b/ts/export/packer/express.ts index 87ab026b37..3db8dd852a 100644 --- a/ts/export/packer/express.ts +++ b/ts/export/packer/express.ts @@ -4,11 +4,12 @@ import * as express from "express"; import {Document} from "../../docx/document"; import {Properties} from "../../properties"; import {DefaultStylesFactory} from "../../styles/factory" +import {Numbering} from "../../numbering"; export class ExpressPacker extends Packer { private res: express.Response; - constructor(document: Document, res: express.Response, styles?: any, properties?: Properties) { + constructor(document: Document, res: express.Response, styles?: any, properties?: Properties, numbering?: Numbering) { if (!styles) { var stylesFactory = new DefaultStylesFactory(); styles = stylesFactory.newInstance() @@ -22,7 +23,11 @@ export class ExpressPacker extends Packer { }); } - super(document, styles, properties); + if (!numbering) { + numbering = new Numbering(); + } + + super(document, styles, properties, numbering); this.res = res; this.res.on('close', () => { diff --git a/ts/export/packer/local.ts b/ts/export/packer/local.ts index 7d207f073d..fccab59afa 100644 --- a/ts/export/packer/local.ts +++ b/ts/export/packer/local.ts @@ -2,12 +2,18 @@ import {Packer} from "./packer"; import * as fs from 'fs'; import {Document} from "../../docx/document"; import {Properties} from "../../properties"; +import {Numbering} from "../../numbering"; export class LocalPacker extends Packer { private stream: fs.WriteStream - constructor(document: Document, style: any, properties: Properties, path: string) { - super(document, style, properties); + constructor(document: Document, style: any, properties: Properties, path: string, numbering?: Numbering) { + + if (!numbering) { + numbering = new Numbering(); + } + + super(document, style, properties, numbering); this.stream = fs.createWriteStream(path); } diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts index aba4988d0d..62e0bed3fc 100644 --- a/ts/export/packer/packer.ts +++ b/ts/export/packer/packer.ts @@ -53,6 +53,8 @@ export abstract class Packer { var xmlStyles = xml(this.formatter.format(this.style)); var xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: 'yes', encoding: 'UTF-8' } }); var xmlNumbering = xml(this.formatter.format(this.numbering)); + console.log(xmlNumbering); + this.archive.append(xmlDocument, { name: 'word/document.xml' }); diff --git a/ts/numbering/index.ts b/ts/numbering/index.ts index 17d1a998b0..c5174f8f1f 100644 --- a/ts/numbering/index.ts +++ b/ts/numbering/index.ts @@ -5,6 +5,7 @@ import {Level} from "./level"; import {Indent} from "./indent"; import {RunFonts} from "./run-fonts"; import {Num} from "./num"; +import * as _ from "lodash"; export class Numbering extends MultiPropertyXmlComponent { @@ -80,4 +81,10 @@ export class Numbering extends MultiPropertyXmlComponent { this.root.push(abstractNumbering); this.root.push(new Num(1, 0)); } + + clearVariables() { + _.forEach(this.root, element => { + element.clearVariables(); + }); + } } \ No newline at end of file diff --git a/ts/numbering/level.ts b/ts/numbering/level.ts index 554ab9f5ac..41b596507c 100644 --- a/ts/numbering/level.ts +++ b/ts/numbering/level.ts @@ -88,8 +88,8 @@ export class Level extends XmlComponent { delete this.paragraphProperties; delete this.runProperties; } - - addParagraphProperty(property: XmlComponent): void { + + addParagraphProperty(property: XmlComponent): void { this.paragraphProperties.push(property); } diff --git a/ts/styles/factory.ts b/ts/styles/factory.ts index 34ecd7162d..d99d0fc57d 100644 --- a/ts/styles/factory.ts +++ b/ts/styles/factory.ts @@ -50,7 +50,7 @@ export class DefaultStylesFactory { //listParagraph.addParagraphProperty(); styles.push(listParagraph); - console.log(JSON.stringify(styles, null, " ")); + //console.log(JSON.stringify(styles, null, " ")); return styles; } } \ No newline at end of file diff --git a/ts/styles/index.ts b/ts/styles/index.ts index 82b7b6559a..4f87d0b6d3 100644 --- a/ts/styles/index.ts +++ b/ts/styles/index.ts @@ -29,8 +29,6 @@ export class Styles extends XmlComponent { } clearVariables() { - console.log(this); - console.log(this.root); this.root.forEach(element => { element.clearVariables(); })