2022-06-26 23:26:42 +01:00
|
|
|
import { SpaceType } from "@file/space-type";
|
|
|
|
import { XmlComponent } from "@file/xml-components";
|
2021-08-03 15:58:26 +02:00
|
|
|
|
2022-06-15 00:07:12 +01:00
|
|
|
import { TextAttributes } from "../run/text-attributes";
|
|
|
|
import { IPageReferenceOptions } from "./pageref-properties";
|
2021-08-03 15:58:26 +02:00
|
|
|
|
2021-09-08 00:41:40 +01:00
|
|
|
export class PageReferenceFieldInstruction extends XmlComponent {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor(bookmarkId: string, options: IPageReferenceOptions = {}) {
|
2021-08-03 15:58:26 +02:00
|
|
|
super("w:instrText");
|
|
|
|
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
|
|
|
|
|
|
|
|
let instruction = `PAGEREF ${bookmarkId}`;
|
|
|
|
|
|
|
|
if (options.hyperlink) {
|
|
|
|
instruction = `${instruction} \\h`;
|
|
|
|
}
|
|
|
|
if (options.useRelativePosition) {
|
|
|
|
instruction = `${instruction} \\p`;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.root.push(instruction);
|
|
|
|
}
|
|
|
|
}
|