docx
Version:
Generate .docx documents with JavaScript (formerly Office-Clippy)
16 lines (13 loc) • 464 B
text/typescript
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
class TextAttributes extends XmlAttributeComponent<{ space: "default" | "preserve" }> {
protected xmlKeys = { space: "xml:space" };
}
export class Text extends XmlComponent {
constructor(text: string) {
super("w:t");
this.root.push(new TextAttributes({ space: "preserve" }));
if (text) {
this.root.push(text);
}
}
}