Merge pull request #1898 from dolanmiu/feat/strict-types-for-File-Child
Add strict types for file child
This commit is contained in:
5
src/file/file-child.ts
Normal file
5
src/file/file-child.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
|
export class FileChild extends XmlComponent {
|
||||||
|
public readonly fileChild = Symbol();
|
||||||
|
}
|
@ -11,15 +11,13 @@ import { Footer, Header } from "./header";
|
|||||||
import { HeaderWrapper, IDocumentHeader } from "./header-wrapper";
|
import { HeaderWrapper, IDocumentHeader } from "./header-wrapper";
|
||||||
import { Media } from "./media";
|
import { Media } from "./media";
|
||||||
import { Numbering } from "./numbering";
|
import { Numbering } from "./numbering";
|
||||||
import { Paragraph } from "./paragraph";
|
|
||||||
import { Comments } from "./paragraph/run/comment-run";
|
import { Comments } from "./paragraph/run/comment-run";
|
||||||
import { Relationships } from "./relationships";
|
import { Relationships } from "./relationships";
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./settings";
|
||||||
import { Styles } from "./styles";
|
import { Styles } from "./styles";
|
||||||
import { ExternalStylesFactory } from "./styles/external-styles-factory";
|
import { ExternalStylesFactory } from "./styles/external-styles-factory";
|
||||||
import { DefaultStylesFactory } from "./styles/factory";
|
import { DefaultStylesFactory } from "./styles/factory";
|
||||||
import { Table } from "./table";
|
import { FileChild } from "./file-child";
|
||||||
import { TableOfContents } from "./table-of-contents";
|
|
||||||
|
|
||||||
export interface ISectionOptions {
|
export interface ISectionOptions {
|
||||||
readonly headers?: {
|
readonly headers?: {
|
||||||
@ -33,7 +31,7 @@ export interface ISectionOptions {
|
|||||||
readonly even?: Footer;
|
readonly even?: Footer;
|
||||||
};
|
};
|
||||||
readonly properties?: ISectionPropertiesOptions;
|
readonly properties?: ISectionPropertiesOptions;
|
||||||
readonly children: readonly (Paragraph | Table | TableOfContents)[];
|
readonly children: readonly FileChild[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class File {
|
export class File {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// http://officeopenxml.com/WPparagraph.php
|
// http://officeopenxml.com/WPparagraph.php
|
||||||
import { FootnoteReferenceRun } from "@file/footnotes";
|
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 { uniqueId } from "@util/convenience-functions";
|
||||||
|
import { FileChild } from "@file/file-child";
|
||||||
|
|
||||||
import { TargetModeType } from "../relationships/relationship/relationship";
|
import { TargetModeType } from "../relationships/relationship/relationship";
|
||||||
import { DeletedTextRun, InsertedTextRun } from "../track-revision";
|
import { DeletedTextRun, InsertedTextRun } from "../track-revision";
|
||||||
@ -39,7 +40,7 @@ export interface IParagraphOptions extends IParagraphPropertiesOptions {
|
|||||||
readonly children?: readonly ParagraphChild[];
|
readonly children?: readonly ParagraphChild[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Paragraph extends XmlComponent {
|
export class Paragraph extends FileChild {
|
||||||
private readonly properties: ParagraphProperties;
|
private readonly properties: ParagraphProperties;
|
||||||
|
|
||||||
public constructor(options: string | IParagraphOptions) {
|
public constructor(options: string | IParagraphOptions) {
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
import { Paragraph } from "@file/paragraph";
|
import { Paragraph } from "@file/paragraph";
|
||||||
import { Run } from "@file/paragraph/run";
|
import { Run } from "@file/paragraph/run";
|
||||||
import { Begin, End, Separate } from "@file/paragraph/run/field";
|
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 { FieldInstruction } from "./field-instruction";
|
||||||
import { StructuredDocumentTagContent } from "./sdt-content";
|
import { StructuredDocumentTagContent } from "./sdt-content";
|
||||||
import { StructuredDocumentTagProperties } from "./sdt-properties";
|
import { StructuredDocumentTagProperties } from "./sdt-properties";
|
||||||
import { ITableOfContentsOptions } from "./table-of-contents-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) {
|
public constructor(alias: string = "Table of Contents", properties?: ITableOfContentsOptions) {
|
||||||
super("w:sdt");
|
super("w:sdt");
|
||||||
this.root.push(new StructuredDocumentTagProperties(alias));
|
this.root.push(new StructuredDocumentTagProperties(alias));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPtableGrid.php
|
// http://officeopenxml.com/WPtableGrid.php
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { FileChild } from "@file/file-child";
|
||||||
|
|
||||||
import { AlignmentType } from "../paragraph";
|
import { AlignmentType } from "../paragraph";
|
||||||
import { TableGrid } from "./grid";
|
import { TableGrid } from "./grid";
|
||||||
@ -34,7 +34,7 @@ export interface ITableOptions {
|
|||||||
readonly visuallyRightToLeft?: boolean;
|
readonly visuallyRightToLeft?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Table extends XmlComponent {
|
export class Table extends FileChild {
|
||||||
public constructor({
|
public constructor({
|
||||||
rows,
|
rows,
|
||||||
width,
|
width,
|
||||||
|
Reference in New Issue
Block a user