diff --git a/src/file/paragraph/run/field.ts b/src/file/paragraph/run/field.ts new file mode 100644 index 0000000000..8465418cf7 --- /dev/null +++ b/src/file/paragraph/run/field.ts @@ -0,0 +1,26 @@ +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; + +class FidCharAttrs extends XmlAttributeComponent<{ type: "begin" | "end" | "separate" }> { + protected xmlKeys = { type: "w:fldCharType" }; +} + +export class Begin extends XmlComponent { + constructor() { + super("w:fldChar"); + this.root.push(new FidCharAttrs({ type: "begin" })); + } +} + +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" })); + } +} diff --git a/src/file/paragraph/run/page-number.ts b/src/file/paragraph/run/page-number.ts index 4048c4f79a..ab3592fd18 100644 --- a/src/file/paragraph/run/page-number.ts +++ b/src/file/paragraph/run/page-number.ts @@ -1,20 +1,9 @@ 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"); @@ -22,17 +11,3 @@ export class Page extends XmlComponent { 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" })); - } -} diff --git a/src/file/paragraph/run/run.ts b/src/file/paragraph/run/run.ts index 70b344842f..b7722e1e44 100644 --- a/src/file/paragraph/run/run.ts +++ b/src/file/paragraph/run/run.ts @@ -1,6 +1,7 @@ // http://officeopenxml.com/WPtext.php import { Break } from "./break"; import { Caps, SmallCaps } from "./caps"; +import { Begin, End, Separate } from "./field"; import { Bold, BoldComplexScript, @@ -13,7 +14,7 @@ import { SizeComplexScript, Strike, } from "./formatting"; -import { Begin, End, Page, Separate } from "./page-number"; +import { Page } from "./page-number"; import { RunProperties } from "./properties"; import { RunFonts } from "./run-fonts"; import { SubScript, SuperScript } from "./script";