diff --git a/ts/docx/document.ts b/ts/docx/document.ts index da1301fbae..0ce98f3571 100644 --- a/ts/docx/document.ts +++ b/ts/docx/document.ts @@ -1,11 +1,11 @@ - export class Document { - private body: string; - - constructor() { - this.body = "ggg"; - } - - test() { - return "hello"; - } - } \ No newline at end of file +export class Document { + private body: string; + + constructor() { + this.body = "ggg"; + } + + test() { + return "hello"; + } +} \ No newline at end of file diff --git a/ts/docx/paragraph.ts b/ts/docx/paragraph.ts index 20cec37ea1..d5ed0c7c1d 100644 --- a/ts/docx/paragraph.ts +++ b/ts/docx/paragraph.ts @@ -1,7 +1,12 @@ +import {P, Attributes, ParagraphProperties, Run} from "./xml-components/p"; + export class Paragraph { - private p: Array; + private p: Array

; - constructor() { - this.p = ['stuff'] + constructor(text?: string) { + this.p = new Array

(); + this.p.push(new Attributes()); + this.p.push(new ParagraphProperties()); + this.p.push(new Run(text)); } } \ No newline at end of file diff --git a/ts/docx/xml-components/p.ts b/ts/docx/xml-components/p.ts new file mode 100644 index 0000000000..4e409fea15 --- /dev/null +++ b/ts/docx/xml-components/p.ts @@ -0,0 +1,37 @@ +export interface P { + +} + +export class Attributes implements P { + private _attrs: Object; + + constructor() { + this._attrs = {}; + } +} + +export class ParagraphProperties implements P { + private pPr: Array

; + + constructor() { + this.pPr = new Array

(); + this.pPr.push(new Attributes()); + } +} + +export class Run implements P { + private r: Array

; + + constructor(text: string) { + this.r = new Array

(); + this.r.push(new Text(text)); + } +} + +export class Text implements P { + private t: string; + + constructor(text: string) { + this.t = text; + } +} \ No newline at end of file diff --git a/ts/export/formatter.ts b/ts/export/formatter.ts index 52034718ab..a1eceb33b9 100644 --- a/ts/export/formatter.ts +++ b/ts/export/formatter.ts @@ -6,7 +6,7 @@ export class Formatter { var stringified = JSON.stringify(input); var newJson = JSON.parse(stringified); this.deepTraverseJson(newJson, (parent, value, key) => { - parent.blah = parent[key]; + //parent.blah = parent[key]; }); diff --git a/ts/tests/docxTest.ts b/ts/tests/docxTest.ts index 9268f4fd14..db5aa28153 100644 --- a/ts/tests/docxTest.ts +++ b/ts/tests/docxTest.ts @@ -20,7 +20,8 @@ describe('Calculator', () => { var document = new docx.Document(); var paragraph = new docx.Paragraph(); //var body = new docx.Body(); - console.log(JSON.stringify(paragraph)); + console.log(paragraph); + console.log(JSON.stringify(paragraph, null, " ")); console.log(document.test()); }); }); \ No newline at end of file