Use enums instead of strings

This commit is contained in:
Dolan Miu
2018-06-30 23:41:57 +01:00
parent 6c85ad3188
commit 34a92ab448
2 changed files with 11 additions and 6 deletions

View File

@ -3,8 +3,13 @@ import { Paragraph } from "../../paragraph";
import { FootnoteAttributes } from "./footnote-attributes"; import { FootnoteAttributes } from "./footnote-attributes";
import { FootnoteRefRun } from "./run/footnote-ref-run"; import { FootnoteRefRun } from "./run/footnote-ref-run";
export class FootNote extends XmlComponent { export enum FootnoteType {
constructor(id: number, type?: string) { SEPERATOR = "separator",
CONTINUATION_SEPERATOR = "continuationSeparator",
}
export class Footnote extends XmlComponent {
constructor(id: number, type?: FootnoteType) {
super("w:footnote"); super("w:footnote");
this.root.push( this.root.push(
new FootnoteAttributes({ new FootnoteAttributes({

View File

@ -1,6 +1,6 @@
import { XmlComponent } from "file/xml-components"; import { XmlComponent } from "file/xml-components";
import { Paragraph } from "../paragraph"; import { Paragraph } from "../paragraph";
import { FootNote } from "./footnote/footnote"; import { Footnote, FootnoteType } from "./footnote/footnote";
import { ContinuationSeperatorRun } from "./footnote/run/continuation-seperator-run"; import { ContinuationSeperatorRun } from "./footnote/run/continuation-seperator-run";
import { SeperatorRun } from "./footnote/run/seperator-run"; import { SeperatorRun } from "./footnote/run/seperator-run";
import { FootnotesAttributes } from "./footnotes-attributes"; import { FootnotesAttributes } from "./footnotes-attributes";
@ -30,7 +30,7 @@ export class FootNotes extends XmlComponent {
}), }),
); );
const begin = new FootNote(-1, "separator"); const begin = new Footnote(-1, FootnoteType.SEPERATOR);
begin.addParagraph( begin.addParagraph(
new Paragraph().spacing({ new Paragraph().spacing({
after: 0, after: 0,
@ -40,7 +40,7 @@ export class FootNotes extends XmlComponent {
); );
this.root.push(begin); this.root.push(begin);
const spacing = new FootNote(0, "continuationSeparator"); const spacing = new Footnote(0, FootnoteType.CONTINUATION_SEPERATOR);
spacing.addParagraph( spacing.addParagraph(
new Paragraph().spacing({ new Paragraph().spacing({
after: 0, after: 0,
@ -52,7 +52,7 @@ export class FootNotes extends XmlComponent {
} }
public createFootNote(paragraph: Paragraph): void { public createFootNote(paragraph: Paragraph): void {
const footnote = new FootNote(1); const footnote = new Footnote(1);
footnote.addParagraph(paragraph); footnote.addParagraph(paragraph);
this.root.push(footnote); this.root.push(footnote);
} }