diff --git a/src/file/file-child.ts b/src/file/file-child.ts new file mode 100644 index 0000000000..005be22641 --- /dev/null +++ b/src/file/file-child.ts @@ -0,0 +1,5 @@ +import { XmlComponent } from "@file/xml-components"; + +export class FileChild extends XmlComponent { + public readonly fileChild = Symbol(); +} diff --git a/src/file/file.ts b/src/file/file.ts index 4b3f31dcdd..1fa9da3c9c 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -11,15 +11,13 @@ import { Footer, Header } from "./header"; import { HeaderWrapper, IDocumentHeader } from "./header-wrapper"; import { Media } from "./media"; import { Numbering } from "./numbering"; -import { Paragraph } from "./paragraph"; import { Comments } from "./paragraph/run/comment-run"; import { Relationships } from "./relationships"; import { Settings } from "./settings"; import { Styles } from "./styles"; import { ExternalStylesFactory } from "./styles/external-styles-factory"; import { DefaultStylesFactory } from "./styles/factory"; -import { Table } from "./table"; -import { TableOfContents } from "./table-of-contents"; +import { FileChild } from "./file-child"; export interface ISectionOptions { readonly headers?: { @@ -33,7 +31,7 @@ export interface ISectionOptions { readonly even?: Footer; }; readonly properties?: ISectionPropertiesOptions; - readonly children: readonly (Paragraph | Table | TableOfContents)[]; + readonly children: readonly FileChild[]; } export class File { diff --git a/src/file/paragraph/paragraph.ts b/src/file/paragraph/paragraph.ts index 6d8074ffa8..a12b88df6a 100644 --- a/src/file/paragraph/paragraph.ts +++ b/src/file/paragraph/paragraph.ts @@ -1,7 +1,8 @@ // http://officeopenxml.com/WPparagraph.php import { FootnoteReferenceRun } from "@file/footnotes"; -import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components"; +import { IContext, IXmlableObject } from "@file/xml-components"; import { uniqueId } from "@util/convenience-functions"; +import { FileChild } from "@file/file-child"; import { TargetModeType } from "../relationships/relationship/relationship"; import { DeletedTextRun, InsertedTextRun } from "../track-revision"; @@ -39,7 +40,7 @@ export interface IParagraphOptions extends IParagraphPropertiesOptions { readonly children?: readonly ParagraphChild[]; } -export class Paragraph extends XmlComponent { +export class Paragraph extends FileChild { private readonly properties: ParagraphProperties; public constructor(options: string | IParagraphOptions) { diff --git a/src/file/table-of-contents/table-of-contents.ts b/src/file/table-of-contents/table-of-contents.ts index 212cd4e79d..da11a28719 100644 --- a/src/file/table-of-contents/table-of-contents.ts +++ b/src/file/table-of-contents/table-of-contents.ts @@ -3,13 +3,13 @@ import { Paragraph } from "@file/paragraph"; import { Run } from "@file/paragraph/run"; import { Begin, End, Separate } from "@file/paragraph/run/field"; -import { XmlComponent } from "@file/xml-components"; +import { FileChild } from "@file/file-child"; import { FieldInstruction } from "./field-instruction"; import { StructuredDocumentTagContent } from "./sdt-content"; import { StructuredDocumentTagProperties } from "./sdt-properties"; import { ITableOfContentsOptions } from "./table-of-contents-properties"; -export class TableOfContents extends XmlComponent { +export class TableOfContents extends FileChild { public constructor(alias: string = "Table of Contents", properties?: ITableOfContentsOptions) { super("w:sdt"); this.root.push(new StructuredDocumentTagProperties(alias)); diff --git a/src/file/table/table.ts b/src/file/table/table.ts index 7f272dfe3e..4e5545b171 100644 --- a/src/file/table/table.ts +++ b/src/file/table/table.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPtableGrid.php -import { XmlComponent } from "@file/xml-components"; +import { FileChild } from "@file/file-child"; import { AlignmentType } from "../paragraph"; import { TableGrid } from "./grid"; @@ -34,7 +34,7 @@ export interface ITableOptions { readonly visuallyRightToLeft?: boolean; } -export class Table extends XmlComponent { +export class Table extends FileChild { public constructor({ rows, width,