docx
Version:
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
33 lines (27 loc) • 965 B
text/typescript
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
enum FieldCharacterType {
BEGIN = "begin",
END = "end",
SEPARATE = "separate",
}
class FidCharAttrs extends XmlAttributeComponent<{ readonly type: FieldCharacterType; readonly dirty?: boolean }> {
protected readonly xmlKeys = { type: "w:fldCharType", dirty: "w:dirty" };
}
export class Begin extends XmlComponent {
constructor(dirty?: boolean) {
super("w:fldChar");
this.root.push(new FidCharAttrs({ type: FieldCharacterType.BEGIN, dirty }));
}
}
export class Separate extends XmlComponent {
constructor(dirty?: boolean) {
super("w:fldChar");
this.root.push(new FidCharAttrs({ type: FieldCharacterType.SEPARATE, dirty }));
}
}
export class End extends XmlComponent {
constructor(dirty?: boolean) {
super("w:fldChar");
this.root.push(new FidCharAttrs({ type: FieldCharacterType.END, dirty }));
}
}