Simplify code using Spreading
This commit is contained in:
@ -2,14 +2,7 @@ import { AppProperties } from "./app-properties/app-properties";
|
|||||||
import { ContentTypes } from "./content-types/content-types";
|
import { ContentTypes } from "./content-types/content-types";
|
||||||
import { CoreProperties, IPropertiesOptions } from "./core-properties";
|
import { CoreProperties, IPropertiesOptions } from "./core-properties";
|
||||||
import { Document } from "./document";
|
import { Document } from "./document";
|
||||||
import {
|
import { FooterReferenceType, HeaderReference, HeaderReferenceType, SectionPropertiesOptions } from "./document/body/section-properties";
|
||||||
FooterReferenceType,
|
|
||||||
HeaderReference,
|
|
||||||
HeaderReferenceType,
|
|
||||||
IFooterOptions,
|
|
||||||
IHeaderOptions,
|
|
||||||
SectionPropertiesOptions,
|
|
||||||
} from "./document/body/section-properties";
|
|
||||||
import { FooterWrapper, IDocumentFooter } from "./footer-wrapper";
|
import { FooterWrapper, IDocumentFooter } from "./footer-wrapper";
|
||||||
import { FootNotes } from "./footnotes";
|
import { FootNotes } from "./footnotes";
|
||||||
import { HeaderWrapper, IDocumentHeader } from "./header-wrapper";
|
import { HeaderWrapper, IDocumentHeader } from "./header-wrapper";
|
||||||
@ -40,7 +33,7 @@ export class File {
|
|||||||
|
|
||||||
private currentRelationshipId: number = 1;
|
private currentRelationshipId: number = 1;
|
||||||
|
|
||||||
constructor(options?: IPropertiesOptions, sectionPropertiesOptions?: SectionPropertiesOptions) {
|
constructor(options?: IPropertiesOptions, sectionPropertiesOptions: SectionPropertiesOptions = {}) {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
options = {
|
options = {
|
||||||
creator: "Un-named",
|
creator: "Un-named",
|
||||||
@ -124,31 +117,17 @@ export class File {
|
|||||||
|
|
||||||
this.footNotes = new FootNotes();
|
this.footNotes = new FootNotes();
|
||||||
|
|
||||||
const headersOptions: IHeaderOptions[] = [];
|
sectionPropertiesOptions = {
|
||||||
for (const documentHeader of this.headers) {
|
...sectionPropertiesOptions,
|
||||||
headersOptions.push({
|
headers: this.headers.map((header) => ({
|
||||||
headerId: documentHeader.header.Header.ReferenceId,
|
headerId: header.header.Header.ReferenceId,
|
||||||
headerType: documentHeader.type,
|
headerType: header.type,
|
||||||
});
|
})),
|
||||||
}
|
footers: this.footers.map((footer) => ({
|
||||||
|
footerId: footer.footer.Footer.ReferenceId,
|
||||||
const footersOptions: IFooterOptions[] = [];
|
footerType: footer.type,
|
||||||
for (const documentFooter of this.footers) {
|
})),
|
||||||
footersOptions.push({
|
};
|
||||||
footerId: documentFooter.footer.Footer.ReferenceId,
|
|
||||||
footerType: documentFooter.type,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sectionPropertiesOptions) {
|
|
||||||
sectionPropertiesOptions = {
|
|
||||||
headers: headersOptions,
|
|
||||||
footers: footersOptions,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
sectionPropertiesOptions.headers = headersOptions;
|
|
||||||
sectionPropertiesOptions.footers = footersOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.document = new Document(sectionPropertiesOptions);
|
this.document = new Document(sectionPropertiesOptions);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user