Refactor to separate classes in their specific files an tests improuvements for styles

This commit is contained in:
Sergio Mendonça
2018-11-13 11:04:03 -02:00
parent ff443aa7c4
commit 7639b60b15
13 changed files with 1689 additions and 874 deletions

View File

@ -0,0 +1,32 @@
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { Name } from "./components";
export interface IStyleAttributes {
readonly type?: string;
readonly styleId?: string;
readonly default?: boolean;
readonly customStyle?: string;
}
class StyleAttributes extends XmlAttributeComponent<IStyleAttributes> {
protected readonly xmlKeys = {
type: "w:type",
styleId: "w:styleId",
default: "w:default",
customStyle: "w:customStyle",
};
}
export class Style extends XmlComponent {
constructor(attributes: IStyleAttributes, name?: string) {
super("w:style");
this.root.push(new StyleAttributes(attributes));
if (name) {
this.root.push(new Name(name));
}
}
public push(styleSegment: XmlComponent): void {
this.root.push(styleSegment);
}
}