* feat: change all enums to as const objects * Add word to dictionary --------- Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Paragraph } from "@file/paragraph";
|
|
import { XmlComponent } from "@file/xml-components";
|
|
|
|
import { FootnoteAttributes } from "./footnote-attributes";
|
|
import { FootnoteRefRun } from "./run/footnote-ref-run";
|
|
|
|
export const FootnoteType = {
|
|
SEPERATOR: "separator",
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
CONTINUATION_SEPERATOR: "continuationSeparator",
|
|
} as const;
|
|
|
|
export interface IFootnoteOptions {
|
|
readonly id: number;
|
|
readonly type?: (typeof FootnoteType)[keyof typeof FootnoteType];
|
|
readonly children: readonly Paragraph[];
|
|
}
|
|
|
|
export class Footnote extends XmlComponent {
|
|
public constructor(options: IFootnoteOptions) {
|
|
super("w:footnote");
|
|
this.root.push(
|
|
new FootnoteAttributes({
|
|
type: options.type,
|
|
id: options.id,
|
|
}),
|
|
);
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|