style factory added and fixed bug allowing styles to work
This commit is contained in:
31
ts/styles/factory.ts
Normal file
31
ts/styles/factory.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
@ -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)
|
||||
}, {
|
||||
|
Reference in New Issue
Block a user