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

38 lines
1.3 KiB
TypeScript
Raw Normal View History

import { XmlComponent } from "file/xml-components";
2017-12-20 00:52:41 +00:00
import { DocumentAttributes } from "../document/document-attributes";
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");
2018-01-23 01:33:12 +00:00
this.root.push(
new DocumentAttributes({
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",
Ignorable: "w14 w15",
}),
);
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
}