/
spacing.ts
35 lines (31 loc) · 1 KB
/
spacing.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// http://officeopenxml.com/WPspacing.php
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
export const LineRuleType = {
// eslint-disable-next-line @typescript-eslint/naming-convention
AT_LEAST: "atLeast",
EXACTLY: "exactly",
EXACT: "exact",
AUTO: "auto",
} as const;
export interface ISpacingProperties {
readonly after?: number;
readonly before?: number;
readonly line?: number;
readonly lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType];
readonly beforeAutoSpacing?: boolean;
readonly afterAutoSpacing?: boolean;
}
class SpacingAttributes extends XmlAttributeComponent<ISpacingProperties> {
protected readonly xmlKeys = {
after: "w:after",
before: "w:before",
line: "w:line",
lineRule: "w:lineRule",
};
}
export class Spacing extends XmlComponent {
public constructor(options: ISpacingProperties) {
super("w:spacing");
this.root.push(new SpacingAttributes(options));
}
}