From b8934c68f23b6e6ad56c81a7bb79ba79f30f6a9c Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Sat, 30 Jun 2018 23:50:02 +0100 Subject: [PATCH] Add counter to footnotes --- src/file/footnotes/footnote/footnote.spec.ts | 1 - src/file/footnotes/footnotes.ts | 33 +++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/file/footnotes/footnote/footnote.spec.ts b/src/file/footnotes/footnote/footnote.spec.ts index 065634a898..caeb8cc694 100644 --- a/src/file/footnotes/footnote/footnote.spec.ts +++ b/src/file/footnotes/footnote/footnote.spec.ts @@ -3,7 +3,6 @@ import { Formatter } from "../../../export/formatter"; import { Footnote, FootnoteType } from "./footnote"; describe("Footnote", () => { - describe("#constructor", () => { it("should create a footnote with a footnote type", () => { const footnote = new Footnote(1, FootnoteType.SEPERATOR); diff --git a/src/file/footnotes/footnotes.ts b/src/file/footnotes/footnotes.ts index fea6141842..bb6ac388c5 100644 --- a/src/file/footnotes/footnotes.ts +++ b/src/file/footnotes/footnotes.ts @@ -6,8 +6,13 @@ import { SeperatorRun } from "./footnote/run/seperator-run"; import { FootnotesAttributes } from "./footnotes-attributes"; export class FootNotes extends XmlComponent { + private counter: number; + constructor() { super("w:footnotes"); + + this.counter = 1; + this.root.push( new FootnotesAttributes({ wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", @@ -32,28 +37,34 @@ export class FootNotes extends XmlComponent { const begin = new Footnote(-1, FootnoteType.SEPERATOR); begin.addParagraph( - new Paragraph().spacing({ - after: 0, - line: 240, - lineRule: "auto", - }).addRun(new SeperatorRun()), + new Paragraph() + .spacing({ + after: 0, + line: 240, + lineRule: "auto", + }) + .addRun(new SeperatorRun()), ); this.root.push(begin); const spacing = new Footnote(0, FootnoteType.CONTINUATION_SEPERATOR); spacing.addParagraph( - new Paragraph().spacing({ - after: 0, - line: 240, - lineRule: "auto", - }).addRun(new ContinuationSeperatorRun()), + new Paragraph() + .spacing({ + after: 0, + line: 240, + lineRule: "auto", + }) + .addRun(new ContinuationSeperatorRun()), ); this.root.push(spacing); } public createFootNote(paragraph: Paragraph): void { - const footnote = new Footnote(1); + const footnote = new Footnote(this.counter); footnote.addParagraph(paragraph); this.root.push(footnote); + + this.counter++; } }