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

30 lines
838 B
TypeScript
Raw Normal View History

import { XmlComponent, BaseXmlComponent } from "file/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 {
constructor(_initialStyles?: BaseXmlComponent) {
2016-04-09 20:16:35 +01:00
super("w:styles");
if (_initialStyles) {
this.root.push(_initialStyles);
}
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
}