Files
docx-js/ts/styles/index.ts

38 lines
1.2 KiB
TypeScript
Raw Normal View History

2017-03-09 09:45:01 +01:00
import { DocumentAttributes } from "../docx/document/document-attributes";
import { XmlComponent } from "../docx/xml-components";
import { DocumentDefaults } from "./defaults";
2017-09-17 00:01:09 +01:00
import { ParagraphStyle } from "./style";
2016-04-03 05:23:13 +01:00
2016-04-09 20:16:35 +01:00
export class Styles extends XmlComponent {
2016-04-03 05:23:13 +01:00
constructor() {
2016-04-09 20:16:35 +01:00
super("w:styles");
this.root.push(new DocumentAttributes({
2016-05-19 23:05:28 +01:00
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
2017-03-09 09:45:01 +01:00
Ignorable: "w14 w15",
2016-05-26 15:08:34 +01:00
}));
2016-04-09 02:04:53 +01:00
}
2017-03-09 09:45:01 +01:00
public push(style: XmlComponent): Styles {
2016-04-09 20:16:35 +01:00
this.root.push(style);
2017-03-09 09:45:01 +01:00
return this;
2016-04-03 05:23:13 +01:00
}
2016-05-26 15:08:34 +01:00
public createDocumentDefaults(): DocumentDefaults {
const defaults = new DocumentDefaults();
this.push(defaults);
return defaults;
}
public createParagraphStyle(styleId: string, name?: string): ParagraphStyle {
const para = new ParagraphStyle(styleId, name);
this.push(para);
return para;
}
2017-03-09 09:45:01 +01:00
}