docx 7.4.1 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/build/export/packer/image-replacer.d.ts +2 -2
- package/build/export/packer/numbering-replacer.d.ts +1 -1
- package/build/export/packer/packer.d.ts +4 -0
- package/build/file/core-properties/properties.d.ts +3 -3
- package/build/file/custom-properties/custom-properties.d.ts +1 -1
- package/build/file/document/body/section-properties/properties/columns.d.ts +1 -1
- package/build/file/drawing/text-wrap/wrap-square.d.ts +1 -1
- package/build/file/file.d.ts +3 -3
- package/build/file/footnotes/footnote/footnote.d.ts +1 -1
- package/build/file/footnotes/footnotes.d.ts +1 -1
- package/build/file/header.d.ts +1 -1
- package/build/file/numbering/abstract-numbering.d.ts +1 -1
- package/build/file/numbering/level.d.ts +2 -2
- package/build/file/numbering/numbering.d.ts +4 -4
- package/build/file/paragraph/formatting/tab-stop.d.ts +7 -2
- package/build/file/paragraph/links/bookmark.d.ts +2 -2
- package/build/file/paragraph/links/hyperlink.d.ts +5 -5
- package/build/file/paragraph/math/brackets/math-angled-brackets.d.ts +1 -1
- package/build/file/paragraph/math/brackets/math-curly-brackets.d.ts +1 -1
- package/build/file/paragraph/math/brackets/math-round-brackets.d.ts +1 -1
- package/build/file/paragraph/math/brackets/math-square-brackets.d.ts +1 -1
- package/build/file/paragraph/math/fraction/math-denominator.d.ts +1 -1
- package/build/file/paragraph/math/fraction/math-fraction.d.ts +2 -2
- package/build/file/paragraph/math/fraction/math-numerator.d.ts +1 -1
- package/build/file/paragraph/math/function/math-function-name.d.ts +1 -1
- package/build/file/paragraph/math/function/math-function.d.ts +2 -2
- package/build/file/paragraph/math/math-component.d.ts +2 -2
- package/build/file/paragraph/math/math.d.ts +1 -1
- package/build/file/paragraph/math/n-ary/index.d.ts +1 -0
- package/build/file/paragraph/math/n-ary/math-base.d.ts +1 -1
- package/build/file/paragraph/math/n-ary/math-integral.d.ts +10 -0
- package/build/file/paragraph/math/n-ary/math-sub-script.d.ts +1 -1
- package/build/file/paragraph/math/n-ary/math-sum.d.ts +3 -3
- package/build/file/paragraph/math/n-ary/math-super-script.d.ts +1 -1
- package/build/file/paragraph/math/radical/math-degree.d.ts +1 -1
- package/build/file/paragraph/math/radical/math-radical.d.ts +2 -2
- package/build/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.d.ts +3 -3
- package/build/file/paragraph/math/script/sub-script/math-sub-script-function.d.ts +2 -2
- package/build/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.d.ts +3 -3
- package/build/file/paragraph/math/script/super-script/math-super-script-function.d.ts +2 -2
- package/build/file/paragraph/paragraph.d.ts +1 -1
- package/build/file/paragraph/properties.d.ts +2 -6
- package/build/file/paragraph/run/comment-run.d.ts +1 -1
- package/build/file/paragraph/run/run.d.ts +1 -1
- package/build/file/styles/sample/default-style.d.ts +1 -102
- package/build/file/styles/styles.d.ts +3 -3
- package/build/file/table/grid.d.ts +1 -1
- package/build/file/table/table-cell/table-cell.d.ts +1 -1
- package/build/file/table/table-row/table-row.d.ts +2 -2
- package/build/file/table/table.d.ts +2 -2
- package/build/file/table-of-contents/table-of-contents-properties.d.ts +1 -1
- package/build/file/xml-components/default-attributes.d.ts +3 -3
- package/build/file/xml-components/imported-xml-component.d.ts +2 -2
- package/build/index.js +1 -1
- package/build/index.js.LICENSE.txt +0 -12
- package/build/util/values.d.ts +17 -17
- package/package.json +15 -8
- package/src/export/packer/image-replacer.ts +2 -2
- package/src/export/packer/next-compiler.spec.ts +2 -2
- package/src/export/packer/next-compiler.ts +8 -8
- package/src/export/packer/numbering-replacer.ts +1 -1
- package/src/export/packer/packer.spec.ts +65 -7
- package/src/export/packer/packer.ts +24 -0
- package/src/file/app-properties/app-properties.ts +1 -1
- package/src/file/border/border.ts +1 -1
- package/src/file/content-types/content-types.ts +1 -1
- package/src/file/content-types/default/default.ts +1 -1
- package/src/file/content-types/override/override.ts +1 -1
- package/src/file/core-properties/properties.ts +5 -5
- package/src/file/custom-properties/custom-properties.ts +4 -2
- package/src/file/custom-properties/custom-property.ts +2 -2
- package/src/file/document/body/body.ts +3 -1
- package/src/file/document/body/section-properties/properties/column.ts +1 -1
- package/src/file/document/body/section-properties/properties/columns.spec.ts +7 -0
- package/src/file/document/body/section-properties/properties/columns.ts +2 -2
- package/src/file/document/body/section-properties/properties/doc-grid.ts +1 -1
- package/src/file/document/body/section-properties/properties/header-footer-reference.ts +1 -1
- package/src/file/document/body/section-properties/properties/line-number.ts +1 -1
- package/src/file/document/body/section-properties/properties/page-borders.ts +1 -1
- package/src/file/document/body/section-properties/properties/page-margin.ts +1 -1
- package/src/file/document/body/section-properties/properties/page-number.ts +1 -1
- package/src/file/document/body/section-properties/properties/page-size.ts +1 -1
- package/src/file/document/body/section-properties/properties/page-text-direction.ts +1 -1
- package/src/file/document/body/section-properties/properties/section-type.ts +1 -1
- package/src/file/document/body/section-properties/section-properties.ts +1 -1
- package/src/file/document/document-background/document-background.ts +1 -1
- package/src/file/document/document.ts +1 -1
- package/src/file/document-wrapper.spec.ts +0 -2
- package/src/file/document-wrapper.ts +1 -1
- package/src/file/drawing/anchor/anchor.spec.ts +2 -3
- package/src/file/drawing/anchor/anchor.ts +1 -1
- package/src/file/drawing/doc-properties/doc-properties.ts +1 -1
- package/src/file/drawing/drawing.spec.ts +2 -3
- package/src/file/drawing/drawing.ts +1 -1
- package/src/file/drawing/effect-extent/effect-extent.ts +1 -1
- package/src/file/drawing/extent/extent.ts +1 -1
- package/src/file/drawing/floating/align.ts +1 -1
- package/src/file/drawing/floating/horizontal-position.ts +1 -1
- package/src/file/drawing/floating/position-offset.ts +1 -1
- package/src/file/drawing/floating/simple-pos.ts +1 -1
- package/src/file/drawing/floating/vertical-position.ts +1 -1
- package/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-locks.ts +1 -1
- package/src/file/drawing/graphic-frame/graphic-frame-properties.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts +2 -2
- package/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/child-non-visual-pic-properties.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/no-fill.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/adjustment-values/adjustment-values.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts +1 -1
- package/src/file/drawing/inline/graphic/graphic.ts +1 -1
- package/src/file/drawing/inline/inline.ts +1 -1
- package/src/file/drawing/text-wrap/wrap-none.ts +1 -1
- package/src/file/drawing/text-wrap/wrap-square.ts +3 -2
- package/src/file/drawing/text-wrap/wrap-tight.ts +1 -1
- package/src/file/drawing/text-wrap/wrap-top-and-bottom.ts +1 -1
- package/src/file/file.spec.ts +55 -2
- package/src/file/file.ts +18 -13
- package/src/file/footer/footer.ts +1 -1
- package/src/file/footer-wrapper.spec.ts +1 -1
- package/src/file/footer-wrapper.ts +1 -1
- package/src/file/footnotes/footnote/footnote.ts +2 -2
- package/src/file/footnotes/footnote/run/continuation-seperator-run.ts +1 -1
- package/src/file/footnotes/footnote/run/continuation-seperator.ts +1 -1
- package/src/file/footnotes/footnote/run/footnote-ref-run.ts +1 -1
- package/src/file/footnotes/footnote/run/footnote-ref.ts +1 -1
- package/src/file/footnotes/footnote/run/reference-run.ts +2 -2
- package/src/file/footnotes/footnote/run/seperator-run.ts +1 -1
- package/src/file/footnotes/footnote/run/seperator.ts +1 -1
- package/src/file/footnotes/footnotes.ts +2 -2
- package/src/file/footnotes-wrapper.spec.ts +0 -2
- package/src/file/footnotes-wrapper.ts +1 -1
- package/src/file/header/header.ts +1 -1
- package/src/file/header-wrapper.spec.ts +1 -1
- package/src/file/header-wrapper.ts +1 -1
- package/src/file/header.ts +11 -3
- package/src/file/media/media.spec.ts +4 -2
- package/src/file/media/media.ts +3 -1
- package/src/file/numbering/abstract-numbering.ts +1 -1
- package/src/file/numbering/level.spec.ts +40 -3
- package/src/file/numbering/level.ts +27 -8
- package/src/file/numbering/multi-level-type.ts +1 -1
- package/src/file/numbering/num.ts +4 -4
- package/src/file/numbering/numbering.spec.ts +2 -1
- package/src/file/numbering/numbering.ts +18 -18
- package/src/file/paragraph/formatting/alignment.ts +1 -1
- package/src/file/paragraph/formatting/border.ts +2 -2
- package/src/file/paragraph/formatting/break.ts +4 -4
- package/src/file/paragraph/formatting/indent.ts +1 -1
- package/src/file/paragraph/formatting/spacing.ts +1 -1
- package/src/file/paragraph/formatting/style.ts +1 -1
- package/src/file/paragraph/formatting/tab-stop.spec.ts +2 -2
- package/src/file/paragraph/formatting/tab-stop.ts +14 -5
- package/src/file/paragraph/formatting/unordered-list.ts +3 -3
- package/src/file/paragraph/frame/frame-properties.ts +1 -1
- package/src/file/paragraph/links/bookmark.ts +4 -4
- package/src/file/paragraph/links/hyperlink.ts +6 -4
- package/src/file/paragraph/links/outline-level.ts +1 -1
- package/src/file/paragraph/links/pageref-field-instruction.ts +1 -1
- package/src/file/paragraph/links/pageref.ts +1 -1
- package/src/file/paragraph/math/brackets/math-angled-brackets.ts +1 -1
- package/src/file/paragraph/math/brackets/math-beginning-character.ts +1 -1
- package/src/file/paragraph/math/brackets/math-bracket-properties.ts +1 -1
- package/src/file/paragraph/math/brackets/math-curly-brackets.ts +1 -1
- package/src/file/paragraph/math/brackets/math-ending-char.ts +1 -1
- package/src/file/paragraph/math/brackets/math-round-brackets.ts +1 -1
- package/src/file/paragraph/math/brackets/math-square-brackets.ts +1 -1
- package/src/file/paragraph/math/fraction/math-denominator.ts +1 -1
- package/src/file/paragraph/math/fraction/math-fraction.ts +3 -3
- package/src/file/paragraph/math/fraction/math-numerator.ts +1 -1
- package/src/file/paragraph/math/function/math-function-name.ts +1 -1
- package/src/file/paragraph/math/function/math-function-properties.ts +1 -1
- package/src/file/paragraph/math/function/math-function.ts +3 -3
- package/src/file/paragraph/math/math-component.ts +2 -1
- package/src/file/paragraph/math/math-run.ts +1 -1
- package/src/file/paragraph/math/math-text.ts +1 -1
- package/src/file/paragraph/math/math.ts +2 -2
- package/src/file/paragraph/math/n-ary/index.ts +1 -0
- package/src/file/paragraph/math/n-ary/math-accent-character.ts +1 -1
- package/src/file/paragraph/math/n-ary/math-base.ts +1 -1
- package/src/file/paragraph/math/n-ary/math-integral.spec.ts +116 -0
- package/src/file/paragraph/math/n-ary/math-integral.ts +31 -0
- package/src/file/paragraph/math/n-ary/math-limit-location.ts +1 -1
- package/src/file/paragraph/math/n-ary/math-n-ary-properties.ts +4 -2
- package/src/file/paragraph/math/n-ary/math-sub-script-hide.ts +1 -1
- package/src/file/paragraph/math/n-ary/math-sub-script.ts +1 -1
- package/src/file/paragraph/math/n-ary/math-sum.ts +4 -4
- package/src/file/paragraph/math/n-ary/math-super-script-hide.ts +1 -1
- package/src/file/paragraph/math/n-ary/math-super-script.ts +1 -1
- package/src/file/paragraph/math/radical/math-degree-hide.ts +1 -1
- package/src/file/paragraph/math/radical/math-degree.ts +1 -1
- package/src/file/paragraph/math/radical/math-radical-properties.ts +1 -1
- package/src/file/paragraph/math/radical/math-radical.ts +3 -3
- package/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function-properties.ts +1 -1
- package/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts +4 -4
- package/src/file/paragraph/math/script/sub-script/math-sub-script-function-properties.ts +1 -1
- package/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts +3 -3
- package/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function-properties.ts +1 -1
- package/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts +4 -4
- package/src/file/paragraph/math/script/super-script/math-super-script-function-properties.ts +1 -1
- package/src/file/paragraph/math/script/super-script/math-super-script-function.ts +3 -3
- package/src/file/paragraph/paragraph.spec.ts +2 -6
- package/src/file/paragraph/paragraph.ts +2 -2
- package/src/file/paragraph/properties.spec.ts +1 -3
- package/src/file/paragraph/properties.ts +18 -18
- package/src/file/paragraph/run/break.ts +1 -1
- package/src/file/paragraph/run/comment-run.ts +6 -6
- package/src/file/paragraph/run/emphasis-mark.ts +2 -2
- package/src/file/paragraph/run/field.ts +3 -3
- package/src/file/paragraph/run/formatting.ts +4 -4
- package/src/file/paragraph/run/image-run.spec.ts +9 -9
- package/src/file/paragraph/run/image-run.ts +2 -1
- package/src/file/paragraph/run/page-number.ts +3 -3
- package/src/file/paragraph/run/properties.ts +2 -2
- package/src/file/paragraph/run/run-components/symbol.ts +1 -1
- package/src/file/paragraph/run/run-components/text.ts +1 -1
- package/src/file/paragraph/run/run-fonts.ts +5 -5
- package/src/file/paragraph/run/run.spec.ts +1 -3
- package/src/file/paragraph/run/run.ts +2 -2
- package/src/file/paragraph/run/script.ts +3 -3
- package/src/file/paragraph/run/sequential-identifier-instruction.ts +1 -1
- package/src/file/paragraph/run/sequential-identifier.ts +1 -1
- package/src/file/paragraph/run/simple-field.ts +2 -2
- package/src/file/paragraph/run/symbol-run.spec.ts +1 -3
- package/src/file/paragraph/run/symbol-run.ts +1 -1
- package/src/file/paragraph/run/tab.ts +1 -1
- package/src/file/paragraph/run/text-run.ts +1 -1
- package/src/file/paragraph/run/underline.ts +1 -1
- package/src/file/relationships/relationship/relationship.ts +1 -1
- package/src/file/relationships/relationships.ts +1 -1
- package/src/file/settings/compatibility-setting/compatibility-setting.ts +1 -1
- package/src/file/settings/compatibility.ts +1 -1
- package/src/file/settings/settings.ts +1 -1
- package/src/file/shading/shading.ts +1 -1
- package/src/file/styles/defaults/document-defaults.spec.ts +2 -2
- package/src/file/styles/defaults/document-defaults.ts +1 -1
- package/src/file/styles/defaults/paragraph-properties.ts +1 -1
- package/src/file/styles/defaults/run-properties.ts +1 -1
- package/src/file/styles/external-styles-factory.spec.ts +3 -3
- package/src/file/styles/external-styles-factory.ts +1 -0
- package/src/file/styles/latent-styles/exceptions.ts +1 -1
- package/src/file/styles/latent-styles/latent-styles.ts +1 -1
- package/src/file/styles/sample/default-style.ts +6 -6
- package/src/file/styles/style/character-style.ts +1 -1
- package/src/file/styles/style/components.ts +2 -2
- package/src/file/styles/style/default-styles.spec.ts +1 -2
- package/src/file/styles/style/default-styles.ts +14 -14
- package/src/file/styles/style/paragraph-style.ts +1 -1
- package/src/file/styles/style/style.ts +1 -1
- package/src/file/styles/styles.ts +4 -4
- package/src/file/table/grid.spec.ts +1 -2
- package/src/file/table/grid.ts +2 -2
- package/src/file/table/table-cell/table-cell-components.ts +4 -4
- package/src/file/table/table-cell/table-cell-properties.ts +1 -1
- package/src/file/table/table-cell/table-cell.ts +2 -2
- package/src/file/table/table-properties/table-borders.ts +1 -1
- package/src/file/table/table-properties/table-cell-margin.ts +4 -1
- package/src/file/table/table-properties/table-float-properties.ts +1 -1
- package/src/file/table/table-properties/table-layout.ts +1 -1
- package/src/file/table/table-properties/table-overlap.ts +1 -1
- package/src/file/table/table-properties/table-properties.ts +1 -1
- package/src/file/table/table-row/table-row-height.ts +1 -1
- package/src/file/table/table-row/table-row-properties.ts +1 -1
- package/src/file/table/table-row/table-row.ts +3 -3
- package/src/file/table/table-width.ts +1 -1
- package/src/file/table/table.ts +4 -3
- package/src/file/table-of-contents/alias.ts +1 -1
- package/src/file/table-of-contents/field-instruction.ts +1 -1
- package/src/file/table-of-contents/sdt-content.ts +1 -1
- package/src/file/table-of-contents/sdt-properties.ts +1 -1
- package/src/file/table-of-contents/table-of-contents-properties.ts +2 -2
- package/src/file/table-of-contents/table-of-contents.spec.ts +1 -3
- package/src/file/table-of-contents/table-of-contents.ts +1 -1
- package/src/file/track-revision/track-revision-components/deleted-page-number.ts +3 -3
- package/src/file/track-revision/track-revision-components/deleted-text-run.ts +2 -2
- package/src/file/track-revision/track-revision-components/deleted-text.ts +1 -1
- package/src/file/track-revision/track-revision-components/inserted-text-run.ts +1 -1
- package/src/file/vertical-align/vertical-align.ts +1 -1
- package/src/file/xml-components/base.ts +1 -1
- package/src/file/xml-components/default-attributes.ts +5 -4
- package/src/file/xml-components/imported-xml-component.spec.ts +3 -2
- package/src/file/xml-components/imported-xml-component.ts +13 -8
- package/src/file/xml-components/initializable-xml-component.ts +1 -1
- package/src/file/xml-components/simple-elements.ts +5 -5
- package/src/file/xml-components/xml-component.ts +4 -2
- package/src/import-dotx/import-dotx.ts +2 -0
- package/src/index.spec.ts +0 -1
- package/src/tests/utility.ts +1 -1
- package/src/util/convenience-functions.spec.ts +0 -2
- package/src/util/convenience-functions.ts +4 -12
- package/src/util/values.ts +29 -41
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
|
|
3
|
-
JSZip v3.10.0 - A JavaScript class for generating and reading zip files
|
|
4
|
-
<http://stuartk.com/jszip>
|
|
5
|
-
|
|
6
|
-
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
|
7
|
-
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
|
8
|
-
|
|
9
|
-
JSZip uses the library pako released under the MIT license :
|
|
10
|
-
https://github.com/nodeca/pako/blob/main/LICENSE
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
1
|
/*!
|
|
14
2
|
* The buffer module from node.js, for the browser.
|
|
15
3
|
*
|
package/build/util/values.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
8
|
-
export declare
|
|
9
|
-
export declare
|
|
10
|
-
export declare
|
|
11
|
-
export declare
|
|
12
|
-
export declare
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
15
|
-
export declare const eighthPointMeasureValue:
|
|
16
|
-
export declare const pointMeasureValue:
|
|
17
|
-
export declare
|
|
1
|
+
export declare const decimalNumber: (val: number) => number;
|
|
2
|
+
export declare const unsignedDecimalNumber: (val: number) => number;
|
|
3
|
+
export declare const longHexNumber: (val: string) => string;
|
|
4
|
+
export declare const shortHexNumber: (val: string) => string;
|
|
5
|
+
export declare const uCharHexNumber: (val: string) => string;
|
|
6
|
+
export declare const universalMeasureValue: (val: string) => string;
|
|
7
|
+
export declare const positiveUniversalMeasureValue: (val: string) => string;
|
|
8
|
+
export declare const hexColorValue: (val: string) => string;
|
|
9
|
+
export declare const signedTwipsMeasureValue: (val: string | number) => string | number;
|
|
10
|
+
export declare const hpsMeasureValue: (val: string | number) => string | number;
|
|
11
|
+
export declare const signedHpsMeasureValue: (val: string | number) => string | number;
|
|
12
|
+
export declare const twipsMeasureValue: (val: string | number) => string | number;
|
|
13
|
+
export declare const percentageValue: (val: string) => string;
|
|
14
|
+
export declare const measurementOrPercentValue: (val: number | string) => number | string;
|
|
15
|
+
export declare const eighthPointMeasureValue: (val: number) => number;
|
|
16
|
+
export declare const pointMeasureValue: (val: number) => number;
|
|
17
|
+
export declare const dateTimeValue: (val: Date) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docx",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test.coverage": "nyc npm test",
|
|
10
10
|
"test.watch": "npm test -- --watch",
|
|
11
11
|
"prepublishOnly": "npm run build --production",
|
|
12
|
-
"lint": "
|
|
12
|
+
"lint": "eslint -c .eslintrc.js --ext .ts src",
|
|
13
13
|
"build": "npm run webpack && npm run fix-types",
|
|
14
14
|
"webpack": "rimraf ./build && webpack --config ./webpack.config.ts",
|
|
15
15
|
"demo": "npm run build && npm run ts-node --skip-project ./demo",
|
|
@@ -64,18 +64,27 @@
|
|
|
64
64
|
"homepage": "https://github.com/dolanmiu/docx#readme",
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/chai": "^4.2.15",
|
|
67
|
-
"@types/glob": "^
|
|
68
|
-
"@types/mocha": "^
|
|
67
|
+
"@types/glob": "^8.0.0",
|
|
68
|
+
"@types/mocha": "^10.0.0",
|
|
69
69
|
"@types/prompt": "^1.1.1",
|
|
70
70
|
"@types/request-promise": "^4.1.42",
|
|
71
71
|
"@types/shelljs": "^0.8.9",
|
|
72
72
|
"@types/sinon": "^10.0.0",
|
|
73
73
|
"@types/unzipper": "^0.10.4",
|
|
74
74
|
"@types/webpack": "^5.0.0",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
|
76
|
+
"@typescript-eslint/parser": "^5.36.1",
|
|
75
77
|
"buffer": "^6.0.3",
|
|
76
78
|
"chai": "^3.5.0",
|
|
77
79
|
"cspell": "^6.2.2",
|
|
78
80
|
"docsify-cli": "^4.3.0",
|
|
81
|
+
"eslint": "^8.23.0",
|
|
82
|
+
"eslint-plugin-functional": "^4.3.1",
|
|
83
|
+
"eslint-plugin-import": "^2.26.0",
|
|
84
|
+
"eslint-plugin-jsdoc": "^39.3.6",
|
|
85
|
+
"eslint-plugin-no-null": "^1.0.2",
|
|
86
|
+
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
87
|
+
"eslint-plugin-unicorn": "^44.0.0",
|
|
79
88
|
"glob": "^8.0.1",
|
|
80
89
|
"jszip": "^3.1.5",
|
|
81
90
|
"mocha": "^10.0.0",
|
|
@@ -94,11 +103,9 @@
|
|
|
94
103
|
"ts-loader": "^9.0.0",
|
|
95
104
|
"ts-node": "^10.2.1",
|
|
96
105
|
"tsconfig-paths": "^4.0.0",
|
|
97
|
-
"tsconfig-paths-webpack-plugin": "^
|
|
98
|
-
"tslint": "^6.1.3",
|
|
99
|
-
"tslint-immutable": "^6.0.1",
|
|
106
|
+
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
100
107
|
"typedoc": "^0.23.2",
|
|
101
|
-
"typescript": "4.
|
|
108
|
+
"typescript": "4.8.4",
|
|
102
109
|
"unzipper": "^0.10.11",
|
|
103
110
|
"webpack": "^5.28.0",
|
|
104
111
|
"webpack-cli": "^4.6.0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IMediaData, Media } from "@file/media";
|
|
2
2
|
|
|
3
3
|
export class ImageReplacer {
|
|
4
|
-
public replace(xmlData: string, mediaData: IMediaData[], offset: number): string {
|
|
4
|
+
public replace(xmlData: string, mediaData: readonly IMediaData[], offset: number): string {
|
|
5
5
|
let currentXmlData = xmlData;
|
|
6
6
|
|
|
7
7
|
mediaData.forEach((image, i) => {
|
|
@@ -11,7 +11,7 @@ export class ImageReplacer {
|
|
|
11
11
|
return currentXmlData;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
public getMediaData(xmlData: string, media: Media): IMediaData[] {
|
|
14
|
+
public getMediaData(xmlData: string, media: Media): readonly IMediaData[] {
|
|
15
15
|
return media.Array.filter((image) => xmlData.search(`{${image.fileName}}`) > 0);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -25,7 +25,7 @@ describe("Compiler", () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
describe("#compile()", () => {
|
|
28
|
-
it("should pack all the content",
|
|
28
|
+
it("should pack all the content", function () {
|
|
29
29
|
this.timeout(99999999);
|
|
30
30
|
const file = new File({
|
|
31
31
|
sections: [],
|
|
@@ -53,7 +53,7 @@ describe("Compiler", () => {
|
|
|
53
53
|
expect(fileNames).to.include("_rels/.rels");
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it("should pack all additional headers and footers",
|
|
56
|
+
it("should pack all additional headers and footers", function () {
|
|
57
57
|
const file = new File({
|
|
58
58
|
sections: [
|
|
59
59
|
{
|
|
@@ -20,10 +20,10 @@ interface IXmlifyedFileMapping {
|
|
|
20
20
|
readonly Numbering: IXmlifyedFile;
|
|
21
21
|
readonly Relationships: IXmlifyedFile;
|
|
22
22
|
readonly FileRelationships: IXmlifyedFile;
|
|
23
|
-
readonly Headers: IXmlifyedFile[];
|
|
24
|
-
readonly Footers: IXmlifyedFile[];
|
|
25
|
-
readonly HeaderRelationships: IXmlifyedFile[];
|
|
26
|
-
readonly FooterRelationships: IXmlifyedFile[];
|
|
23
|
+
readonly Headers: readonly IXmlifyedFile[];
|
|
24
|
+
readonly Footers: readonly IXmlifyedFile[];
|
|
25
|
+
readonly HeaderRelationships: readonly IXmlifyedFile[];
|
|
26
|
+
readonly FooterRelationships: readonly IXmlifyedFile[];
|
|
27
27
|
readonly ContentTypes: IXmlifyedFile;
|
|
28
28
|
readonly CustomProperties: IXmlifyedFile;
|
|
29
29
|
readonly AppProperties: IXmlifyedFile;
|
|
@@ -38,7 +38,7 @@ export class Compiler {
|
|
|
38
38
|
private readonly imageReplacer: ImageReplacer;
|
|
39
39
|
private readonly numberingReplacer: NumberingReplacer;
|
|
40
40
|
|
|
41
|
-
constructor() {
|
|
41
|
+
public constructor() {
|
|
42
42
|
this.formatter = new Formatter();
|
|
43
43
|
this.imageReplacer = new ImageReplacer();
|
|
44
44
|
this.numberingReplacer = new NumberingReplacer();
|
|
@@ -47,15 +47,15 @@ export class Compiler {
|
|
|
47
47
|
public compile(file: File, prettifyXml?: boolean | PrettifyType): JSZip {
|
|
48
48
|
const zip = new JSZip();
|
|
49
49
|
const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml);
|
|
50
|
-
const map = new Map<string, IXmlifyedFile | IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
|
50
|
+
const map = new Map<string, IXmlifyedFile | readonly IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
|
51
51
|
|
|
52
52
|
for (const [, obj] of map) {
|
|
53
53
|
if (Array.isArray(obj)) {
|
|
54
|
-
for (const subFile of obj) {
|
|
54
|
+
for (const subFile of obj as readonly IXmlifyedFile[]) {
|
|
55
55
|
zip.file(subFile.path, subFile.data);
|
|
56
56
|
}
|
|
57
57
|
} else {
|
|
58
|
-
zip.file(obj.path, obj.data);
|
|
58
|
+
zip.file((obj as IXmlifyedFile).path, (obj as IXmlifyedFile).data);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConcreteNumbering } from "@file/numbering";
|
|
2
2
|
|
|
3
3
|
export class NumberingReplacer {
|
|
4
|
-
public replace(xmlData: string, concreteNumberings: ConcreteNumbering[]): string {
|
|
4
|
+
public replace(xmlData: string, concreteNumberings: readonly ConcreteNumbering[]): string {
|
|
5
5
|
let currentXmlData = xmlData;
|
|
6
6
|
|
|
7
7
|
for (const concreteNumbering of concreteNumberings) {
|
|
@@ -37,6 +37,14 @@ describe("Packer", () => {
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
describe("#toString()", () => {
|
|
41
|
+
it("should return a non-empty string", async () => {
|
|
42
|
+
const result = await Packer.toString(file);
|
|
43
|
+
|
|
44
|
+
assert.isAbove(result.length, 0);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
40
48
|
describe("#toBuffer()", () => {
|
|
41
49
|
it("should create a standard docx file", async function () {
|
|
42
50
|
this.timeout(99999999);
|
|
@@ -47,7 +55,7 @@ describe("Packer", () => {
|
|
|
47
55
|
});
|
|
48
56
|
|
|
49
57
|
it("should handle exception if it throws any", () => {
|
|
50
|
-
//
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
59
|
const compiler = stub((Packer as any).compiler, "compile");
|
|
52
60
|
|
|
53
61
|
compiler.throwsException();
|
|
@@ -57,7 +65,7 @@ describe("Packer", () => {
|
|
|
57
65
|
});
|
|
58
66
|
|
|
59
67
|
after(() => {
|
|
60
|
-
//
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
69
|
(Packer as any).compiler.compile.restore();
|
|
62
70
|
});
|
|
63
71
|
});
|
|
@@ -72,7 +80,7 @@ describe("Packer", () => {
|
|
|
72
80
|
});
|
|
73
81
|
|
|
74
82
|
it("should handle exception if it throws any", () => {
|
|
75
|
-
//
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
84
|
const compiler = stub((Packer as any).compiler, "compile");
|
|
77
85
|
|
|
78
86
|
compiler.throwsException();
|
|
@@ -82,14 +90,14 @@ describe("Packer", () => {
|
|
|
82
90
|
});
|
|
83
91
|
|
|
84
92
|
after(() => {
|
|
85
|
-
//
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
94
|
(Packer as any).compiler.compile.restore();
|
|
87
95
|
});
|
|
88
96
|
});
|
|
89
97
|
|
|
90
98
|
describe("#toBlob()", () => {
|
|
91
99
|
it("should create a standard docx file", async () => {
|
|
92
|
-
//
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
101
|
stub((Packer as any).compiler, "compile").callsFake(() => ({
|
|
94
102
|
// tslint:disable-next-line: no-empty
|
|
95
103
|
generateAsync: () => mock({}),
|
|
@@ -100,7 +108,7 @@ describe("Packer", () => {
|
|
|
100
108
|
});
|
|
101
109
|
|
|
102
110
|
it("should handle exception if it throws any", () => {
|
|
103
|
-
//
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
112
|
const compiler = stub((Packer as any).compiler, "compile");
|
|
105
113
|
|
|
106
114
|
compiler.throwsException();
|
|
@@ -110,7 +118,57 @@ describe("Packer", () => {
|
|
|
110
118
|
});
|
|
111
119
|
|
|
112
120
|
afterEach(() => {
|
|
113
|
-
//
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
+
(Packer as any).compiler.compile.restore();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("#toStream()", () => {
|
|
127
|
+
it("should create a standard docx file", async () => {
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
stub((Packer as any).compiler, "compile").callsFake(() => ({
|
|
130
|
+
// tslint:disable-next-line: no-empty
|
|
131
|
+
generateNodeStream: () => ({
|
|
132
|
+
on: (event: string, cb: () => void) => {
|
|
133
|
+
if (event === "end") {
|
|
134
|
+
cb();
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
}));
|
|
139
|
+
const stream = await Packer.toStream(file);
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
stream.on("error", () => {
|
|
142
|
+
reject(new Error());
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
stream.on("end", () => {
|
|
146
|
+
resolve();
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("should handle exception if it throws any", () => {
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
|
+
const compiler = stub((Packer as any).compiler, "compile").callsFake(() => ({
|
|
154
|
+
// tslint:disable-next-line: no-empty
|
|
155
|
+
on: (event: string, cb: () => void) => {
|
|
156
|
+
if (event === "error") {
|
|
157
|
+
cb();
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
compiler.throwsException();
|
|
163
|
+
try {
|
|
164
|
+
Packer.toStream(file);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
assert.isDefined(error);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
afterEach(() => {
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
172
|
(Packer as any).compiler.compile.restore();
|
|
115
173
|
});
|
|
116
174
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Stream } from "stream";
|
|
1
2
|
import { File } from "@file/file";
|
|
2
3
|
|
|
3
4
|
import { Compiler } from "./next-compiler";
|
|
@@ -13,6 +14,17 @@ export enum PrettifyType {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export class Packer {
|
|
17
|
+
public static async toString(file: File, prettify?: boolean | PrettifyType): Promise<string> {
|
|
18
|
+
const zip = this.compiler.compile(file, prettify);
|
|
19
|
+
const zipData = await zip.generateAsync({
|
|
20
|
+
type: "string",
|
|
21
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
22
|
+
compression: "DEFLATE",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return zipData;
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
public static async toBuffer(file: File, prettify?: boolean | PrettifyType): Promise<Buffer> {
|
|
17
29
|
const zip = this.compiler.compile(file, prettify);
|
|
18
30
|
const zipData = await zip.generateAsync({
|
|
@@ -46,5 +58,17 @@ export class Packer {
|
|
|
46
58
|
return zipData;
|
|
47
59
|
}
|
|
48
60
|
|
|
61
|
+
public static toStream(file: File, prettify?: boolean | PrettifyType): Stream {
|
|
62
|
+
const zip = this.compiler.compile(file, prettify);
|
|
63
|
+
const zipData = zip.generateNodeStream({
|
|
64
|
+
type: "nodebuffer",
|
|
65
|
+
streamFiles: true,
|
|
66
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
67
|
+
compression: "DEFLATE",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return zipData;
|
|
71
|
+
}
|
|
72
|
+
|
|
49
73
|
private static readonly compiler = new Compiler();
|
|
50
74
|
}
|
|
@@ -33,7 +33,7 @@ export interface IBorderOptions {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export class BorderElement extends XmlComponent {
|
|
36
|
-
constructor(elementName: string, { color, size, space, style }: IBorderOptions) {
|
|
36
|
+
public constructor(elementName: string, { color, size, space, style }: IBorderOptions) {
|
|
37
37
|
super(elementName);
|
|
38
38
|
this.root.push(
|
|
39
39
|
new BordersAttributes({
|
|
@@ -2,7 +2,7 @@ import { XmlComponent } from "@file/xml-components";
|
|
|
2
2
|
import { DefaultAttributes } from "./default-attributes";
|
|
3
3
|
|
|
4
4
|
export class Default extends XmlComponent {
|
|
5
|
-
constructor(contentType: string, extension?: string) {
|
|
5
|
+
public constructor(contentType: string, extension?: string) {
|
|
6
6
|
super("Default");
|
|
7
7
|
|
|
8
8
|
this.root.push(
|
|
@@ -2,7 +2,7 @@ import { XmlComponent } from "@file/xml-components";
|
|
|
2
2
|
import { OverrideAttributes } from "./override-attributes";
|
|
3
3
|
|
|
4
4
|
export class Override extends XmlComponent {
|
|
5
|
-
constructor(contentType: string, partName?: string) {
|
|
5
|
+
public constructor(contentType: string, partName?: string) {
|
|
6
6
|
super("Override");
|
|
7
7
|
|
|
8
8
|
this.root.push(
|
|
@@ -12,7 +12,7 @@ import { Paragraph } from "../paragraph";
|
|
|
12
12
|
import { IStylesOptions } from "../styles";
|
|
13
13
|
|
|
14
14
|
export interface IPropertiesOptions {
|
|
15
|
-
readonly sections: ISectionOptions[];
|
|
15
|
+
readonly sections: readonly ISectionOptions[];
|
|
16
16
|
readonly title?: string;
|
|
17
17
|
readonly subject?: string;
|
|
18
18
|
readonly creator?: string;
|
|
@@ -26,7 +26,7 @@ export interface IPropertiesOptions {
|
|
|
26
26
|
readonly comments?: ICommentsOptions;
|
|
27
27
|
readonly footnotes?: {
|
|
28
28
|
readonly [key: string]: {
|
|
29
|
-
readonly children: Paragraph[];
|
|
29
|
+
readonly children: readonly Paragraph[];
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
readonly background?: IDocumentBackgroundOptions;
|
|
@@ -35,7 +35,7 @@ export interface IPropertiesOptions {
|
|
|
35
35
|
readonly updateFields?: boolean;
|
|
36
36
|
};
|
|
37
37
|
readonly compatabilityModeVersion?: number;
|
|
38
|
-
readonly customProperties?: ICustomPropertyOptions[];
|
|
38
|
+
readonly customProperties?: readonly ICustomPropertyOptions[];
|
|
39
39
|
readonly evenAndOddHeaderAndFooters?: boolean;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -64,7 +64,7 @@ export interface IPropertiesOptions {
|
|
|
64
64
|
/* cSpell:enable */
|
|
65
65
|
|
|
66
66
|
export class CoreProperties extends XmlComponent {
|
|
67
|
-
constructor(options: Omit<IPropertiesOptions, "sections">) {
|
|
67
|
+
public constructor(options: Omit<IPropertiesOptions, "sections">) {
|
|
68
68
|
super("cp:coreProperties");
|
|
69
69
|
this.root.push(
|
|
70
70
|
new DocumentAttributes({
|
|
@@ -102,7 +102,7 @@ export class CoreProperties extends XmlComponent {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
class TimestampElement extends XmlComponent {
|
|
105
|
-
constructor(name: string) {
|
|
105
|
+
public constructor(name: string) {
|
|
106
106
|
super(name);
|
|
107
107
|
this.root.push(
|
|
108
108
|
new DocumentAttributes({
|
|
@@ -3,11 +3,12 @@ import { CustomPropertiesAttributes } from "./custom-properties-attributes";
|
|
|
3
3
|
import { CustomProperty, ICustomPropertyOptions } from "./custom-property";
|
|
4
4
|
|
|
5
5
|
export class CustomProperties extends XmlComponent {
|
|
6
|
-
//
|
|
6
|
+
// eslint-disable-next-line functional/prefer-readonly-type
|
|
7
7
|
private nextId: number;
|
|
8
|
+
// eslint-disable-next-line functional/prefer-readonly-type
|
|
8
9
|
private readonly properties: CustomProperty[] = [];
|
|
9
10
|
|
|
10
|
-
constructor(properties: ICustomPropertyOptions[]) {
|
|
11
|
+
public constructor(properties: readonly ICustomPropertyOptions[]) {
|
|
11
12
|
super("Properties");
|
|
12
13
|
|
|
13
14
|
this.root.push(
|
|
@@ -32,6 +33,7 @@ export class CustomProperties extends XmlComponent {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
public addCustomProperty(property: ICustomPropertyOptions): void {
|
|
36
|
+
// eslint-disable-next-line functional/immutable-data
|
|
35
37
|
this.properties.push(new CustomProperty(this.nextId++, property));
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -7,7 +7,7 @@ export interface ICustomPropertyOptions {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export class CustomProperty extends XmlComponent {
|
|
10
|
-
constructor(id: number, properties: ICustomPropertyOptions) {
|
|
10
|
+
public constructor(id: number, properties: ICustomPropertyOptions) {
|
|
11
11
|
super("property");
|
|
12
12
|
this.root.push(
|
|
13
13
|
new CustomPropertyAttributes({
|
|
@@ -21,7 +21,7 @@ export class CustomProperty extends XmlComponent {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class CustomPropertyValue extends XmlComponent {
|
|
24
|
-
constructor(value: string) {
|
|
24
|
+
public constructor(value: string) {
|
|
25
25
|
super("vt:lpwstr");
|
|
26
26
|
this.root.push(value);
|
|
27
27
|
}
|
|
@@ -4,9 +4,10 @@ import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
|
|
|
4
4
|
import { ISectionPropertiesOptions, SectionProperties } from "./section-properties/section-properties";
|
|
5
5
|
|
|
6
6
|
export class Body extends XmlComponent {
|
|
7
|
+
// eslint-disable-next-line functional/prefer-readonly-type
|
|
7
8
|
private readonly sections: SectionProperties[] = [];
|
|
8
9
|
|
|
9
|
-
constructor() {
|
|
10
|
+
public constructor() {
|
|
10
11
|
super("w:body");
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -16,6 +17,7 @@ export class Body extends XmlComponent {
|
|
|
16
17
|
* The spec says:
|
|
17
18
|
* - section element should be in the last paragraph of the section
|
|
18
19
|
* - last section should be direct child of body
|
|
20
|
+
*
|
|
19
21
|
* @param options new section options
|
|
20
22
|
*/
|
|
21
23
|
public addSection(options: ISectionPropertiesOptions): void {
|
|
@@ -14,7 +14,7 @@ export class ColumnAttributes extends XmlAttributeComponent<IColumnAttributes> {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class Column extends XmlComponent {
|
|
17
|
-
constructor({ width, space }: IColumnAttributes) {
|
|
17
|
+
public constructor({ width, space }: IColumnAttributes) {
|
|
18
18
|
super("w:col");
|
|
19
19
|
this.root.push(
|
|
20
20
|
new ColumnAttributes({
|
|
@@ -13,6 +13,13 @@ describe("Columns", () => {
|
|
|
13
13
|
expect(tree["w:cols"]).to.deep.equal({ _attr: { "w:num": 3, "w:space": 720 } });
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
+
it("should create set space and count to undefined if they are undefined", () => {
|
|
17
|
+
const columns = new Columns({});
|
|
18
|
+
const tree = new Formatter().format(columns);
|
|
19
|
+
|
|
20
|
+
expect(tree["w:cols"]).to.deep.equal({ _attr: {} });
|
|
21
|
+
});
|
|
22
|
+
|
|
16
23
|
it("should ignore individual column attributes if equalWidth is true", () => {
|
|
17
24
|
const unequalColumns = [new Column({ width: 1000, space: 400 }), new Column({ width: 2000 })];
|
|
18
25
|
const columns = new Columns({ count: 3, space: 720, equalWidth: true, children: unequalColumns });
|
|
@@ -17,7 +17,7 @@ export interface IColumnsAttributes {
|
|
|
17
17
|
readonly count?: number;
|
|
18
18
|
readonly separate?: boolean;
|
|
19
19
|
readonly equalWidth?: boolean;
|
|
20
|
-
readonly children?: Column[];
|
|
20
|
+
readonly children?: readonly Column[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class ColumnsAttributes extends XmlAttributeComponent<IColumnsAttributes> {
|
|
@@ -30,7 +30,7 @@ export class ColumnsAttributes extends XmlAttributeComponent<IColumnsAttributes>
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export class Columns extends XmlComponent {
|
|
33
|
-
constructor({ space, count, separate, equalWidth, children }: IColumnsAttributes) {
|
|
33
|
+
public constructor({ space, count, separate, equalWidth, children }: IColumnsAttributes) {
|
|
34
34
|
super("w:cols");
|
|
35
35
|
this.root.push(
|
|
36
36
|
new ColumnsAttributes({
|
|
@@ -38,7 +38,7 @@ export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesP
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export class DocumentGrid extends XmlComponent {
|
|
41
|
-
constructor(linePitch: number, charSpace?: number, type?: DocumentGridType) {
|
|
41
|
+
public constructor(linePitch: number, charSpace?: number, type?: DocumentGridType) {
|
|
42
42
|
super("w:docGrid");
|
|
43
43
|
|
|
44
44
|
this.root.push(
|
|
@@ -52,7 +52,7 @@ export enum HeaderFooterType {
|
|
|
52
52
|
FOOTER = "w:footerReference",
|
|
53
53
|
}
|
|
54
54
|
export class HeaderFooterReference extends XmlComponent {
|
|
55
|
-
constructor(type: HeaderFooterType, options: IHeaderFooterOptions) {
|
|
55
|
+
public constructor(type: HeaderFooterType, options: IHeaderFooterOptions) {
|
|
56
56
|
super(type);
|
|
57
57
|
|
|
58
58
|
this.root.push(
|
|
@@ -39,7 +39,7 @@ export class LineNumberAttributes extends XmlAttributeComponent<ILineNumberAttri
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export class LineNumberType extends XmlComponent {
|
|
42
|
-
constructor({ countBy, start, restart, distance }: ILineNumberAttributes) {
|
|
42
|
+
public constructor({ countBy, start, restart, distance }: ILineNumberAttributes) {
|
|
43
43
|
super("w:lnNumType");
|
|
44
44
|
this.root.push(
|
|
45
45
|
new LineNumberAttributes({
|
|
@@ -71,7 +71,7 @@ class PageBordersAttributes extends XmlAttributeComponent<IPageBorderAttributes>
|
|
|
71
71
|
// <xsd:attribute name="offsetFrom" type="ST_PageBorderOffset" use="optional" default="text"/>
|
|
72
72
|
// </xsd:complexType>
|
|
73
73
|
export class PageBorders extends IgnoreIfEmptyXmlComponent {
|
|
74
|
-
constructor(options?: IPageBordersOptions) {
|
|
74
|
+
public constructor(options?: IPageBordersOptions) {
|
|
75
75
|
super("w:pgBorders");
|
|
76
76
|
|
|
77
77
|
if (!options) {
|
|
@@ -41,7 +41,7 @@ export class PageNumberTypeAttributes extends XmlAttributeComponent<IPageNumberT
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export class PageNumberType extends XmlComponent {
|
|
44
|
-
constructor({ start, formatType, separator }: IPageNumberTypeAttributes) {
|
|
44
|
+
public constructor({ start, formatType, separator }: IPageNumberTypeAttributes) {
|
|
45
45
|
super("w:pgNumType");
|
|
46
46
|
this.root.push(
|
|
47
47
|
new PageNumberTypeAttributes({
|
|
@@ -33,7 +33,7 @@ export class PageSizeAttributes extends XmlAttributeComponent<IPageSizeAttribute
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export class PageSize extends XmlComponent {
|
|
36
|
-
constructor(width: number | string, height: number | string, orientation: PageOrientation) {
|
|
36
|
+
public constructor(width: number | string, height: number | string, orientation: PageOrientation) {
|
|
37
37
|
super("w:pgSz");
|
|
38
38
|
|
|
39
39
|
const flip = orientation === PageOrientation.LANDSCAPE;
|