Optional background property

This commit is contained in:
Dolan
2022-12-09 21:07:08 +00:00
parent 3ea453a07f
commit f789f60e22
2 changed files with 5 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import { DocumentAttributes } from "./document-attributes";
import { DocumentBackground, IDocumentBackgroundOptions } from "./document-background"; import { DocumentBackground, IDocumentBackgroundOptions } from "./document-background";
export interface IDocumentOptions { export interface IDocumentOptions {
readonly background: IDocumentBackgroundOptions; readonly background?: IDocumentBackgroundOptions;
} }
// <xsd:element name="document" type="CT_Document"/> // <xsd:element name="document" type="CT_Document"/>
@ -73,7 +73,9 @@ export class Document extends XmlComponent {
}), }),
); );
this.body = new Body(); this.body = new Body();
this.root.push(new DocumentBackground(options.background)); if (options.background) {
this.root.push(new DocumentBackground(options.background));
}
this.root.push(this.body); this.root.push(this.body);
} }

View File

@ -73,7 +73,7 @@ export class File {
this.appProperties = new AppProperties(); this.appProperties = new AppProperties();
this.footnotesWrapper = new FootnotesWrapper(); this.footnotesWrapper = new FootnotesWrapper();
this.contentTypes = new ContentTypes(); this.contentTypes = new ContentTypes();
this.documentWrapper = new DocumentWrapper({ background: options.background || {} }); this.documentWrapper = new DocumentWrapper({ background: options.background });
this.settings = new Settings({ this.settings = new Settings({
compatibilityModeVersion: options.compatabilityModeVersion, compatibilityModeVersion: options.compatabilityModeVersion,
compatibility: options.compatibility, compatibility: options.compatibility,