Files
docx-js/src/file/paragraph/links/pageref-field-instruction.ts
Dolan Miu 982d923553 Improve import alias
@file/ and @export/ instead of file/ and export/ etc
2022-06-26 23:26:42 +01:00

24 lines
757 B
TypeScript

import { SpaceType } from "@file/space-type";
import { XmlComponent } from "@file/xml-components";
import { TextAttributes } from "../run/text-attributes";
import { IPageReferenceOptions } from "./pageref-properties";
export class PageReferenceFieldInstruction extends XmlComponent {
constructor(bookmarkId: string, options: IPageReferenceOptions = {}) {
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);
}
}