Files
docx-js/src/file/paragraph/links/pageref-field-instruction.ts
Dolan c3080ff9d9 Update vitest (#2475)
* Update vitest

* Update vite test config

* Fix coverage metrics and bump coverage
2023-12-25 02:47:43 +00:00

24 lines
749 B
TypeScript

import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";
import { TextAttributes } from "../run/text-attributes";
import { IPageReferenceOptions } from "./pageref";
export class PageReferenceFieldInstruction extends XmlComponent {
public 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);
}
}