From a3febae8a32c57f493d4d1c30ff3681abc83fe00 Mon Sep 17 00:00:00 2001 From: Dolan Date: Mon, 15 Mar 2021 00:11:39 +0000 Subject: [PATCH] Inline single use interfaces --- docs/usage/tables.md | 19 +++++++++---------- .../footer-reference-attributes.ts | 6 ++---- .../header-reference-attributes.ts | 6 ++---- .../title-page/title-page-attributes.ts | 6 ++---- .../doc-properties-attributes.ts | 6 ++---- .../effect-extent/effect-extent-attributes.ts | 6 ++---- src/file/drawing/extent/extent-attributes.ts | 6 ++---- .../drawing/floating/horizontal-position.ts | 6 ++---- src/file/drawing/floating/simple-pos.ts | 6 ++---- .../drawing/floating/vertical-position.ts | 6 ++---- .../graphic-frame-lock-attributes.ts | 6 ++---- .../graphic-data/graphic-data-attribute.ts | 6 ++---- .../graphic/graphic-data/pic/blip/blip.ts | 6 ++---- .../pic-locks/pic-locks-attributes.ts | 6 ++---- .../non-visual-properties-attributes.ts | 6 ++---- .../graphic-data/pic/pic-attributes.ts | 6 ++---- .../form/extents/extents-attributes.ts | 6 ++---- .../form/offset/off-attributes.ts | 6 ++---- .../preset-geometry-attributes.ts | 6 ++---- .../shape-properties-attributes.ts | 6 ++---- src/file/drawing/inline/graphic/graphic.ts | 6 ++---- src/file/drawing/inline/inline-attributes.ts | 9 +-------- src/file/drawing/text-wrap/wrap-square.ts | 4 ---- src/file/drawing/text-wrap/wrap-tight.ts | 6 ++---- .../drawing/text-wrap/wrap-top-and-bottom.ts | 6 ++---- src/file/footer/footer-attributes.ts | 6 ++---- src/file/footnotes/footnotes-attributes.ts | 6 ++---- src/file/header/header-attributes.ts | 6 ++---- src/file/numbering/level.ts | 6 ++---- .../paragraph/formatting/border-attributes.ts | 6 ++---- .../paragraph/links/bookmark-attributes.ts | 12 ++++-------- .../paragraph/run/run-components/symbol.ts | 6 ++---- src/file/relationships/attributes.ts | 6 ++---- .../relationship/relationship-attributes.ts | 6 ++---- src/file/settings/settings.ts | 6 ++---- src/file/settings/update-fields.ts | 6 +++--- src/file/styles/style/components.ts | 6 ++---- .../table-cell/cell-margin/cell-margin.ts | 6 ++---- .../table/table-cell/table-cell-components.ts | 6 ++---- .../table/table-properties/table-width.ts | 6 ++---- src/file/table/table-row/table-row-height.ts | 6 ++---- src/file/xml-components/attributes.ts | 6 ++---- 42 files changed, 91 insertions(+), 181 deletions(-) diff --git a/docs/usage/tables.md b/docs/usage/tables.md index 637efa2977..16aa8d4f7b 100644 --- a/docs/usage/tables.md +++ b/docs/usage/tables.md @@ -4,9 +4,9 @@ ## Intro -* `Tables` contain a list of `Rows` -* `Rows` contain a list of `TableCells` -* `TableCells` contain a list of `Parahraphs` and/or `Tables`. You can add `Tables` as tables can be nested inside each other +- `Tables` contain a list of `Rows` +- `Rows` contain a list of `TableCells` +- `TableCells` contain a list of `Parahraphs` and/or `Tables`. You can add `Tables` as tables can be nested inside each other Create a simple table like so: @@ -85,11 +85,11 @@ const table = new Table({ Here is a list of options you can add to the `table row`: -| Property | Type | Notes | -| ----------- | ------------------------------------- | -------- | -| children | `Array` | Required | -| cantSplit | `boolean` | Optional | -| tableHeader | `boolean` | Optional | +| Property | Type | Notes | +| ----------- | -------------------------------------- | -------- | +| children | `Array` | Required | +| cantSplit | `boolean` | Optional | +| tableHeader | `boolean` | Optional | | height | `{ height: number, rule: HeightRule }` | Optional | ### Repeat row @@ -142,7 +142,7 @@ const tableRow = new TableRow({ | Property | Type | Notes | | ------------- | ----------------------------------- | ----------------------------------------------------------- | -| children | `Array` | Required. You can nest tables by adding a table into a cell | +| children | `Array` | Required. You can nest tables by adding a table into a cell | | shading | `ITableShadingAttributesProperties` | Optional | | margins | `ITableCellMarginOptions` | Optional | | verticalAlign | `VerticalAlign` | Optional | @@ -336,7 +336,6 @@ const table = new Table({ }); ``` - ## Examples [Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/4-basic-table.ts ':include') diff --git a/src/file/document/body/section-properties/footer-reference/footer-reference-attributes.ts b/src/file/document/body/section-properties/footer-reference/footer-reference-attributes.ts index 9f725e01e0..861cc86a11 100644 --- a/src/file/document/body/section-properties/footer-reference/footer-reference-attributes.ts +++ b/src/file/document/body/section-properties/footer-reference/footer-reference-attributes.ts @@ -6,12 +6,10 @@ export enum FooterReferenceType { EVEN = "even", } -export interface IFooterReferenceAttributes { +export class FooterReferenceAttributes extends XmlAttributeComponent<{ readonly type: string; readonly id: string; -} - -export class FooterReferenceAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { type: "w:type", id: "r:id", diff --git a/src/file/document/body/section-properties/header-reference/header-reference-attributes.ts b/src/file/document/body/section-properties/header-reference/header-reference-attributes.ts index 3b0e0bff07..b46c993999 100644 --- a/src/file/document/body/section-properties/header-reference/header-reference-attributes.ts +++ b/src/file/document/body/section-properties/header-reference/header-reference-attributes.ts @@ -6,12 +6,10 @@ export enum HeaderReferenceType { EVEN = "even", } -export interface IHeaderReferenceAttributes { +export class HeaderReferenceAttributes extends XmlAttributeComponent<{ readonly type: string; readonly id: string; -} - -export class HeaderReferenceAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { type: "w:type", id: "r:id", diff --git a/src/file/document/body/section-properties/title-page/title-page-attributes.ts b/src/file/document/body/section-properties/title-page/title-page-attributes.ts index 00da3f7c58..078b6ed47f 100644 --- a/src/file/document/body/section-properties/title-page/title-page-attributes.ts +++ b/src/file/document/body/section-properties/title-page/title-page-attributes.ts @@ -1,10 +1,8 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IHeaderReferenceAttributes { +export class TitlePageAttributes extends XmlAttributeComponent<{ readonly value: string; -} - -export class TitlePageAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { value: "w:val", }; diff --git a/src/file/drawing/doc-properties/doc-properties-attributes.ts b/src/file/drawing/doc-properties/doc-properties-attributes.ts index 9e80e65935..69771d0472 100644 --- a/src/file/drawing/doc-properties/doc-properties-attributes.ts +++ b/src/file/drawing/doc-properties/doc-properties-attributes.ts @@ -1,12 +1,10 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IDocPropertiesAttributes { +export class DocPropertiesAttributes extends XmlAttributeComponent<{ readonly id?: number; readonly name?: string; readonly descr?: string; -} - -export class DocPropertiesAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { id: "id", name: "name", diff --git a/src/file/drawing/effect-extent/effect-extent-attributes.ts b/src/file/drawing/effect-extent/effect-extent-attributes.ts index eccd38daf3..4c9986d486 100644 --- a/src/file/drawing/effect-extent/effect-extent-attributes.ts +++ b/src/file/drawing/effect-extent/effect-extent-attributes.ts @@ -1,13 +1,11 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IEffectExtentAttributes { +export class EffectExtentAttributes extends XmlAttributeComponent<{ readonly b?: number; readonly l?: number; readonly r?: number; readonly t?: number; -} - -export class EffectExtentAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { b: "b", l: "l", diff --git a/src/file/drawing/extent/extent-attributes.ts b/src/file/drawing/extent/extent-attributes.ts index cae1324285..6f0562fab6 100644 --- a/src/file/drawing/extent/extent-attributes.ts +++ b/src/file/drawing/extent/extent-attributes.ts @@ -1,11 +1,9 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IExtentAttributes { +export class ExtentAttributes extends XmlAttributeComponent<{ readonly cx?: number; readonly cy?: number; -} - -export class ExtentAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { cx: "cx", cy: "cy", diff --git a/src/file/drawing/floating/horizontal-position.ts b/src/file/drawing/floating/horizontal-position.ts index 64f3e38e74..c083392f5f 100644 --- a/src/file/drawing/floating/horizontal-position.ts +++ b/src/file/drawing/floating/horizontal-position.ts @@ -4,11 +4,9 @@ import { Align } from "./align"; import { HorizontalPositionRelativeFrom, IHorizontalPositionOptions } from "./floating-position"; import { PositionOffset } from "./position-offset"; -interface IHorizontalPositionAttributes { +class HorizontalPositionAttributes extends XmlAttributeComponent<{ readonly relativeFrom: HorizontalPositionRelativeFrom; -} - -class HorizontalPositionAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { relativeFrom: "relativeFrom", }; diff --git a/src/file/drawing/floating/simple-pos.ts b/src/file/drawing/floating/simple-pos.ts index 0e0fedcdc6..0a82e12693 100644 --- a/src/file/drawing/floating/simple-pos.ts +++ b/src/file/drawing/floating/simple-pos.ts @@ -1,12 +1,10 @@ // http://officeopenxml.com/drwPicFloating-position.php import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; -interface ISimplePosAttributes { +class SimplePosAttributes extends XmlAttributeComponent<{ readonly x: number; readonly y: number; -} - -class SimplePosAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { x: "x", y: "y", diff --git a/src/file/drawing/floating/vertical-position.ts b/src/file/drawing/floating/vertical-position.ts index bc4f6febe6..830306b237 100644 --- a/src/file/drawing/floating/vertical-position.ts +++ b/src/file/drawing/floating/vertical-position.ts @@ -4,11 +4,9 @@ import { Align } from "./align"; import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floating-position"; import { PositionOffset } from "./position-offset"; -interface IVerticalPositionAttributes { +class VerticalPositionAttributes extends XmlAttributeComponent<{ readonly relativeFrom: VerticalPositionRelativeFrom; -} - -class VerticalPositionAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { relativeFrom: "relativeFrom", }; diff --git a/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-lock-attributes.ts b/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-lock-attributes.ts index 5ba96eabec..ec57ceb4ae 100644 --- a/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-lock-attributes.ts +++ b/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-lock-attributes.ts @@ -1,11 +1,9 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IGraphicFrameLockAttributes { +export class GraphicFrameLockAttributes extends XmlAttributeComponent<{ readonly xmlns?: string; readonly noChangeAspect?: number; -} - -export class GraphicFrameLockAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { xmlns: "xmlns:a", noChangeAspect: "noChangeAspect", diff --git a/src/file/drawing/inline/graphic/graphic-data/graphic-data-attribute.ts b/src/file/drawing/inline/graphic/graphic-data/graphic-data-attribute.ts index 9293950537..5c7fa30e34 100644 --- a/src/file/drawing/inline/graphic/graphic-data/graphic-data-attribute.ts +++ b/src/file/drawing/inline/graphic/graphic-data/graphic-data-attribute.ts @@ -1,10 +1,8 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IGraphicDataAttributes { +export class GraphicDataAttributes extends XmlAttributeComponent<{ readonly uri?: string; -} - -export class GraphicDataAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { uri: "uri", }; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts index f45b4d8316..4460affa73 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts @@ -1,12 +1,10 @@ import { IMediaData } from "file/media"; import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; -interface IBlipProperties { +class BlipAttributes extends XmlAttributeComponent<{ readonly embed: string; readonly cstate: string; -} - -class BlipAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { embed: "r:embed", cstate: "cstate", diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks-attributes.ts index e8902814af..c544d8ccfc 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks-attributes.ts @@ -1,11 +1,9 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IPicLocksAttributes { +export class PicLocksAttributes extends XmlAttributeComponent<{ readonly noChangeAspect?: number; readonly noChangeArrowheads?: number; -} - -export class PicLocksAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { noChangeAspect: "noChangeAspect", noChangeArrowheads: "noChangeArrowheads", diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts index 86845c5825..cac3312dde 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts @@ -1,12 +1,10 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface INonVisualPropertiesAttributes { +export class NonVisualPropertiesAttributes extends XmlAttributeComponent<{ readonly id?: number; readonly name?: string; readonly descr?: string; -} - -export class NonVisualPropertiesAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { id: "id", name: "name", diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/pic-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/pic-attributes.ts index 9aec0c1d57..00cc5b7cc2 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/pic-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/pic-attributes.ts @@ -1,10 +1,8 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IPicAttributes { +export class PicAttributes extends XmlAttributeComponent<{ readonly xmlns?: string; -} - -export class PicAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { xmlns: "xmlns:pic", }; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents-attributes.ts index 6f3eecfde3..db957965f5 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents-attributes.ts @@ -1,11 +1,9 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IExtentsAttributes { +export class ExtentsAttributes extends XmlAttributeComponent<{ readonly cx?: number; readonly cy?: number; -} - -export class ExtentsAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { cx: "cx", cy: "cy", diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off-attributes.ts index 03123b86c1..5dd6a1d071 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off-attributes.ts @@ -1,11 +1,9 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IOffsetAttributes { +export class OffsetAttributes extends XmlAttributeComponent<{ readonly x?: number; readonly y?: number; -} - -export class OffsetAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { x: "x", y: "y", diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry-attributes.ts index 912619e569..85d9626a91 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry-attributes.ts @@ -1,10 +1,8 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IPresetGeometryAttributes { +export class PresetGeometryAttributes extends XmlAttributeComponent<{ readonly prst?: string; -} - -export class PresetGeometryAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { prst: "prst", }; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties-attributes.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties-attributes.ts index c063881f1d..c39c466b3c 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties-attributes.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties-attributes.ts @@ -1,10 +1,8 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IShapePropertiesAttributes { +export class ShapePropertiesAttributes extends XmlAttributeComponent<{ readonly bwMode?: string; -} - -export class ShapePropertiesAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { bwMode: "bwMode", }; diff --git a/src/file/drawing/inline/graphic/graphic.ts b/src/file/drawing/inline/graphic/graphic.ts index 52d11d8e42..0e124cd63d 100644 --- a/src/file/drawing/inline/graphic/graphic.ts +++ b/src/file/drawing/inline/graphic/graphic.ts @@ -3,11 +3,9 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { GraphicData } from "./graphic-data"; -interface IGraphicProperties { +class GraphicAttributes extends XmlAttributeComponent<{ readonly a: string; -} - -class GraphicAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { a: "xmlns:a", }; diff --git a/src/file/drawing/inline/inline-attributes.ts b/src/file/drawing/inline/inline-attributes.ts index 4790e4d1fd..2220fc8493 100644 --- a/src/file/drawing/inline/inline-attributes.ts +++ b/src/file/drawing/inline/inline-attributes.ts @@ -2,14 +2,7 @@ import { XmlAttributeComponent } from "file/xml-components"; import { IDistance } from "../drawing"; // distT, distB etc have no effect on inline images, only floating -export interface IInlineAttributes extends IDistance { - readonly distT?: number; - readonly distB?: number; - readonly distL?: number; - readonly distR?: number; -} - -export class InlineAttributes extends XmlAttributeComponent { +export class InlineAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { distT: "distT", distB: "distB", diff --git a/src/file/drawing/text-wrap/wrap-square.ts b/src/file/drawing/text-wrap/wrap-square.ts index eec5baff55..5bd4948572 100644 --- a/src/file/drawing/text-wrap/wrap-square.ts +++ b/src/file/drawing/text-wrap/wrap-square.ts @@ -6,10 +6,6 @@ import { IMargins } from "../floating"; interface IWrapSquareAttributes extends IDistance { readonly wrapText?: TextWrappingSide; - readonly distT?: number; - readonly distB?: number; - readonly distL?: number; - readonly distR?: number; } class WrapSquareAttributes extends XmlAttributeComponent { diff --git a/src/file/drawing/text-wrap/wrap-tight.ts b/src/file/drawing/text-wrap/wrap-tight.ts index c2833ab4a3..c652d81c18 100644 --- a/src/file/drawing/text-wrap/wrap-tight.ts +++ b/src/file/drawing/text-wrap/wrap-tight.ts @@ -3,12 +3,10 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { IMargins } from "../floating"; -interface IWrapTightAttributes { +class WrapTightAttributes extends XmlAttributeComponent<{ readonly distT?: number; readonly distB?: number; -} - -class WrapTightAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { distT: "distT", distB: "distB", diff --git a/src/file/drawing/text-wrap/wrap-top-and-bottom.ts b/src/file/drawing/text-wrap/wrap-top-and-bottom.ts index 0333b31624..261559b325 100644 --- a/src/file/drawing/text-wrap/wrap-top-and-bottom.ts +++ b/src/file/drawing/text-wrap/wrap-top-and-bottom.ts @@ -3,12 +3,10 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { IMargins } from "../floating"; -interface IWrapTopAndBottomAttributes { +class WrapTopAndBottomAttributes extends XmlAttributeComponent<{ readonly distT?: number; readonly distB?: number; -} - -class WrapTopAndBottomAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { distT: "distT", distB: "distB", diff --git a/src/file/footer/footer-attributes.ts b/src/file/footer/footer-attributes.ts index 68df02b4eb..db7bdb03d8 100644 --- a/src/file/footer/footer-attributes.ts +++ b/src/file/footer/footer-attributes.ts @@ -1,6 +1,6 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IFooterAttributesProperties { +export class FooterAttributes extends XmlAttributeComponent<{ readonly wpc?: string; readonly mc?: string; readonly o?: string; @@ -23,9 +23,7 @@ export interface IFooterAttributesProperties { readonly dcmitype?: string; readonly xsi?: string; readonly type?: string; -} - -export class FooterAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { wpc: "xmlns:wpc", mc: "xmlns:mc", diff --git a/src/file/footnotes/footnotes-attributes.ts b/src/file/footnotes/footnotes-attributes.ts index fbd946afc2..59690ff23d 100644 --- a/src/file/footnotes/footnotes-attributes.ts +++ b/src/file/footnotes/footnotes-attributes.ts @@ -1,6 +1,6 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IFootnotesAttributesProperties { +export class FootnotesAttributes extends XmlAttributeComponent<{ readonly wpc?: string; readonly mc?: string; readonly o?: string; @@ -18,9 +18,7 @@ export interface IFootnotesAttributesProperties { readonly wne?: string; readonly wps?: string; readonly Ignorable?: string; -} - -export class FootnotesAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { wpc: "xmlns:wpc", mc: "xmlns:mc", diff --git a/src/file/header/header-attributes.ts b/src/file/header/header-attributes.ts index a34e9c8a0a..8ccb49c7d2 100644 --- a/src/file/header/header-attributes.ts +++ b/src/file/header/header-attributes.ts @@ -1,6 +1,6 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IHeaderAttributesProperties { +export class HeaderAttributes extends XmlAttributeComponent<{ readonly wpc?: string; readonly mc?: string; readonly o?: string; @@ -34,9 +34,7 @@ export interface IHeaderAttributesProperties { readonly cx8?: string; readonly w16cid: string; readonly w16se: string; -} - -export class HeaderAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { wpc: "xmlns:wpc", mc: "xmlns:mc", diff --git a/src/file/numbering/level.ts b/src/file/numbering/level.ts index 22ff07acf3..08f96c1610 100644 --- a/src/file/numbering/level.ts +++ b/src/file/numbering/level.ts @@ -21,12 +21,10 @@ export enum LevelFormat { UPPER_ROMAN = "upperRoman", } -interface ILevelAttributesProperties { +class LevelAttributes extends XmlAttributeComponent<{ readonly ilvl?: number; readonly tentative?: number; -} - -class LevelAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { ilvl: "w:ilvl", tentative: "w15:tentative", diff --git a/src/file/paragraph/formatting/border-attributes.ts b/src/file/paragraph/formatting/border-attributes.ts index d389f7adc7..304128426b 100644 --- a/src/file/paragraph/formatting/border-attributes.ts +++ b/src/file/paragraph/formatting/border-attributes.ts @@ -1,13 +1,11 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IBorderAttributesProperties { +export class BorderAttributes extends XmlAttributeComponent<{ readonly color: string; readonly space: number; readonly val: string; readonly sz: number; -} - -export class BorderAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { val: "w:val", color: "w:color", diff --git a/src/file/paragraph/links/bookmark-attributes.ts b/src/file/paragraph/links/bookmark-attributes.ts index 3858b5c464..1d856ff404 100644 --- a/src/file/paragraph/links/bookmark-attributes.ts +++ b/src/file/paragraph/links/bookmark-attributes.ts @@ -1,22 +1,18 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IBookmarkStartAttributesProperties { +export class BookmarkStartAttributes extends XmlAttributeComponent<{ readonly id: string; readonly name: string; -} - -export class BookmarkStartAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { id: "w:id", name: "w:name", }; } -export interface IBookmarkEndAttributesProperties { +export class BookmarkEndAttributes extends XmlAttributeComponent<{ readonly id: string; -} - -export class BookmarkEndAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { id: "w:id", }; diff --git a/src/file/paragraph/run/run-components/symbol.ts b/src/file/paragraph/run/run-components/symbol.ts index dff2e7c39b..e5350cd998 100644 --- a/src/file/paragraph/run/run-components/symbol.ts +++ b/src/file/paragraph/run/run-components/symbol.ts @@ -1,11 +1,9 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; -interface ISymbolAttributesProperties { +class SymbolAttributes extends XmlAttributeComponent<{ readonly char: string; readonly symbolfont?: string; -} - -class SymbolAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { char: "w:char", symbolfont: "w:font", diff --git a/src/file/relationships/attributes.ts b/src/file/relationships/attributes.ts index c0e6ead4a1..5aba4b730a 100644 --- a/src/file/relationships/attributes.ts +++ b/src/file/relationships/attributes.ts @@ -1,10 +1,8 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IRelationshipsAttributesProperties { +export class RelationshipsAttributes extends XmlAttributeComponent<{ readonly xmlns: string; -} - -export class RelationshipsAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { xmlns: "xmlns", }; diff --git a/src/file/relationships/relationship/relationship-attributes.ts b/src/file/relationships/relationship/relationship-attributes.ts index 98cbacbdae..8b9db06240 100644 --- a/src/file/relationships/relationship/relationship-attributes.ts +++ b/src/file/relationships/relationship/relationship-attributes.ts @@ -1,13 +1,11 @@ import { XmlAttributeComponent } from "file/xml-components"; -export interface IRelationshipAttributesProperties { +export class RelationshipAttributes extends XmlAttributeComponent<{ readonly id: string; readonly type: string; readonly target: string; readonly targetMode?: string; -} - -export class RelationshipAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { id: "Id", type: "Type", diff --git a/src/file/settings/settings.ts b/src/file/settings/settings.ts index e63d539a39..352c86b23f 100644 --- a/src/file/settings/settings.ts +++ b/src/file/settings/settings.ts @@ -4,7 +4,7 @@ import { DisplayBackgroundShape } from "./display-background-shape"; import { TrackRevisions } from "./track-revisions"; import { UpdateFields } from "./update-fields"; -export interface ISettingsAttributesProperties { +export class SettingsAttributes extends XmlAttributeComponent<{ readonly wpc?: string; readonly mc?: string; readonly o?: string; @@ -22,9 +22,7 @@ export interface ISettingsAttributesProperties { readonly wne?: string; readonly wps?: string; readonly Ignorable?: string; -} - -export class SettingsAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { wpc: "xmlns:wpc", mc: "xmlns:mc", diff --git a/src/file/settings/update-fields.ts b/src/file/settings/update-fields.ts index 8cb013ce0d..47a2ec6e18 100644 --- a/src/file/settings/update-fields.ts +++ b/src/file/settings/update-fields.ts @@ -1,8 +1,8 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; -export interface IUpdateFieldsAttributesProperties { + +export class UpdateFieldsAttributes extends XmlAttributeComponent<{ readonly enabled: boolean; -} -export class UpdateFieldsAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { enabled: "w:val", }; diff --git a/src/file/styles/style/components.ts b/src/file/styles/style/components.ts index a051a75005..e8a217c638 100644 --- a/src/file/styles/style/components.ts +++ b/src/file/styles/style/components.ts @@ -1,11 +1,9 @@ // http://officeopenxml.com/WPstyleGenProps.php import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; -interface IComponentAttributes { +class ComponentAttributes extends XmlAttributeComponent<{ readonly val: string | number; -} - -class ComponentAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { val: "w:val" }; } diff --git a/src/file/table/table-cell/cell-margin/cell-margin.ts b/src/file/table/table-cell/cell-margin/cell-margin.ts index 416d4e3ad2..090f83367a 100644 --- a/src/file/table/table-cell/cell-margin/cell-margin.ts +++ b/src/file/table/table-cell/cell-margin/cell-margin.ts @@ -1,12 +1,10 @@ // http://officeopenxml.com/WPtableCellProperties-Margins.php import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; -export interface ICellMarginProperties { +class CellMarginAttributes extends XmlAttributeComponent<{ readonly type: string; readonly width: number; -} - -class CellMarginAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { width: "w:w", type: "w:type" }; } diff --git a/src/file/table/table-cell/table-cell-components.ts b/src/file/table/table-cell/table-cell-components.ts index f3ebe570e9..41858d4e17 100644 --- a/src/file/table/table-cell/table-cell-components.ts +++ b/src/file/table/table-cell/table-cell-components.ts @@ -1,13 +1,11 @@ import { BorderStyle } from "file/styles"; import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent, XmlComponent } from "file/xml-components"; -interface ICellBorder { +class CellBorderAttributes extends XmlAttributeComponent<{ readonly style: BorderStyle; readonly size: number; readonly color: string; -} - -class CellBorderAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { style: "w:val", size: "w:sz", color: "w:color" }; } diff --git a/src/file/table/table-properties/table-width.ts b/src/file/table/table-properties/table-width.ts index 44468c744d..1b86125e90 100644 --- a/src/file/table/table-properties/table-width.ts +++ b/src/file/table/table-properties/table-width.ts @@ -3,12 +3,10 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { WidthType } from "../table-cell"; -interface ITableWidth { +class TableWidthAttributes extends XmlAttributeComponent<{ readonly type: WidthType; readonly w: number | string; -} - -class TableWidthAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { type: "w:type", w: "w:w" }; } diff --git a/src/file/table/table-row/table-row-height.ts b/src/file/table/table-row/table-row-height.ts index 79e4266201..6803d9b17e 100644 --- a/src/file/table/table-row/table-row-height.ts +++ b/src/file/table/table-row/table-row-height.ts @@ -9,12 +9,10 @@ export enum HeightRule { EXACT = "exact", } -interface ITableRowHeight { +export class TableRowHeightAttributes extends XmlAttributeComponent<{ readonly value: number; readonly rule: HeightRule; -} - -export class TableRowHeightAttributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { value: "w:val", rule: "w:hRule" }; } diff --git a/src/file/xml-components/attributes.ts b/src/file/xml-components/attributes.ts index 703ee1a679..0af2238196 100644 --- a/src/file/xml-components/attributes.ts +++ b/src/file/xml-components/attributes.ts @@ -1,6 +1,6 @@ import { XmlAttributeComponent } from "./default-attributes"; -export interface IAttributesProperties { +export class Attributes extends XmlAttributeComponent<{ readonly val?: string | number | boolean; readonly color?: string; readonly fill?: string; @@ -21,9 +21,7 @@ export interface IAttributesProperties { readonly gutter?: string; readonly linePitch?: string; readonly pos?: string | number; // Little strange. Perhaps it is normal. Need to clarify in the spec. -} - -export class Attributes extends XmlAttributeComponent { +}> { protected readonly xmlKeys = { val: "w:val", color: "w:color",