Re-name PageRef to PageReference
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { PageRefFieldInstruction } from "./pageref-field-instruction";
|
||||
import { PageReferenceFieldInstruction } from "./pageref-field-instruction";
|
||||
|
||||
describe("PageRef field instruction", () => {
|
||||
describe("PageReference field instruction", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should construct a pageref field instruction without options", () => {
|
||||
const instruction = new PageRefFieldInstruction("anchor");
|
||||
const instruction = new PageReferenceFieldInstruction("anchor");
|
||||
const tree = new Formatter().format(instruction);
|
||||
|
||||
expect(tree).to.be.deep.equal({
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { SpaceType } from "file/space-type";
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
import { IPageRefOptions } from "./pageref-properties";
|
||||
import { IPageReferenceOptions } from "./pageref-properties";
|
||||
|
||||
class TextAttributes extends XmlAttributeComponent<{ readonly space: SpaceType }> {
|
||||
protected readonly xmlKeys = { space: "xml:space" };
|
||||
}
|
||||
|
||||
export class PageRefFieldInstruction extends XmlComponent {
|
||||
constructor(bookmarkId: string, options: IPageRefOptions = {}) {
|
||||
export class PageReferenceFieldInstruction extends XmlComponent {
|
||||
constructor(bookmarkId: string, options: IPageReferenceOptions = {}) {
|
||||
super("w:instrText");
|
||||
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Options according to https://www.ecma-international.org/publications/standards/Ecma-376.htm (at Part 1, Page 1234)
|
||||
|
||||
export interface IPageRefOptions {
|
||||
export interface IPageReferenceOptions {
|
||||
/**
|
||||
* \h option - Creates a hyperlink to the bookmarked paragraph.
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { PageRef } from "./pageref";
|
||||
import { PageReference } from "./pageref";
|
||||
|
||||
describe("PageRef", () => {
|
||||
describe("PageReference", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should construct a pageref without options", () => {
|
||||
const pageref = new PageRef("some_bookmark");
|
||||
const pageref = new PageReference("some_bookmark");
|
||||
const tree = new Formatter().format(pageref);
|
||||
expect(tree).to.be.deep.equal({
|
||||
"w:r": [
|
||||
@ -40,8 +40,8 @@ describe("PageRef", () => {
|
||||
});
|
||||
|
||||
it("should construct a pageref with all the options", () => {
|
||||
const pageref = new PageRef("some_bookmark", { hyperlink: true, useRelativePosition: true });
|
||||
const tree = new Formatter().format(pageref);
|
||||
const pageReference = new PageReference("some_bookmark", { hyperlink: true, useRelativePosition: true });
|
||||
const tree = new Formatter().format(pageReference);
|
||||
expect(tree).to.be.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
// See https://www.ecma-international.org/publications/standards/Ecma-376.htm (at Part 1, Page 1234)
|
||||
import { Begin, End } from "file/paragraph/run/field";
|
||||
import { Run } from "../run";
|
||||
import { PageRefFieldInstruction } from "./pageref-field-instruction";
|
||||
import type { IPageRefOptions } from "./pageref-properties";
|
||||
import { PageReferenceFieldInstruction } from "./pageref-field-instruction";
|
||||
import type { IPageReferenceOptions } from "./pageref-properties";
|
||||
|
||||
export class PageRef extends Run {
|
||||
constructor(bookmarkId: string, options: IPageRefOptions = {}) {
|
||||
export class PageReference extends Run {
|
||||
constructor(bookmarkId: string, options: IPageReferenceOptions = {}) {
|
||||
super({
|
||||
children: [new Begin(true), new PageRefFieldInstruction(bookmarkId, options), new End()],
|
||||
children: [new Begin(true), new PageReferenceFieldInstruction(bookmarkId, options), new End()],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user