added properties
This commit is contained in:
@ -1,7 +1,12 @@
|
|||||||
export class Paragraph {
|
import {P, Attributes, ParagraphProperties, Run} from "./xml-components/p";
|
||||||
private p: Array<string>;
|
|
||||||
|
|
||||||
constructor() {
|
export class Paragraph {
|
||||||
this.p = ['stuff']
|
private p: Array<P>;
|
||||||
|
|
||||||
|
constructor(text?: string) {
|
||||||
|
this.p = new Array<P>();
|
||||||
|
this.p.push(new Attributes());
|
||||||
|
this.p.push(new ParagraphProperties());
|
||||||
|
this.p.push(new Run(text));
|
||||||
}
|
}
|
||||||
}
|
}
|
37
ts/docx/xml-components/p.ts
Normal file
37
ts/docx/xml-components/p.ts
Normal file
@ -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<P>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.pPr = new Array<P>();
|
||||||
|
this.pPr.push(new Attributes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Run implements P {
|
||||||
|
private r: Array<P>;
|
||||||
|
|
||||||
|
constructor(text: string) {
|
||||||
|
this.r = new Array<P>();
|
||||||
|
this.r.push(new Text(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Text implements P {
|
||||||
|
private t: string;
|
||||||
|
|
||||||
|
constructor(text: string) {
|
||||||
|
this.t = text;
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ export class Formatter {
|
|||||||
var stringified = JSON.stringify(input);
|
var stringified = JSON.stringify(input);
|
||||||
var newJson = JSON.parse(stringified);
|
var newJson = JSON.parse(stringified);
|
||||||
this.deepTraverseJson(newJson, (parent, value, key) => {
|
this.deepTraverseJson(newJson, (parent, value, key) => {
|
||||||
parent.blah = parent[key];
|
//parent.blah = parent[key];
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ describe('Calculator', () => {
|
|||||||
var document = new docx.Document();
|
var document = new docx.Document();
|
||||||
var paragraph = new docx.Paragraph();
|
var paragraph = new docx.Paragraph();
|
||||||
//var body = new docx.Body();
|
//var body = new docx.Body();
|
||||||
console.log(JSON.stringify(paragraph));
|
console.log(paragraph);
|
||||||
|
console.log(JSON.stringify(paragraph, null, " "));
|
||||||
console.log(document.test());
|
console.log(document.test());
|
||||||
});
|
});
|
||||||
});
|
});
|
Reference in New Issue
Block a user