Files
docx-js/src/file/paragraph/formatting/spacing.ts

37 lines
1.0 KiB
TypeScript
Raw Normal View History

2017-09-21 14:56:46 +01:00
// http://officeopenxml.com/WPspacing.php
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
export const LineRuleType = {
AT_LEAST: "atLeast",
EXACTLY: "exactly",
EXACT: "exact",
AUTO: "auto",
} as const;
export type ISpacingProperties = {
readonly after?: number;
readonly before?: number;
readonly line?: number;
readonly lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType];
2021-03-15 19:23:40 +00:00
readonly beforeAutoSpacing?: boolean;
readonly afterAutoSpacing?: boolean;
};
class SpacingAttributes extends XmlAttributeComponent<ISpacingProperties> {
protected readonly xmlKeys = {
after: "w:after",
before: "w:before",
line: "w:line",
2018-06-11 00:45:21 +01:00
lineRule: "w:lineRule",
beforeAutoSpacing: "w:beforeAutospacing",
afterAutoSpacing: "w:afterAutospacing",
};
}
export class Spacing extends XmlComponent {
2022-08-31 07:52:27 +01:00
public constructor(options: ISpacingProperties) {
super("w:spacing");
2019-01-11 00:16:25 +00:00
this.root.push(new SpacingAttributes(options));
}
}