ITableOfContentsProperties to ITableOfContentsOptions
This commit is contained in:
@ -21,7 +21,7 @@ doc.Styles.createParagraphStyle("MySpectacularStyle", "My Spectacular Style")
|
||||
const toc = new TableOfContents("Summary", {
|
||||
hyperlink: true,
|
||||
headingStyleRange: "1-5",
|
||||
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)]
|
||||
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
|
||||
});
|
||||
|
||||
doc.addTableOfContents(toc);
|
||||
|
@ -1,19 +1,24 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
import { ITableOfContentsProperties } from "./table-of-contents-properties";
|
||||
import { ITableOfContentsOptions } from "./table-of-contents-properties";
|
||||
|
||||
class TextAttributes extends XmlAttributeComponent<{ space: "default" | "preserve" }> {
|
||||
enum SpaceType {
|
||||
DEFAULT = "default",
|
||||
PRESERVE = "preserve",
|
||||
}
|
||||
|
||||
class TextAttributes extends XmlAttributeComponent<{ space: SpaceType }> {
|
||||
protected xmlKeys = { space: "xml:space" };
|
||||
}
|
||||
|
||||
export class TableOfContentsInstruction extends XmlComponent {
|
||||
private readonly properties: ITableOfContentsProperties;
|
||||
private readonly properties: ITableOfContentsOptions;
|
||||
|
||||
constructor(properties: ITableOfContentsProperties = {}) {
|
||||
constructor(properties: ITableOfContentsOptions = {}) {
|
||||
super("w:instrText");
|
||||
|
||||
this.properties = properties;
|
||||
|
||||
this.root.push(new TextAttributes({ space: "preserve" }));
|
||||
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
|
||||
let instruction = "TOC";
|
||||
|
||||
if (this.properties.captionLabel) {
|
||||
|
@ -16,7 +16,7 @@ export class StyleLevel {
|
||||
* Short Guide:
|
||||
* http://officeopenxml.com/WPtableOfContents.php
|
||||
*/
|
||||
export interface ITableOfContentsProperties {
|
||||
export interface ITableOfContentsOptions {
|
||||
/**
|
||||
* \a option - Includes captioned items, but omits caption labels and numbers.
|
||||
* The identifier designated by text in this switch's field-argument corresponds to the caption label.
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "../../export/formatter";
|
||||
import { ITableOfContentsProperties, StyleLevel, TableOfContents } from "./";
|
||||
import { ITableOfContentsOptions, StyleLevel, TableOfContents } from "./";
|
||||
|
||||
describe("Table of Contents", () => {
|
||||
describe("#constructor", () => {
|
||||
@ -12,7 +12,7 @@ describe("Table of Contents", () => {
|
||||
});
|
||||
|
||||
it("should construct a TOC with all the options and alias", () => {
|
||||
const props: ITableOfContentsProperties = {};
|
||||
const props: ITableOfContentsOptions = {};
|
||||
|
||||
props.captionLabel = "A";
|
||||
props.entriesFromBookmark = "B";
|
||||
|
@ -5,10 +5,10 @@ import { XmlComponent } from "file/xml-components";
|
||||
import { SdtContent } from "./sdt-content";
|
||||
import { SdtProperties } from "./sdt-properties";
|
||||
import { TableOfContentsInstruction } from "./table-of-contents-instruction";
|
||||
import { ITableOfContentsProperties } from "./table-of-contents-properties";
|
||||
import { ITableOfContentsOptions } from "./table-of-contents-properties";
|
||||
|
||||
export class TableOfContents extends XmlComponent {
|
||||
constructor(alias: string = "Table of Contents", properties?: ITableOfContentsProperties) {
|
||||
constructor(alias: string = "Table of Contents", properties?: ITableOfContentsOptions) {
|
||||
super("w:sdt");
|
||||
this.root.push(new SdtProperties(alias));
|
||||
|
||||
|
Reference in New Issue
Block a user