Refactor to separate classes in their specific files an tests improuvements for styles
This commit is contained in:
32
src/file/styles/style/style.ts
Normal file
32
src/file/styles/style/style.ts
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user