Files
docx-js/src/file/footnotes/footnote/footnote.ts

39 lines
1018 B
TypeScript
Raw Normal View History

import { Paragraph } from "@file/paragraph";
import { XmlComponent } from "@file/xml-components";
2018-10-26 01:04:07 +01:00
2018-06-11 00:45:21 +01:00
import { FootnoteAttributes } from "./footnote-attributes";
2018-06-28 03:01:25 +01:00
import { FootnoteRefRun } from "./run/footnote-ref-run";
2018-06-11 00:45:21 +01:00
2018-06-30 23:41:57 +01:00
export enum FootnoteType {
SEPERATOR = "separator",
CONTINUATION_SEPERATOR = "continuationSeparator",
}
2021-03-01 23:35:52 +00:00
export interface IFootnoteOptions {
readonly id: number;
readonly type?: FootnoteType;
readonly children: readonly Paragraph[];
2021-03-01 23:35:52 +00:00
}
2018-06-30 23:41:57 +01:00
export class Footnote extends XmlComponent {
2022-08-31 07:52:27 +01:00
public constructor(options: IFootnoteOptions) {
2018-06-11 00:45:21 +01:00
super("w:footnote");
this.root.push(
new FootnoteAttributes({
2020-01-01 20:22:42 +00:00
type: options.type,
id: options.id,
2018-06-11 00:45:21 +01:00
}),
);
2020-01-01 20:22:42 +00:00
for (let i = 0; i < options.children.length; i++) {
const child = options.children[i];
if (i === 0) {
child.addRunToFront(new FootnoteRefRun());
}
this.root.push(child);
}
2018-06-11 00:45:21 +01:00
}
}