diff --git a/template/[Content_Types].xml b/template/[Content_Types].xml
index 6a6465a2a9..7baf58a03b 100644
--- a/template/[Content_Types].xml
+++ b/template/[Content_Types].xml
@@ -3,6 +3,7 @@
+
-
\ No newline at end of file
+
diff --git a/template/word/_rels/document.xml.rels b/template/word/_rels/document.xml.rels
index fa78bfd2e7..6a6fbde4c2 100644
--- a/template/word/_rels/document.xml.rels
+++ b/template/word/_rels/document.xml.rels
@@ -1,3 +1,4 @@
-
\ No newline at end of file
+
+
diff --git a/ts/docx/paragraph/properties.ts b/ts/docx/paragraph/properties.ts
index 5675a472cf..9d0e6117d7 100644
--- a/ts/docx/paragraph/properties.ts
+++ b/ts/docx/paragraph/properties.ts
@@ -3,7 +3,7 @@ import {XmlComponent, Attributes} from "../xml-components";
export class ParagraphProperties extends XmlComponent {
constructor() {
- super("w:rPr");
+ super("w:pPr");
this.root.push(new Attributes());
}
diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts
index fd2f04e6f4..1179368bb4 100644
--- a/ts/export/packer/packer.ts
+++ b/ts/export/packer/packer.ts
@@ -46,10 +46,11 @@ export abstract class Packer {
prefix: "root"
});*/
var xmlDocument = xml(this.formatter.format(this.document));
- console.log(xmlDocument);
- var xmlStyle = xml(this.style);
+ var xmlStyle = xml(this.formatter.format(this.style));
+ //var xmlStyle = xml(this.style);
var xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: 'yes', encoding: 'UTF-8' } });
+ console.log(xmlStyle);
//console.log(JSON.stringify(this.formatter.format(this.document), null, " "));
//console.log(xmlDocument);
@@ -57,9 +58,9 @@ export abstract class Packer {
name: 'word/document.xml'
});
- //this.archive.append(xmlStyle, {
- // name: 'word/newStyle.xml'
- //});
+ this.archive.append(xmlStyle, {
+ name: 'word/styles.xml'
+ });
this.archive.append(xmlProperties, {
name: 'docProps/core.xml'
diff --git a/ts/styles/factory.ts b/ts/styles/factory.ts
new file mode 100644
index 0000000000..8176f10108
--- /dev/null
+++ b/ts/styles/factory.ts
@@ -0,0 +1,31 @@
+import {Styles} from "./";
+import {DocumentDefaults} from "./defaults";
+import {ParagraphPropertiesDefaults} from "./defaults/paragraph-properties";
+import {RunPropertiesDefaults} from "./defaults/run-properties";
+import {Heading1Style} from "./style";
+//import {StyleAttributes} from "./style/attributes";
+import {ParagraphProperties} from "../docx/paragraph/properties";
+import {RunProperties} from "../docx/run/properties";
+import {Color} from "../docx/run/formatting";
+
+export class DefaultStylesFactory {
+ constructor() {
+
+ }
+
+ newInstance(): Styles {
+ var styles = new Styles();
+ var paragraphProperties = new ParagraphPropertiesDefaults();
+ var runProperties = new RunPropertiesDefaults();
+ styles.push(new DocumentDefaults(paragraphProperties, runProperties));
+
+ var heading1ParagraphProperties = new ParagraphProperties();
+ var heading1RunProperties = new RunProperties();
+ heading1RunProperties.push(new Color("365F91"));
+ var heading1Style = new Heading1Style(heading1ParagraphProperties, heading1RunProperties);
+ styles.push(heading1Style);
+
+ 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 155c8c3efe..098972d537 100644
--- a/ts/styles/index.ts
+++ b/ts/styles/index.ts
@@ -17,12 +17,11 @@ export class Styles extends XmlComponent {
w15: 'http://schemas.microsoft.com/office/word/2012/wordml',
Ignorable: 'w14 w15'
}))
- this.root.push(new DocumentDefaults());
- var latentStyles = new LatentStyles();
+ //var latentStyles = new LatentStyles();
//latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({
// name: "Normal"
//})));
- this.root.push(latentStyles);
+ //this.root.push(latentStyles);
}
push(style: XmlComponent): void {
diff --git a/ts/styles/sample/index.ts b/ts/styles/sample/index.ts
index 90151acce6..4eae15443e 100644
--- a/ts/styles/sample/index.ts
+++ b/ts/styles/sample/index.ts
@@ -82,8 +82,6 @@ export function DefaultStyle() {
}
}, {
'w:lsdException': createLsdException('Normal', 0, 1)
- }, {
- 'w:lsdException': createLsdException("heading 1", 9, 1)
}, {
'w:lsdException': createLsdException("heading 1", 9, 1, 1, 1)
}, {
diff --git a/ts/tests/localPackerTest.ts b/ts/tests/localPackerTest.ts
index b8d1b55265..5f82bb00ec 100644
--- a/ts/tests/localPackerTest.ts
+++ b/ts/tests/localPackerTest.ts
@@ -9,25 +9,31 @@ import {Document} from "../docx/document"
import {Properties} from "../properties"
import {DefaultStyle} from "../styles/sample"
import {Paragraph} from "../docx/paragraph"
+import {DefaultStylesFactory} from "../styles/factory"
describe("Packer", () => {
var packer: LocalPacker;
+ var stylesFactory: DefaultStylesFactory;
beforeEach(() => {
var document = new Document();
var paragraph = new Paragraph("test text");
+ var heading = new Paragraph("Hello world").heading1();
+ document.addParagraph(heading);
document.addParagraph(paragraph);
var properties = new Properties({
creator: "Shan Fu",
revision: "1",
lastModifiedBy: "Shan Fu"
});
- packer = new LocalPacker(document, DefaultStyle(), properties, "build/tests/test.docx");
+ stylesFactory = new DefaultStylesFactory();
+ packer = new LocalPacker(document, stylesFactory.newInstance(), properties, "build/tests/test.docx");
+ //packer = new LocalPacker(document, DefaultStyle(), properties, "build/tests/test.docx");
});
describe('#pack()', () => {
-
- it("should create a standard docx file", (done) => {
+
+ it("should create a standard docx file", (done) => {
packer.pack();
setTimeout(done, 1900);
});