Initial Commit

This commit is contained in:
Tyler Bell
2018-05-12 20:04:54 -04:00
parent 4d7bdc2ed9
commit 87648a742c
14 changed files with 301 additions and 8 deletions

View File

@ -0,0 +1,38 @@
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
class fidCharAttrs extends XmlAttributeComponent<{ type: "begin" | "end" | "separate" }> {
protected xmlKeys = { type: "w:fldCharType" };
}
class TextAttributes extends XmlAttributeComponent<{ space: "default" | "preserve" }> {
protected xmlKeys = { space: "xml:space" };
}
export class Begin extends XmlComponent {
constructor() {
super("w:fldChar");
this.root.push(new fidCharAttrs({ type: "begin" }));
}
}
export class Page extends XmlComponent {
constructor() {
super("w:instrText");
this.root.push(new TextAttributes({ space: "preserve" }));
this.root.push("PAGE");
}
}
export class Separate extends XmlComponent {
constructor() {
super("w:fldChar");
this.root.push(new fidCharAttrs({ type: "separate" }));
}
}
export class End extends XmlComponent {
constructor() {
super("w:fldChar");
this.root.push(new fidCharAttrs({ type: "end" }));
}
}

View File

@ -8,6 +8,7 @@ import { SubScript, SuperScript } from "./script";
import { Style } from "./style";
import { Tab } from "./tab";
import { Underline } from "./underline";
import { Begin, Page, End, Separate } from "./pagenumber";
import { XmlComponent } from "file/xml-components";
@ -55,6 +56,14 @@ export class Run extends XmlComponent {
return this;
}
public pageNumber(): Run {
this.root.push(new Begin());
this.root.push(new Page());
this.root.push(new Separate());
this.root.push(new End());
return this;
}
public smallCaps(): Run {
this.properties.push(new SmallCaps());
return this;