Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
b7334a1ab5 | |||
9229f45d59 | |||
2bd4aacdd5 | |||
abbd695a8f | |||
f7b98bcde8 | |||
a756a7697c | |||
fd1ea5b4dc | |||
d83e089cd3 | |||
33715cc50c | |||
f3f1f2d0b1 | |||
c35e706fa8 | |||
35cebfe1a2 | |||
d04c42cbe8 | |||
8744e613ac | |||
cbeecbf3e1 | |||
f8ab2d1701 | |||
adc5c6f594 | |||
c9524cc497 | |||
90de6ba7e1 | |||
78d74ae60b | |||
579593a467 | |||
b5393dadae | |||
528ab1933e | |||
36181f8c91 | |||
45af681db1 | |||
ad6b482136 | |||
a6e1c2b019 |
@ -17,6 +17,7 @@
|
||||
"dolan",
|
||||
"execa",
|
||||
"falsey",
|
||||
"horz",
|
||||
"iife",
|
||||
"Initializable",
|
||||
"iroha",
|
||||
|
@ -7,7 +7,6 @@ parser: "@typescript-eslint/parser"
|
||||
parserOptions:
|
||||
project:
|
||||
- tsconfig.json
|
||||
- demo/tsconfig.json
|
||||
sourceType: module
|
||||
plugins:
|
||||
- eslint-plugin-import
|
||||
@ -214,8 +213,7 @@ rules:
|
||||
valid-typeof: "off"
|
||||
functional/immutable-data:
|
||||
- error
|
||||
- assumeTypes: true
|
||||
ignoreImmediateMutation: true
|
||||
- ignoreImmediateMutation: true
|
||||
ignoreAccessorPattern:
|
||||
- "**.root*"
|
||||
- "**.numberingReferences*"
|
||||
|
166
.github/workflows/demos.yml
vendored
166
.github/workflows/demos.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
||||
name: build
|
||||
path: build
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/1-basic.ts
|
||||
run: npm run run-ts -- ./demo/1-basic.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -47,7 +47,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/2-declaritive-styles.ts
|
||||
run: npm run run-ts -- ./demo/2-declaritive-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -56,7 +56,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/3-numbering-and-bullet-points.ts
|
||||
run: npm run run-ts -- ./demo/3-numbering-and-bullet-points.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -65,7 +65,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/4-basic-table.ts
|
||||
run: npm run run-ts -- ./demo/4-basic-table.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -74,7 +74,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/5-images.ts
|
||||
run: npm run run-ts -- ./demo/5-images.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -83,7 +83,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/6-page-borders.ts
|
||||
run: npm run run-ts -- ./demo/6-page-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -92,7 +92,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/7-landscape.ts
|
||||
run: npm run run-ts -- ./demo/7-landscape.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -101,7 +101,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/8-header-footer.ts
|
||||
run: npm run run-ts -- ./demo/8-header-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -110,7 +110,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/9-images-in-header-and-footer.ts
|
||||
run: npm run run-ts -- ./demo/9-images-in-header-and-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -119,7 +119,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/10-my-cv.ts
|
||||
run: npm run run-ts -- ./demo/10-my-cv.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -128,7 +128,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/11-declaritive-styles-2.ts
|
||||
run: npm run run-ts -- ./demo/11-declaritive-styles-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -137,7 +137,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/12-scaling-images.ts
|
||||
run: npm run run-ts -- ./demo/12-scaling-images.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -146,7 +146,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/13-xml-styles.ts
|
||||
run: npm run run-ts -- ./demo/13-xml-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -155,7 +155,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/14-page-numbers.ts
|
||||
run: npm run run-ts -- ./demo/14-page-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -164,7 +164,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/15-page-break-before.ts
|
||||
run: npm run run-ts -- ./demo/15-page-break-before.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -173,7 +173,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/16-multiple-sections.ts
|
||||
run: npm run run-ts -- ./demo/16-multiple-sections.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -182,7 +182,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/17-footnotes.ts
|
||||
run: npm run run-ts -- ./demo/17-footnotes.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element r: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r': This element is not expected.
|
||||
@ -192,7 +192,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/18-image-from-buffer.ts
|
||||
run: npm run run-ts -- ./demo/18-image-from-buffer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -201,7 +201,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/19-export-to-base64.ts
|
||||
run: npm run run-ts -- ./demo/19-export-to-base64.ts
|
||||
# Base 64 No longer works, abruptly. Node issue?
|
||||
# - name: Extract Word Document
|
||||
# run: npm run extract
|
||||
@ -211,7 +211,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/20-table-cell-borders.ts
|
||||
run: npm run run-ts -- ./demo/20-table-cell-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -220,7 +220,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/21-bookmarks.ts
|
||||
run: npm run run-ts -- ./demo/21-bookmarks.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# Bad ID - need numeric ID
|
||||
@ -230,7 +230,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/22-right-to-left-text.ts
|
||||
run: npm run run-ts -- ./demo/22-right-to-left-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -239,7 +239,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/23-base64-images.ts
|
||||
run: npm run run-ts -- ./demo/23-base64-images.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -248,7 +248,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/24-images-to-table-cell.ts
|
||||
run: npm run run-ts -- ./demo/24-images-to-table-cell.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -257,7 +257,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/25-table-xml-styles.ts
|
||||
run: npm run run-ts -- ./demo/25-table-xml-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -266,7 +266,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/26-paragraph-borders.ts
|
||||
run: npm run run-ts -- ./demo/26-paragraph-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -275,7 +275,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/27-declaritive-styles-3.ts
|
||||
run: npm run run-ts -- ./demo/27-declaritive-styles-3.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -284,7 +284,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/28-table-of-contents.ts
|
||||
run: npm run run-ts -- ./demo/28-table-of-contents.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -293,7 +293,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/29-numbered-lists.ts
|
||||
run: npm run run-ts -- ./demo/29-numbered-lists.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -302,7 +302,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/31-tables.ts
|
||||
run: npm run run-ts -- ./demo/31-tables.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -311,7 +311,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/32-merge-and-shade-table-cells.ts
|
||||
run: npm run run-ts -- ./demo/32-merge-and-shade-table-cells.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -320,7 +320,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/33-sequential-captions.ts
|
||||
run: npm run run-ts -- ./demo/33-sequential-captions.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -329,7 +329,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/34-floating-tables.ts
|
||||
run: npm run run-ts -- ./demo/34-floating-tables.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element tblpPr: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tblpPr', attribute 'overlap': The attribute 'overlap' is not allowed.
|
||||
@ -340,7 +340,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/35-hyperlinks.ts
|
||||
run: npm run run-ts -- ./demo/35-hyperlinks.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -349,7 +349,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/36-image-to-table-cell.ts
|
||||
run: npm run run-ts -- ./demo/36-image-to-table-cell.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -358,7 +358,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/37-images-to-header-and-footer.ts
|
||||
run: npm run run-ts -- ./demo/37-images-to-header-and-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -367,7 +367,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/38-text-wrapping.ts
|
||||
run: npm run run-ts -- ./demo/38-text-wrapping.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -376,7 +376,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/39-page-numbers.ts
|
||||
run: npm run run-ts -- ./demo/39-page-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -385,7 +385,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/40-line-numbers.ts
|
||||
run: npm run run-ts -- ./demo/40-line-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -394,7 +394,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/41-merge-table-cells-2.ts
|
||||
run: npm run run-ts -- ./demo/41-merge-table-cells-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -403,7 +403,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/42-restart-page-numbers.ts
|
||||
run: npm run run-ts -- ./demo/42-restart-page-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -412,7 +412,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/43-images-to-table-cell-2.ts
|
||||
run: npm run run-ts -- ./demo/43-images-to-table-cell-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -421,7 +421,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/44-multiple-columns.ts
|
||||
run: npm run run-ts -- ./demo/44-multiple-columns.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -430,7 +430,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/45-highlighting-text.ts
|
||||
run: npm run run-ts -- ./demo/45-highlighting-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -439,7 +439,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/46-shading-text.ts
|
||||
run: npm run run-ts -- ./demo/46-shading-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -448,7 +448,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/47-number-of-total-pages-section.ts
|
||||
run: npm run run-ts -- ./demo/47-number-of-total-pages-section.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -457,7 +457,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/48-vertical-align.ts
|
||||
run: npm run run-ts -- ./demo/48-vertical-align.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -466,7 +466,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/49-table-borders.ts
|
||||
run: npm run run-ts -- ./demo/49-table-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -475,7 +475,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/50-readme-demo.ts
|
||||
run: npm run run-ts -- ./demo/50-readme-demo.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -484,7 +484,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/51-character-styles.ts
|
||||
run: npm run run-ts -- ./demo/51-character-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -493,7 +493,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/52-japanese.ts
|
||||
run: npm run run-ts -- ./demo/52-japanese.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -502,7 +502,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/53-chinese.ts
|
||||
run: npm run run-ts -- ./demo/53-chinese.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -511,7 +511,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/54-custom-properties.ts
|
||||
run: npm run run-ts -- ./demo/54-custom-properties.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -520,7 +520,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/55-math.ts
|
||||
run: npm run run-ts -- ./demo/55-math.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
#: element subHide: Schemas validity error : Element '{http://schemas.openxmlformats.org/officeDocument/2006/math}subHide': This element is not expected. Expected is ( {http://schemas.openxmlformats.org/officeDocument/2006/math}ctrlPr ).
|
||||
@ -533,7 +533,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/56-background-color.ts
|
||||
run: npm run run-ts -- ./demo/56-background-color.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -542,7 +542,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/57-add-parent-numbered-lists.ts
|
||||
run: npm run run-ts -- ./demo/57-add-parent-numbered-lists.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -551,7 +551,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/58-section-types.ts
|
||||
run: npm run run-ts -- ./demo/58-section-types.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -560,7 +560,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/59-header-footer-margins.ts
|
||||
run: npm run run-ts -- ./demo/59-header-footer-margins.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -569,7 +569,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/60-track-revisions.ts
|
||||
run: npm run run-ts -- ./demo/60-track-revisions.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element r: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r': This element is not expected.
|
||||
@ -579,7 +579,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/61-text-frame.ts
|
||||
run: npm run run-ts -- ./demo/61-text-frame.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element left: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}left': This element is not expected. Expected is one of ( {http://schemas.openxmlformats.org/wordprocessingml/2006/main}right, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}between, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}bar ).
|
||||
@ -589,7 +589,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/62-paragraph-spacing.ts
|
||||
run: npm run run-ts -- ./demo/62-paragraph-spacing.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -598,7 +598,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/63-odd-even-header-footer.ts
|
||||
run: npm run run-ts -- ./demo/63-odd-even-header-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -607,7 +607,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/64-complex-numbering-text.ts
|
||||
run: npm run run-ts -- ./demo/64-complex-numbering-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -616,7 +616,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/65-page-sizes.ts
|
||||
run: npm run run-ts -- ./demo/65-page-sizes.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -625,7 +625,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/66-fields.ts
|
||||
run: npm run run-ts -- ./demo/66-fields.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element bookmarkStart: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}bookmarkStart', attribute '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}id': '-irrswq-ln94j4fdgdjxs' is not a valid value of the atomic type '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_DecimalNumber'.
|
||||
@ -636,7 +636,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/67-column-break.ts
|
||||
run: npm run run-ts -- ./demo/67-column-break.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -645,7 +645,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/68-numbering-instances-and-starting-number.ts
|
||||
run: npm run run-ts -- ./demo/68-numbering-instances-and-starting-number.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -654,7 +654,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/69-different-width-columns.ts
|
||||
run: npm run run-ts -- ./demo/69-different-width-columns.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -663,7 +663,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/70-line-numbers-suppression.ts
|
||||
run: npm run run-ts -- ./demo/70-line-numbers-suppression.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -672,7 +672,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/71-page-borders-2.ts
|
||||
run: npm run run-ts -- ./demo/71-page-borders-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -681,7 +681,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/72-word-wrap.ts
|
||||
run: npm run run-ts -- ./demo/72-word-wrap.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -690,7 +690,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/73-comments.ts
|
||||
run: npm run run-ts -- ./demo/73-comments.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -699,7 +699,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/73-comments.ts
|
||||
run: npm run run-ts -- ./demo/73-comments.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -708,7 +708,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
# - name: Run Demo
|
||||
# run: npm run ts-node -- ./demo/75-tab-stops.ts
|
||||
# run: npm run run-ts -- ./demo/75-tab-stops.ts
|
||||
# - name: Extract Word Document
|
||||
# run: npm run extract
|
||||
# - name: Validate XML
|
||||
@ -717,7 +717,7 @@ jobs:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/76-compatibility.ts
|
||||
run: npm run run-ts -- ./demo/76-compatibility.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -726,7 +726,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/77-side-by-side-tables.ts
|
||||
run: npm run run-ts -- ./demo/77-side-by-side-tables.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -735,7 +735,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/78-thai-distributed.ts
|
||||
run: npm run run-ts -- ./demo/78-thai-distributed.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -744,7 +744,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/79-table-from-data-source.ts
|
||||
run: npm run run-ts -- ./demo/79-table-from-data-source.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -753,7 +753,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/80-thai-distributed.ts
|
||||
run: npm run run-ts -- ./demo/80-thai-distributed.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -762,7 +762,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/81-continuous-header.ts
|
||||
run: npm run run-ts -- ./demo/81-continuous-header.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -771,7 +771,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/82-new-headers-new-section.ts
|
||||
run: npm run run-ts -- ./demo/82-new-headers-new-section.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -780,7 +780,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/83-setting-languages.ts
|
||||
run: npm run run-ts -- ./demo/83-setting-languages.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
@ -789,7 +789,7 @@ jobs:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/84-positional-tabs.ts
|
||||
run: npm run run-ts -- ./demo/84-positional-tabs.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
|
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
@ -1,18 +1,4 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Demo",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeArgs": [
|
||||
"-r",
|
||||
"${workspaceFolder}/node_modules/ts-node/register",
|
||||
"-r",
|
||||
"${workspaceFolder}/node_modules/tsconfig-paths/register"
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceFolder}/demo/85-template-document.ts"
|
||||
}
|
||||
]
|
||||
"configurations": []
|
||||
}
|
||||
|
20
.vscode/tasks.json
vendored
20
.vscode/tasks.json
vendored
@ -2,23 +2,5 @@
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "typescript",
|
||||
"tsconfig": "tsconfig.json",
|
||||
"option": "watch",
|
||||
"problemMatcher": [
|
||||
"$tsc-watch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "ts-node",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
"tasks": []
|
||||
}
|
@ -18,6 +18,7 @@ const receiptTabStops = [
|
||||
const twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
||||
|
||||
const doc = new Document({
|
||||
defaultTabStop: 0,
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
|
@ -55,7 +55,7 @@ if (files.length === 0) {
|
||||
const filePath = path.join(dir, files[0]);
|
||||
|
||||
console.log(`Running demo ${demoNumber}: ${files[0]}`);
|
||||
const { stdout } = await $`ts-node --project demo/tsconfig.json ${filePath}`;
|
||||
const { stdout } = await $`tsx ${filePath}`;
|
||||
console.log(stdout);
|
||||
console.log("Successfully created document!");
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./",
|
||||
"paths": {
|
||||
"docx": ["../build"]
|
||||
}
|
||||
},
|
||||
"include": ["../demo"]
|
||||
}
|
4724
package-lock.json
generated
4724
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docx",
|
||||
"version": "8.2.4",
|
||||
"version": "8.4.0",
|
||||
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
||||
"type": "module",
|
||||
"main": "build/index.umd.js",
|
||||
@ -24,14 +24,14 @@
|
||||
"prepublishOnly": "npm run build --omit=dev",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"predemo": "npm run build",
|
||||
"demo": "ts-node --project demo/tsconfig.json ./demo/index.ts",
|
||||
"demo": "tsx ./demo/index.ts",
|
||||
"typedoc": "typedoc src/index.ts --tsconfig tsconfig.typedoc.json",
|
||||
"style": "prettier -l \"{src,scripts,demo}/**/*.{ts,html}\"",
|
||||
"style.fix": "npm run style -- --write",
|
||||
"cspell": "cspell \"{src,demo,docs,scripts}/**/*.{ts,scss,html,md}\" && cspell \"./*.*\"",
|
||||
"serve.docs": "cd docs && docsify serve",
|
||||
"extract": "ts-node scripts/extract-document.ts",
|
||||
"ts-node": "ts-node --project demo/tsconfig.json"
|
||||
"extract": "tsx scripts/extract-document.ts",
|
||||
"run-ts": "tsx"
|
||||
},
|
||||
"pre-commit": [
|
||||
"style",
|
||||
@ -56,7 +56,7 @@
|
||||
"dependencies": {
|
||||
"@types/node": "^20.3.1",
|
||||
"jszip": "^3.10.1",
|
||||
"nanoid": "^4.0.2",
|
||||
"nanoid": "^5.0.4",
|
||||
"xml": "^1.0.1",
|
||||
"xml-js": "^1.6.8"
|
||||
},
|
||||
@ -73,29 +73,29 @@
|
||||
"@types/xml": "^1.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
||||
"@typescript-eslint/parser": "^6.9.1",
|
||||
"@vitest/coverage-v8": "^0.33.0",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"@vitest/ui": "^0.33.0",
|
||||
"cspell": "^7.3.8",
|
||||
"docsify-cli": "^4.3.0",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint-plugin-functional": "^5.0.8",
|
||||
"eslint-plugin-functional": "^6.0.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-jsdoc": "^46.2.6",
|
||||
"eslint-plugin-no-null": "^1.0.2",
|
||||
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||
"eslint-plugin-unicorn": "^48.0.1",
|
||||
"eslint-plugin-unicorn": "^50.0.1",
|
||||
"execa": "^8.0.1",
|
||||
"glob": "^10.2.7",
|
||||
"inquirer": "^9.2.7",
|
||||
"jsdom": "^22.1.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"prettier": "^3.0.0",
|
||||
"ts-node": "^10.2.1",
|
||||
"tsconfig-paths": "^4.0.0",
|
||||
"tsx": "^4.7.0",
|
||||
"typedoc": "^0.24.8",
|
||||
"typescript": "5.1.6",
|
||||
"unzipper": "^0.10.11",
|
||||
"vite": "^4.3.2",
|
||||
"vite": "^5.0.10",
|
||||
"vite-plugin-dts": "^3.3.1",
|
||||
"vite-plugin-node-polyfills": "^0.9.0",
|
||||
"vite-tsconfig-paths": "^4.2.0",
|
||||
|
@ -44,7 +44,7 @@ export class Compiler {
|
||||
this.numberingReplacer = new NumberingReplacer();
|
||||
}
|
||||
|
||||
public compile(file: File, prettifyXml?: PrettifyType): JSZip {
|
||||
public compile(file: File, prettifyXml?: (typeof PrettifyType)[keyof typeof PrettifyType]): JSZip {
|
||||
const zip = new JSZip();
|
||||
const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml);
|
||||
const map = new Map<string, IXmlifyedFile | readonly IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
||||
@ -66,7 +66,7 @@ export class Compiler {
|
||||
return zip;
|
||||
}
|
||||
|
||||
private xmlifyFile(file: File, prettify?: PrettifyType): IXmlifyedFileMapping {
|
||||
private xmlifyFile(file: File, prettify?: (typeof PrettifyType)[keyof typeof PrettifyType]): IXmlifyedFileMapping {
|
||||
const documentRelationshipCount = file.Document.Relationships.RelationshipCount + 1;
|
||||
|
||||
const documentXmlData = xml(
|
||||
|
@ -6,18 +6,21 @@ import { Compiler } from "./next-compiler";
|
||||
/**
|
||||
* Use blanks to prettify
|
||||
*/
|
||||
export enum PrettifyType {
|
||||
NONE = "",
|
||||
WITH_2_BLANKS = " ",
|
||||
WITH_4_BLANKS = " ",
|
||||
WITH_TAB = "\t",
|
||||
}
|
||||
export const PrettifyType = {
|
||||
NONE: "",
|
||||
WITH_2_BLANKS: " ",
|
||||
WITH_4_BLANKS: " ",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
WITH_TAB: "\t",
|
||||
} as const;
|
||||
|
||||
const convertPrettifyType = (prettify?: boolean | PrettifyType): PrettifyType | undefined =>
|
||||
const convertPrettifyType = (
|
||||
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||
): (typeof PrettifyType)[keyof typeof PrettifyType] | undefined =>
|
||||
prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? undefined : prettify;
|
||||
|
||||
export class Packer {
|
||||
public static async toString(file: File, prettify?: boolean | PrettifyType): Promise<string> {
|
||||
public static async toString(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<string> {
|
||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
||||
const zipData = await zip.generateAsync({
|
||||
type: "string",
|
||||
@ -28,7 +31,7 @@ export class Packer {
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public static async toBuffer(file: File, prettify?: boolean | PrettifyType): Promise<Buffer> {
|
||||
public static async toBuffer(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<Buffer> {
|
||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
||||
const zipData = await zip.generateAsync({
|
||||
type: "nodebuffer",
|
||||
@ -39,7 +42,7 @@ export class Packer {
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public static async toBase64String(file: File, prettify?: boolean | PrettifyType): Promise<string> {
|
||||
public static async toBase64String(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<string> {
|
||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
||||
const zipData = await zip.generateAsync({
|
||||
type: "base64",
|
||||
@ -50,7 +53,7 @@ export class Packer {
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public static async toBlob(file: File, prettify?: boolean | PrettifyType): Promise<Blob> {
|
||||
public static async toBlob(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<Blob> {
|
||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
||||
const zipData = await zip.generateAsync({
|
||||
type: "blob",
|
||||
@ -61,7 +64,7 @@ export class Packer {
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public static toStream(file: File, prettify?: boolean | PrettifyType): Stream {
|
||||
public static toStream(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Stream {
|
||||
const stream = new Stream();
|
||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
||||
|
||||
|
@ -23,7 +23,7 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
import { eighthPointMeasureValue, hexColorValue, pointMeasureValue } from "@util/values";
|
||||
|
||||
export interface IBorderOptions {
|
||||
readonly style: BorderStyle;
|
||||
readonly style: (typeof BorderStyle)[keyof typeof BorderStyle];
|
||||
/** Border color, in hex (eg 'FF00AA') */
|
||||
readonly color?: string;
|
||||
/** Size of the border in 1/8 pt */
|
||||
@ -55,32 +55,34 @@ class BordersAttributes extends XmlAttributeComponent<IBorderOptions> {
|
||||
};
|
||||
}
|
||||
|
||||
export enum BorderStyle {
|
||||
SINGLE = "single",
|
||||
DASH_DOT_STROKED = "dashDotStroked",
|
||||
DASHED = "dashed",
|
||||
DASH_SMALL_GAP = "dashSmallGap",
|
||||
DOT_DASH = "dotDash",
|
||||
DOT_DOT_DASH = "dotDotDash",
|
||||
DOTTED = "dotted",
|
||||
DOUBLE = "double",
|
||||
DOUBLE_WAVE = "doubleWave",
|
||||
INSET = "inset",
|
||||
NIL = "nil",
|
||||
NONE = "none",
|
||||
OUTSET = "outset",
|
||||
THICK = "thick",
|
||||
THICK_THIN_LARGE_GAP = "thickThinLargeGap",
|
||||
THICK_THIN_MEDIUM_GAP = "thickThinMediumGap",
|
||||
THICK_THIN_SMALL_GAP = "thickThinSmallGap",
|
||||
THIN_THICK_LARGE_GAP = "thinThickLargeGap",
|
||||
THIN_THICK_MEDIUM_GAP = "thinThickMediumGap",
|
||||
THIN_THICK_SMALL_GAP = "thinThickSmallGap",
|
||||
THIN_THICK_THIN_LARGE_GAP = "thinThickThinLargeGap",
|
||||
THIN_THICK_THIN_MEDIUM_GAP = "thinThickThinMediumGap",
|
||||
THIN_THICK_THIN_SMALL_GAP = "thinThickThinSmallGap",
|
||||
THREE_D_EMBOSS = "threeDEmboss",
|
||||
THREE_D_ENGRAVE = "threeDEngrave",
|
||||
TRIPLE = "triple",
|
||||
WAVE = "wave",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const BorderStyle = {
|
||||
SINGLE: "single",
|
||||
DASH_DOT_STROKED: "dashDotStroked",
|
||||
DASHED: "dashed",
|
||||
DASH_SMALL_GAP: "dashSmallGap",
|
||||
DOT_DASH: "dotDash",
|
||||
DOT_DOT_DASH: "dotDotDash",
|
||||
DOTTED: "dotted",
|
||||
DOUBLE: "double",
|
||||
DOUBLE_WAVE: "doubleWave",
|
||||
INSET: "inset",
|
||||
NIL: "nil",
|
||||
NONE: "none",
|
||||
OUTSET: "outset",
|
||||
THICK: "thick",
|
||||
THICK_THIN_LARGE_GAP: "thickThinLargeGap",
|
||||
THICK_THIN_MEDIUM_GAP: "thickThinMediumGap",
|
||||
THICK_THIN_SMALL_GAP: "thickThinSmallGap",
|
||||
THIN_THICK_LARGE_GAP: "thinThickLargeGap",
|
||||
THIN_THICK_MEDIUM_GAP: "thinThickMediumGap",
|
||||
THIN_THICK_SMALL_GAP: "thinThickSmallGap",
|
||||
THIN_THICK_THIN_LARGE_GAP: "thinThickThinLargeGap",
|
||||
THIN_THICK_THIN_MEDIUM_GAP: "thinThickThinMediumGap",
|
||||
THIN_THICK_THIN_SMALL_GAP: "thinThickThinSmallGap",
|
||||
THREE_D_EMBOSS: "threeDEmboss",
|
||||
THREE_D_ENGRAVE: "threeDEngrave",
|
||||
TRIPLE: "triple",
|
||||
WAVE: "wave",
|
||||
} as const;
|
||||
/* eslint-enable */
|
||||
|
@ -39,6 +39,7 @@ export interface IPropertiesOptions {
|
||||
readonly compatibility?: ICompatibilityOptions;
|
||||
readonly customProperties?: readonly ICustomPropertyOptions[];
|
||||
readonly evenAndOddHeaderAndFooters?: boolean;
|
||||
readonly defaultTabStop?: number;
|
||||
}
|
||||
|
||||
// <xs:element name="coreProperties" type="CT_CoreProperties"/>
|
||||
|
@ -17,14 +17,17 @@ import { decimalNumber } from "@util/values";
|
||||
// <xsd:attribute name="charSpace" type="ST_DecimalNumber"/>
|
||||
// </xsd:complexType>
|
||||
|
||||
export enum DocumentGridType {
|
||||
DEFAULT = "default",
|
||||
LINES = "lines",
|
||||
LINES_AND_CHARS = "linesAndChars",
|
||||
SNAP_TO_CHARS = "snapToChars",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const DocumentGridType = {
|
||||
DEFAULT: "default",
|
||||
LINES: "lines",
|
||||
LINES_AND_CHARS: "linesAndChars",
|
||||
SNAP_TO_CHARS: "snapToChars",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
export interface IDocGridAttributesProperties {
|
||||
readonly type?: DocumentGridType;
|
||||
readonly type?: (typeof DocumentGridType)[keyof typeof DocumentGridType];
|
||||
readonly linePitch?: number;
|
||||
readonly charSpace?: number;
|
||||
}
|
||||
@ -38,7 +41,7 @@ export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesP
|
||||
}
|
||||
|
||||
export class DocumentGrid extends XmlComponent {
|
||||
public constructor(linePitch: number, charSpace?: number, type?: DocumentGridType) {
|
||||
public constructor(linePitch: number, charSpace?: number, type?: (typeof DocumentGridType)[keyof typeof DocumentGridType]) {
|
||||
super("w:docGrid");
|
||||
|
||||
this.root.push(
|
||||
|
@ -7,11 +7,11 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
// <xsd:enumeration value="first"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum HeaderFooterReferenceType {
|
||||
DEFAULT = "default",
|
||||
FIRST = "first",
|
||||
EVEN = "even",
|
||||
}
|
||||
export const HeaderFooterReferenceType = {
|
||||
DEFAULT: "default",
|
||||
FIRST: "first",
|
||||
EVEN: "even",
|
||||
} as const;
|
||||
|
||||
// </xsd:complexType>
|
||||
// <xsd:group name="EG_HdrFtrReferences">
|
||||
@ -33,12 +33,12 @@ export enum HeaderFooterReferenceType {
|
||||
// </xsd:complexType>
|
||||
|
||||
export interface IHeaderFooterOptions {
|
||||
readonly type?: HeaderFooterReferenceType;
|
||||
readonly type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
||||
readonly id?: number;
|
||||
}
|
||||
|
||||
class FooterReferenceAttributes extends XmlAttributeComponent<{
|
||||
readonly type: HeaderFooterReferenceType;
|
||||
readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
||||
readonly id: string;
|
||||
}> {
|
||||
protected readonly xmlKeys = {
|
||||
@ -47,12 +47,13 @@ class FooterReferenceAttributes extends XmlAttributeComponent<{
|
||||
};
|
||||
}
|
||||
|
||||
export enum HeaderFooterType {
|
||||
HEADER = "w:headerReference",
|
||||
FOOTER = "w:footerReference",
|
||||
}
|
||||
export const HeaderFooterType = {
|
||||
HEADER: "w:headerReference",
|
||||
FOOTER: "w:footerReference",
|
||||
} as const;
|
||||
|
||||
export class HeaderFooterReference extends XmlComponent {
|
||||
public constructor(type: HeaderFooterType, options: IHeaderFooterOptions) {
|
||||
public constructor(type: (typeof HeaderFooterType)[keyof typeof HeaderFooterType], options: IHeaderFooterOptions) {
|
||||
super(type);
|
||||
|
||||
this.root.push(
|
||||
|
@ -9,11 +9,14 @@ import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@uti
|
||||
// <xsd:enumeration value="continuous"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum LineNumberRestartFormat {
|
||||
NEW_PAGE = "newPage",
|
||||
NEW_SECTION = "newSection",
|
||||
CONTINUOUS = "continuous",
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const LineNumberRestartFormat = {
|
||||
NEW_PAGE: "newPage",
|
||||
NEW_SECTION: "newSection",
|
||||
CONTINUOUS: "continuous",
|
||||
} as const;
|
||||
/* eslint-enable */
|
||||
|
||||
// <xsd:complexType name="CT_LineNumber">
|
||||
// <xsd:attribute name="countBy" type="ST_DecimalNumber" use="optional"/>
|
||||
@ -25,7 +28,7 @@ export enum LineNumberRestartFormat {
|
||||
export interface ILineNumberAttributes {
|
||||
readonly countBy?: number;
|
||||
readonly start?: number;
|
||||
readonly restart?: LineNumberRestartFormat;
|
||||
readonly restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];
|
||||
readonly distance?: number | PositiveUniversalMeasure;
|
||||
}
|
||||
|
||||
@ -36,13 +39,16 @@ export class LineNumberType extends XmlComponent {
|
||||
new NextAttributeComponent<{
|
||||
readonly countBy?: number;
|
||||
readonly start?: number;
|
||||
readonly restart?: LineNumberRestartFormat;
|
||||
readonly restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];
|
||||
readonly distance?: number | PositiveUniversalMeasure;
|
||||
}>({
|
||||
countBy: { key: "w:countBy", value: countBy === undefined ? undefined : decimalNumber(countBy) },
|
||||
start: { key: "w:start", value: start === undefined ? undefined : decimalNumber(start) },
|
||||
restart: { key: "w:restart", value: restart },
|
||||
distance: { key: "w:distance", value: distance === undefined ? undefined : twipsMeasureValue(distance) },
|
||||
distance: {
|
||||
key: "w:distance",
|
||||
value: distance === undefined ? undefined : twipsMeasureValue(distance),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -9,11 +9,14 @@ import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent } from "@file/xml-comp
|
||||
// <xsd:enumeration value="notFirstPage"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PageBorderDisplay {
|
||||
ALL_PAGES = "allPages",
|
||||
FIRST_PAGE = "firstPage",
|
||||
NOT_FIRST_PAGE = "notFirstPage",
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const PageBorderDisplay = {
|
||||
ALL_PAGES: "allPages",
|
||||
FIRST_PAGE: "firstPage",
|
||||
NOT_FIRST_PAGE: "notFirstPage",
|
||||
} as const;
|
||||
/* eslint-enable */
|
||||
|
||||
// <xsd:simpleType name="ST_PageBorderOffset">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
@ -21,10 +24,10 @@ export enum PageBorderDisplay {
|
||||
// <xsd:enumeration value="text"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PageBorderOffsetFrom {
|
||||
PAGE = "page",
|
||||
TEXT = "text",
|
||||
}
|
||||
export const PageBorderOffsetFrom = {
|
||||
PAGE: "page",
|
||||
TEXT: "text",
|
||||
} as const;
|
||||
|
||||
// <xsd:simpleType name="ST_PageBorderZOrder">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
@ -32,15 +35,15 @@ export enum PageBorderOffsetFrom {
|
||||
// <xsd:enumeration value="back"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PageBorderZOrder {
|
||||
BACK = "back",
|
||||
FRONT = "front",
|
||||
}
|
||||
export const PageBorderZOrder = {
|
||||
BACK: "back",
|
||||
FRONT: "front",
|
||||
} as const;
|
||||
|
||||
export interface IPageBorderAttributes {
|
||||
readonly display?: PageBorderDisplay;
|
||||
readonly offsetFrom?: PageBorderOffsetFrom;
|
||||
readonly zOrder?: PageBorderZOrder;
|
||||
readonly display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay];
|
||||
readonly offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom];
|
||||
readonly zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder];
|
||||
}
|
||||
|
||||
export interface IPageBordersOptions {
|
||||
|
@ -12,18 +12,22 @@ import { decimalNumber } from "@util/values";
|
||||
// <xsd:enumeration value="enDash"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PageNumberSeparator {
|
||||
HYPHEN = "hyphen",
|
||||
PERIOD = "period",
|
||||
COLON = "colon",
|
||||
EM_DASH = "emDash",
|
||||
EN_DASH = "endash",
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const PageNumberSeparator = {
|
||||
HYPHEN: "hyphen",
|
||||
PERIOD: "period",
|
||||
COLON: "colon",
|
||||
EM_DASH: "emDash",
|
||||
EN_DASH: "endash",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
export interface IPageNumberTypeAttributes {
|
||||
readonly start?: number;
|
||||
readonly formatType?: NumberFormat;
|
||||
readonly separator?: PageNumberSeparator;
|
||||
readonly formatType?: (typeof NumberFormat)[keyof typeof NumberFormat];
|
||||
readonly separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator];
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_PageNumber">
|
||||
@ -40,6 +44,7 @@ export class PageNumberTypeAttributes extends XmlAttributeComponent<IPageNumberT
|
||||
separator: "w:chapSep",
|
||||
};
|
||||
}
|
||||
|
||||
export class PageNumberType extends XmlComponent {
|
||||
public constructor({ start, formatType, separator }: IPageNumberTypeAttributes) {
|
||||
super("w:pgNumType");
|
||||
|
@ -7,10 +7,10 @@ import { PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
|
||||
// <xsd:enumeration value="landscape"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PageOrientation {
|
||||
PORTRAIT = "portrait",
|
||||
LANDSCAPE = "landscape",
|
||||
}
|
||||
export const PageOrientation = {
|
||||
PORTRAIT: "portrait",
|
||||
LANDSCAPE: "landscape",
|
||||
} as const;
|
||||
|
||||
// <xsd:complexType name="CT_PageSz">
|
||||
// <xsd:attribute name="w" type="s:ST_TwipsMeasure"/>
|
||||
@ -21,11 +21,15 @@ export enum PageOrientation {
|
||||
export type IPageSizeAttributes = {
|
||||
readonly width?: number | PositiveUniversalMeasure;
|
||||
readonly height?: number | PositiveUniversalMeasure;
|
||||
readonly orientation?: PageOrientation;
|
||||
readonly orientation?: (typeof PageOrientation)[keyof typeof PageOrientation];
|
||||
};
|
||||
|
||||
export class PageSize extends XmlComponent {
|
||||
public constructor(width: number | PositiveUniversalMeasure, height: number | PositiveUniversalMeasure, orientation: PageOrientation) {
|
||||
public constructor(
|
||||
width: number | PositiveUniversalMeasure,
|
||||
height: number | PositiveUniversalMeasure,
|
||||
orientation: (typeof PageOrientation)[keyof typeof PageOrientation],
|
||||
) {
|
||||
super("w:pgSz");
|
||||
|
||||
const flip = orientation === PageOrientation.LANDSCAPE;
|
||||
|
@ -1,16 +1,21 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
|
||||
export enum PageTextDirectionType {
|
||||
LEFT_TO_RIGHT_TOP_TO_BOTTOM = "lrTb",
|
||||
TOP_TO_BOTTOM_RIGHT_TO_LEFT = "tbRl",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const PageTextDirectionType = {
|
||||
LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb",
|
||||
TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl",
|
||||
} as const;
|
||||
|
||||
class PageTextDirectionAttributes extends XmlAttributeComponent<{ readonly val: PageTextDirectionType }> {
|
||||
/* eslint-enable */
|
||||
|
||||
class PageTextDirectionAttributes extends XmlAttributeComponent<{
|
||||
readonly val: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];
|
||||
}> {
|
||||
protected readonly xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
||||
export class PageTextDirection extends XmlComponent {
|
||||
public constructor(value: PageTextDirectionType) {
|
||||
public constructor(value: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType]) {
|
||||
super("w:textDirection");
|
||||
|
||||
this.root.push(
|
||||
|
@ -10,19 +10,22 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
// <xsd:enumeration value="oddPage"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum SectionType {
|
||||
NEXT_PAGE = "nextPage",
|
||||
NEXT_COLUMN = "nextColumn",
|
||||
CONTINUOUS = "continuous",
|
||||
EVEN_PAGE = "evenPage",
|
||||
ODD_PAGE = "oddPage",
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const SectionType = {
|
||||
NEXT_PAGE: "nextPage",
|
||||
NEXT_COLUMN: "nextColumn",
|
||||
CONTINUOUS: "continuous",
|
||||
EVEN_PAGE: "evenPage",
|
||||
ODD_PAGE: "oddPage",
|
||||
} as const;
|
||||
/* eslint-enable */
|
||||
|
||||
// <xsd:complexType name="CT_SectType">
|
||||
// <xsd:attribute name="val" type="ST_SectionMark"/>
|
||||
// </xsd:complexType>
|
||||
export class SectionTypeAttributes extends XmlAttributeComponent<{
|
||||
readonly val: SectionType;
|
||||
readonly val: (typeof SectionType)[keyof typeof SectionType];
|
||||
}> {
|
||||
protected readonly xmlKeys = {
|
||||
val: "w:val",
|
||||
@ -30,7 +33,7 @@ export class SectionTypeAttributes extends XmlAttributeComponent<{
|
||||
}
|
||||
|
||||
export class Type extends XmlComponent {
|
||||
public constructor(value: SectionType) {
|
||||
public constructor(value: (typeof SectionType)[keyof typeof SectionType]) {
|
||||
super("w:type");
|
||||
this.root.push(new SectionTypeAttributes({ val: value }));
|
||||
}
|
||||
|
@ -29,16 +29,16 @@ export interface ISectionPropertiesOptions {
|
||||
readonly margin?: IPageMarginAttributes;
|
||||
readonly pageNumbers?: IPageNumberTypeAttributes;
|
||||
readonly borders?: IPageBordersOptions;
|
||||
readonly textDirection?: PageTextDirectionType;
|
||||
readonly textDirection?: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];
|
||||
};
|
||||
readonly grid?: IDocGridAttributesProperties;
|
||||
readonly headerWrapperGroup?: IHeaderFooterGroup<HeaderWrapper>;
|
||||
readonly footerWrapperGroup?: IHeaderFooterGroup<FooterWrapper>;
|
||||
readonly lineNumbers?: ILineNumberAttributes;
|
||||
readonly titlePage?: boolean;
|
||||
readonly verticalAlign?: VerticalAlign;
|
||||
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
||||
readonly column?: IColumnsAttributes;
|
||||
readonly type?: SectionType;
|
||||
readonly type?: (typeof SectionType)[keyof typeof SectionType];
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_SectPr">
|
||||
@ -162,7 +162,7 @@ export class SectionProperties extends XmlComponent {
|
||||
}
|
||||
|
||||
private addHeaderFooterGroup(
|
||||
type: HeaderFooterType,
|
||||
type: (typeof HeaderFooterType)[keyof typeof HeaderFooterType],
|
||||
group: IHeaderFooterGroup<HeaderWrapper> | IHeaderFooterGroup<FooterWrapper>,
|
||||
): void {
|
||||
if (group.default) {
|
||||
|
@ -3,7 +3,11 @@ import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared/ali
|
||||
import { XmlComponent } from "@file/xml-components";
|
||||
|
||||
export class Align extends XmlComponent {
|
||||
public constructor(value: HorizontalPositionAlign | VerticalPositionAlign) {
|
||||
public constructor(
|
||||
value:
|
||||
| (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign]
|
||||
| (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign],
|
||||
) {
|
||||
super("wp:align");
|
||||
this.root.push(value);
|
||||
}
|
||||
|
@ -4,37 +4,39 @@ import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared/ali
|
||||
|
||||
import { ITextWrapping } from "../text-wrap";
|
||||
|
||||
export enum HorizontalPositionRelativeFrom {
|
||||
CHARACTER = "character",
|
||||
COLUMN = "column",
|
||||
INSIDE_MARGIN = "insideMargin",
|
||||
LEFT_MARGIN = "leftMargin",
|
||||
MARGIN = "margin",
|
||||
OUTSIDE_MARGIN = "outsideMargin",
|
||||
PAGE = "page",
|
||||
RIGHT_MARGIN = "rightMargin",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const HorizontalPositionRelativeFrom = {
|
||||
CHARACTER: "character",
|
||||
COLUMN: "column",
|
||||
INSIDE_MARGIN: "insideMargin",
|
||||
LEFT_MARGIN: "leftMargin",
|
||||
MARGIN: "margin",
|
||||
OUTSIDE_MARGIN: "outsideMargin",
|
||||
PAGE: "page",
|
||||
RIGHT_MARGIN: "rightMargin",
|
||||
} as const;
|
||||
|
||||
export enum VerticalPositionRelativeFrom {
|
||||
BOTTOM_MARGIN = "bottomMargin",
|
||||
INSIDE_MARGIN = "insideMargin",
|
||||
LINE = "line",
|
||||
MARGIN = "margin",
|
||||
OUTSIDE_MARGIN = "outsideMargin",
|
||||
PAGE = "page",
|
||||
PARAGRAPH = "paragraph",
|
||||
TOP_MARGIN = "topMargin",
|
||||
}
|
||||
export const VerticalPositionRelativeFrom = {
|
||||
BOTTOM_MARGIN: "bottomMargin",
|
||||
INSIDE_MARGIN: "insideMargin",
|
||||
LINE: "line",
|
||||
MARGIN: "margin",
|
||||
OUTSIDE_MARGIN: "outsideMargin",
|
||||
PAGE: "page",
|
||||
PARAGRAPH: "paragraph",
|
||||
TOP_MARGIN: "topMargin",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
export interface IHorizontalPositionOptions {
|
||||
readonly relative?: HorizontalPositionRelativeFrom;
|
||||
readonly align?: HorizontalPositionAlign;
|
||||
readonly relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];
|
||||
readonly align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];
|
||||
readonly offset?: number;
|
||||
}
|
||||
|
||||
export interface IVerticalPositionOptions {
|
||||
readonly relative?: VerticalPositionRelativeFrom;
|
||||
readonly align?: VerticalPositionAlign;
|
||||
readonly relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];
|
||||
readonly align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];
|
||||
readonly offset?: number;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { HorizontalPositionRelativeFrom, IHorizontalPositionOptions } from "./fl
|
||||
import { PositionOffset } from "./position-offset";
|
||||
|
||||
class HorizontalPositionAttributes extends XmlAttributeComponent<{
|
||||
readonly relativeFrom: HorizontalPositionRelativeFrom;
|
||||
readonly relativeFrom: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];
|
||||
}> {
|
||||
protected readonly xmlKeys = {
|
||||
relativeFrom: "relativeFrom",
|
||||
|
@ -5,7 +5,7 @@ import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floati
|
||||
import { PositionOffset } from "./position-offset";
|
||||
|
||||
class VerticalPositionAttributes extends XmlAttributeComponent<{
|
||||
readonly relativeFrom: VerticalPositionRelativeFrom;
|
||||
readonly relativeFrom: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];
|
||||
}> {
|
||||
protected readonly xmlKeys = {
|
||||
relativeFrom: "relativeFrom",
|
||||
|
@ -1,22 +1,25 @@
|
||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||
import { IDistance } from "../drawing";
|
||||
|
||||
export enum TextWrappingType {
|
||||
NONE,
|
||||
SQUARE,
|
||||
TIGHT,
|
||||
TOP_AND_BOTTOM,
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const TextWrappingType = {
|
||||
NONE: 0,
|
||||
SQUARE: 1,
|
||||
TIGHT: 2,
|
||||
TOP_AND_BOTTOM: 3,
|
||||
} as const;
|
||||
|
||||
export enum TextWrappingSide {
|
||||
BOTH_SIDES = "bothSides",
|
||||
LEFT = "left",
|
||||
RIGHT = "right",
|
||||
LARGEST = "largest",
|
||||
}
|
||||
export const TextWrappingSide = {
|
||||
BOTH_SIDES: "bothSides",
|
||||
LEFT: "left",
|
||||
RIGHT: "right",
|
||||
LARGEST: "largest",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
export interface ITextWrapping {
|
||||
readonly type: TextWrappingType;
|
||||
readonly side?: TextWrappingSide;
|
||||
readonly type: (typeof TextWrappingType)[keyof typeof TextWrappingType];
|
||||
readonly side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
|
||||
readonly margins?: IDistance;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import { IMargins } from "../floating";
|
||||
import { ITextWrapping, TextWrappingSide } from "./text-wrapping";
|
||||
|
||||
interface IWrapSquareAttributes extends IDistance {
|
||||
readonly wrapText?: TextWrappingSide;
|
||||
readonly wrapText?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
|
||||
}
|
||||
|
||||
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
|
||||
|
@ -77,6 +77,7 @@ export class File {
|
||||
evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,
|
||||
trackRevisions: options.features?.trackRevisions,
|
||||
updateFields: options.features?.updateFields,
|
||||
defaultTabStop: options.defaultTabStop,
|
||||
});
|
||||
|
||||
this.media = new Media();
|
||||
@ -154,7 +155,10 @@ export class File {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private addHeaderToDocument(header: HeaderWrapper, type: HeaderFooterReferenceType = HeaderFooterReferenceType.DEFAULT): void {
|
||||
private addHeaderToDocument(
|
||||
header: HeaderWrapper,
|
||||
type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType] = HeaderFooterReferenceType.DEFAULT,
|
||||
): void {
|
||||
// eslint-disable-next-line functional/immutable-data
|
||||
this.headers.push({ header, type });
|
||||
this.documentWrapper.Relationships.createRelationship(
|
||||
@ -165,7 +169,10 @@ export class File {
|
||||
this.contentTypes.addHeader(this.headers.length);
|
||||
}
|
||||
|
||||
private addFooterToDocument(footer: FooterWrapper, type: HeaderFooterReferenceType = HeaderFooterReferenceType.DEFAULT): void {
|
||||
private addFooterToDocument(
|
||||
footer: FooterWrapper,
|
||||
type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType] = HeaderFooterReferenceType.DEFAULT,
|
||||
): void {
|
||||
// eslint-disable-next-line functional/immutable-data
|
||||
this.footers.push({ footer, type });
|
||||
this.documentWrapper.Relationships.createRelationship(
|
||||
|
@ -10,7 +10,7 @@ import { Table } from "./table";
|
||||
|
||||
export interface IDocumentFooter {
|
||||
readonly footer: FooterWrapper;
|
||||
readonly type: HeaderFooterReferenceType;
|
||||
readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
||||
}
|
||||
|
||||
export class FooterWrapper implements IViewWrapper {
|
||||
|
@ -4,14 +4,15 @@ import { XmlComponent } from "@file/xml-components";
|
||||
import { FootnoteAttributes } from "./footnote-attributes";
|
||||
import { FootnoteRefRun } from "./run/footnote-ref-run";
|
||||
|
||||
export enum FootnoteType {
|
||||
SEPERATOR = "separator",
|
||||
CONTINUATION_SEPERATOR = "continuationSeparator",
|
||||
}
|
||||
export const FootnoteType = {
|
||||
SEPERATOR: "separator",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
CONTINUATION_SEPERATOR: "continuationSeparator",
|
||||
} as const;
|
||||
|
||||
export interface IFootnoteOptions {
|
||||
readonly id: number;
|
||||
readonly type?: FootnoteType;
|
||||
readonly type?: (typeof FootnoteType)[keyof typeof FootnoteType];
|
||||
readonly children: readonly Paragraph[];
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import { Table } from "./table";
|
||||
|
||||
export interface IDocumentHeader {
|
||||
readonly header: HeaderWrapper;
|
||||
readonly type: HeaderFooterReferenceType;
|
||||
readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
||||
}
|
||||
|
||||
export class HeaderWrapper implements IViewWrapper {
|
||||
|
@ -75,71 +75,75 @@ import { IRunStylePropertiesOptions, RunProperties } from "../paragraph/run/prop
|
||||
// <xsd:enumeration value="custom"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum LevelFormat {
|
||||
DECIMAL = "decimal",
|
||||
UPPER_ROMAN = "upperRoman",
|
||||
LOWER_ROMAN = "lowerRoman",
|
||||
UPPER_LETTER = "upperLetter",
|
||||
LOWER_LETTER = "lowerLetter",
|
||||
ORDINAL = "ordinal",
|
||||
CARDINAL_TEXT = "cardinalText",
|
||||
ORDINAL_TEXT = "ordinalText",
|
||||
HEX = "hex",
|
||||
CHICAGO = "chicago",
|
||||
IDEOGRAPH__DIGITAL = "ideographDigital",
|
||||
JAPANESE_COUNTING = "japaneseCounting",
|
||||
AIUEO = "aiueo",
|
||||
IROHA = "iroha",
|
||||
DECIMAL_FULL_WIDTH = "decimalFullWidth",
|
||||
DECIMAL_HALF_WIDTH = "decimalHalfWidth",
|
||||
JAPANESE_LEGAL = "japaneseLegal",
|
||||
JAPANESE_DIGITAL_TEN_THOUSAND = "japaneseDigitalTenThousand",
|
||||
DECIMAL_ENCLOSED_CIRCLE = "decimalEnclosedCircle",
|
||||
DECIMAL_FULL_WIDTH2 = "decimalFullWidth2",
|
||||
AIUEO_FULL_WIDTH = "aiueoFullWidth",
|
||||
IROHA_FULL_WIDTH = "irohaFullWidth",
|
||||
DECIMAL_ZERO = "decimalZero",
|
||||
BULLET = "bullet",
|
||||
GANADA = "ganada",
|
||||
CHOSUNG = "chosung",
|
||||
DECIMAL_ENCLOSED_FULLSTOP = "decimalEnclosedFullstop",
|
||||
DECIMAL_ENCLOSED_PARENTHESES = "decimalEnclosedParen",
|
||||
DECIMAL_ENCLOSED_CIRCLE_CHINESE = "decimalEnclosedCircleChinese",
|
||||
IDEOGRAPH_ENCLOSED_CIRCLE = "ideographEnclosedCircle",
|
||||
IDEOGRAPH_TRADITIONAL = "ideographTraditional",
|
||||
IDEOGRAPH_ZODIAC = "ideographZodiac",
|
||||
IDEOGRAPH_ZODIAC_TRADITIONAL = "ideographZodiacTraditional",
|
||||
TAIWANESE_COUNTING = "taiwaneseCounting",
|
||||
IDEOGRAPH_LEGAL_TRADITIONAL = "ideographLegalTraditional",
|
||||
TAIWANESE_COUNTING_THOUSAND = "taiwaneseCountingThousand",
|
||||
TAIWANESE_DIGITAL = "taiwaneseDigital",
|
||||
CHINESE_COUNTING = "chineseCounting",
|
||||
CHINESE_LEGAL_SIMPLIFIED = "chineseLegalSimplified",
|
||||
CHINESE_COUNTING_THOUSAND = "chineseCountingThousand",
|
||||
KOREAN_DIGITAL = "koreanDigital",
|
||||
KOREAN_COUNTING = "koreanCounting",
|
||||
KOREAN_LEGAL = "koreanLegal",
|
||||
KOREAN_DIGITAL2 = "koreanDigital2",
|
||||
VIETNAMESE_COUNTING = "vietnameseCounting",
|
||||
RUSSIAN_LOWER = "russianLower",
|
||||
RUSSIAN_UPPER = "russianUpper",
|
||||
NONE = "none",
|
||||
NUMBER_IN_DASH = "numberInDash",
|
||||
HEBREW1 = "hebrew1",
|
||||
HEBREW2 = "hebrew2",
|
||||
ARABIC_ALPHA = "arabicAlpha",
|
||||
ARABIC_ABJAD = "arabicAbjad",
|
||||
HINDI_VOWELS = "hindiVowels",
|
||||
HINDI_CONSONANTS = "hindiConsonants",
|
||||
HINDI_NUMBERS = "hindiNumbers",
|
||||
HINDI_COUNTING = "hindiCounting",
|
||||
THAI_LETTERS = "thaiLetters",
|
||||
THAI_NUMBERS = "thaiNumbers",
|
||||
THAI_COUNTING = "thaiCounting",
|
||||
BAHT_TEXT = "bahtText",
|
||||
DOLLAR_TEXT = "dollarText",
|
||||
CUSTOM = "custom",
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const LevelFormat = {
|
||||
DECIMAL: "decimal",
|
||||
UPPER_ROMAN: "upperRoman",
|
||||
LOWER_ROMAN: "lowerRoman",
|
||||
UPPER_LETTER: "upperLetter",
|
||||
LOWER_LETTER: "lowerLetter",
|
||||
ORDINAL: "ordinal",
|
||||
CARDINAL_TEXT: "cardinalText",
|
||||
ORDINAL_TEXT: "ordinalText",
|
||||
HEX: "hex",
|
||||
CHICAGO: "chicago",
|
||||
IDEOGRAPH__DIGITAL: "ideographDigital",
|
||||
JAPANESE_COUNTING: "japaneseCounting",
|
||||
AIUEO: "aiueo",
|
||||
IROHA: "iroha",
|
||||
DECIMAL_FULL_WIDTH: "decimalFullWidth",
|
||||
DECIMAL_HALF_WIDTH: "decimalHalfWidth",
|
||||
JAPANESE_LEGAL: "japaneseLegal",
|
||||
JAPANESE_DIGITAL_TEN_THOUSAND: "japaneseDigitalTenThousand",
|
||||
DECIMAL_ENCLOSED_CIRCLE: "decimalEnclosedCircle",
|
||||
DECIMAL_FULL_WIDTH2: "decimalFullWidth2",
|
||||
AIUEO_FULL_WIDTH: "aiueoFullWidth",
|
||||
IROHA_FULL_WIDTH: "irohaFullWidth",
|
||||
DECIMAL_ZERO: "decimalZero",
|
||||
BULLET: "bullet",
|
||||
GANADA: "ganada",
|
||||
CHOSUNG: "chosung",
|
||||
DECIMAL_ENCLOSED_FULLSTOP: "decimalEnclosedFullstop",
|
||||
DECIMAL_ENCLOSED_PARENTHESES: "decimalEnclosedParen",
|
||||
DECIMAL_ENCLOSED_CIRCLE_CHINESE: "decimalEnclosedCircleChinese",
|
||||
IDEOGRAPH_ENCLOSED_CIRCLE: "ideographEnclosedCircle",
|
||||
IDEOGRAPH_TRADITIONAL: "ideographTraditional",
|
||||
IDEOGRAPH_ZODIAC: "ideographZodiac",
|
||||
IDEOGRAPH_ZODIAC_TRADITIONAL: "ideographZodiacTraditional",
|
||||
TAIWANESE_COUNTING: "taiwaneseCounting",
|
||||
IDEOGRAPH_LEGAL_TRADITIONAL: "ideographLegalTraditional",
|
||||
TAIWANESE_COUNTING_THOUSAND: "taiwaneseCountingThousand",
|
||||
TAIWANESE_DIGITAL: "taiwaneseDigital",
|
||||
CHINESE_COUNTING: "chineseCounting",
|
||||
CHINESE_LEGAL_SIMPLIFIED: "chineseLegalSimplified",
|
||||
CHINESE_COUNTING_THOUSAND: "chineseCountingThousand",
|
||||
KOREAN_DIGITAL: "koreanDigital",
|
||||
KOREAN_COUNTING: "koreanCounting",
|
||||
KOREAN_LEGAL: "koreanLegal",
|
||||
KOREAN_DIGITAL2: "koreanDigital2",
|
||||
VIETNAMESE_COUNTING: "vietnameseCounting",
|
||||
RUSSIAN_LOWER: "russianLower",
|
||||
RUSSIAN_UPPER: "russianUpper",
|
||||
NONE: "none",
|
||||
NUMBER_IN_DASH: "numberInDash",
|
||||
HEBREW1: "hebrew1",
|
||||
HEBREW2: "hebrew2",
|
||||
ARABIC_ALPHA: "arabicAlpha",
|
||||
ARABIC_ABJAD: "arabicAbjad",
|
||||
HINDI_VOWELS: "hindiVowels",
|
||||
HINDI_CONSONANTS: "hindiConsonants",
|
||||
HINDI_NUMBERS: "hindiNumbers",
|
||||
HINDI_COUNTING: "hindiCounting",
|
||||
THAI_LETTERS: "thaiLetters",
|
||||
THAI_NUMBERS: "thaiNumbers",
|
||||
THAI_COUNTING: "thaiCounting",
|
||||
BAHT_TEXT: "bahtText",
|
||||
DOLLAR_TEXT: "dollarText",
|
||||
CUSTOM: "custom",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
class LevelAttributes extends XmlAttributeComponent<{
|
||||
readonly ilvl?: number;
|
||||
@ -182,7 +186,7 @@ class LevelText extends XmlComponent {
|
||||
}
|
||||
|
||||
class LevelJc extends XmlComponent {
|
||||
public constructor(value: AlignmentType) {
|
||||
public constructor(value: (typeof AlignmentType)[keyof typeof AlignmentType]) {
|
||||
super("w:lvlJc");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
@ -192,19 +196,19 @@ class LevelJc extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export enum LevelSuffix {
|
||||
NOTHING = "nothing",
|
||||
SPACE = "space",
|
||||
TAB = "tab",
|
||||
}
|
||||
export const LevelSuffix = {
|
||||
NOTHING: "nothing",
|
||||
SPACE: "space",
|
||||
TAB: "tab",
|
||||
} as const;
|
||||
|
||||
export interface ILevelsOptions {
|
||||
readonly level: number;
|
||||
readonly format?: LevelFormat;
|
||||
readonly format?: (typeof LevelFormat)[keyof typeof LevelFormat];
|
||||
readonly text?: string;
|
||||
readonly alignment?: AlignmentType;
|
||||
readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
|
||||
readonly start?: number;
|
||||
readonly suffix?: LevelSuffix;
|
||||
readonly suffix?: (typeof LevelSuffix)[keyof typeof LevelSuffix];
|
||||
readonly isLegalNumberingStyle?: boolean;
|
||||
readonly style?: {
|
||||
readonly run?: IRunStylePropertiesOptions;
|
||||
@ -223,7 +227,7 @@ export interface ILevelsOptions {
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
class Suffix extends XmlComponent {
|
||||
public constructor(value: LevelSuffix) {
|
||||
public constructor(value: (typeof LevelSuffix)[keyof typeof LevelSuffix]) {
|
||||
super("w:suff");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
|
@ -19,41 +19,47 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
// <xsd:enumeration value="right"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum AlignmentType {
|
||||
/** Align Start */
|
||||
START = "start",
|
||||
/** Align Center */
|
||||
CENTER = "center",
|
||||
/** End */
|
||||
END = "end",
|
||||
/** Justified */
|
||||
BOTH = "both",
|
||||
/** Medium Kashida Length */
|
||||
MEDIUM_KASHIDA = "mediumKashida",
|
||||
/** Distribute All Characters Equally */
|
||||
DISTRIBUTE = "distribute",
|
||||
/** Align to List Tab */
|
||||
NUM_TAB = "numTab",
|
||||
/** Widest Kashida Length */
|
||||
HIGH_KASHIDA = "highKashida",
|
||||
/** Low Kashida Length */
|
||||
LOW_KASHIDA = "lowKashida",
|
||||
/** Thai Language Justification */
|
||||
THAI_DISTRIBUTE = "thaiDistribute",
|
||||
/** Align Left */
|
||||
LEFT = "left",
|
||||
/** Align Right */
|
||||
RIGHT = "right",
|
||||
/** Justified */
|
||||
JUSTIFIED = "both",
|
||||
}
|
||||
|
||||
export class AlignmentAttributes extends XmlAttributeComponent<{ readonly val: AlignmentType }> {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const AlignmentType = {
|
||||
/** Align Start */
|
||||
START: "start",
|
||||
/** Align Center */
|
||||
CENTER: "center",
|
||||
/** End */
|
||||
END: "end",
|
||||
/** Justified */
|
||||
BOTH: "both",
|
||||
/** Medium Kashida Length */
|
||||
MEDIUM_KASHIDA: "mediumKashida",
|
||||
/** Distribute All Characters Equally */
|
||||
DISTRIBUTE: "distribute",
|
||||
/** Align to List Tab */
|
||||
NUM_TAB: "numTab",
|
||||
/** Widest Kashida Length */
|
||||
HIGH_KASHIDA: "highKashida",
|
||||
/** Low Kashida Length */
|
||||
LOW_KASHIDA: "lowKashida",
|
||||
/** Thai Language Justification */
|
||||
THAI_DISTRIBUTE: "thaiDistribute",
|
||||
/** Align Left */
|
||||
LEFT: "left",
|
||||
/** Align Right */
|
||||
RIGHT: "right",
|
||||
/** Justified */
|
||||
JUSTIFIED: "both",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
export class AlignmentAttributes extends XmlAttributeComponent<{
|
||||
readonly val: (typeof AlignmentType)[keyof typeof AlignmentType];
|
||||
}> {
|
||||
protected readonly xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
||||
export class Alignment extends XmlComponent {
|
||||
public constructor(type: AlignmentType) {
|
||||
public constructor(type: (typeof AlignmentType)[keyof typeof AlignmentType]) {
|
||||
super("w:jc");
|
||||
this.root.push(new AlignmentAttributes({ val: type }));
|
||||
}
|
||||
|
@ -2,14 +2,14 @@
|
||||
import { Attributes, XmlComponent } from "@file/xml-components";
|
||||
import { Run } from "../run";
|
||||
|
||||
enum BreakType {
|
||||
COLUMN = "column",
|
||||
PAGE = "page",
|
||||
const BreakType = {
|
||||
COLUMN: "column",
|
||||
PAGE: "page",
|
||||
// textWrapping breaks are the default and already exposed via the "Run" class
|
||||
}
|
||||
} as const;
|
||||
|
||||
class Break extends XmlComponent {
|
||||
public constructor(type: BreakType) {
|
||||
public constructor(type: (typeof BreakType)[keyof typeof BreakType]) {
|
||||
super("w:br");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
|
@ -1,17 +1,19 @@
|
||||
// http://officeopenxml.com/WPspacing.php
|
||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
|
||||
export enum LineRuleType {
|
||||
AT_LEAST = "atLeast",
|
||||
EXACTLY = "exactly",
|
||||
EXACT = "exact",
|
||||
AUTO = "auto",
|
||||
}
|
||||
export const LineRuleType = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
AT_LEAST: "atLeast",
|
||||
EXACTLY: "exactly",
|
||||
EXACT: "exact",
|
||||
AUTO: "auto",
|
||||
} as const;
|
||||
|
||||
export interface ISpacingProperties {
|
||||
readonly after?: number;
|
||||
readonly before?: number;
|
||||
readonly line?: number;
|
||||
readonly lineRule?: LineRuleType;
|
||||
readonly lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType];
|
||||
readonly beforeAutoSpacing?: boolean;
|
||||
readonly afterAutoSpacing?: boolean;
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { Attributes, XmlComponent } from "@file/xml-components";
|
||||
|
||||
export enum HeadingLevel {
|
||||
HEADING_1 = "Heading1",
|
||||
HEADING_2 = "Heading2",
|
||||
HEADING_3 = "Heading3",
|
||||
HEADING_4 = "Heading4",
|
||||
HEADING_5 = "Heading5",
|
||||
HEADING_6 = "Heading6",
|
||||
TITLE = "Title",
|
||||
}
|
||||
export const HeadingLevel = {
|
||||
HEADING_1: "Heading1",
|
||||
HEADING_2: "Heading2",
|
||||
HEADING_3: "Heading3",
|
||||
HEADING_4: "Heading4",
|
||||
HEADING_5: "Heading5",
|
||||
HEADING_6: "Heading6",
|
||||
TITLE: "Title",
|
||||
} as const;
|
||||
|
||||
export class Style extends XmlComponent {
|
||||
public constructor(styleId: string) {
|
||||
|
@ -2,9 +2,9 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
|
||||
export interface TabStopDefinition {
|
||||
readonly type: TabStopType;
|
||||
readonly position: number | TabStopPosition;
|
||||
readonly leader?: LeaderType;
|
||||
readonly type: (typeof TabStopType)[keyof typeof TabStopType];
|
||||
readonly position: number | (typeof TabStopPosition)[keyof typeof TabStopPosition];
|
||||
readonly leader?: (typeof LeaderType)[keyof typeof LeaderType];
|
||||
}
|
||||
|
||||
export class TabStop extends XmlComponent {
|
||||
@ -17,34 +17,35 @@ export class TabStop extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export enum TabStopType {
|
||||
LEFT = "left",
|
||||
RIGHT = "right",
|
||||
CENTER = "center",
|
||||
BAR = "bar",
|
||||
CLEAR = "clear",
|
||||
DECIMAL = "decimal",
|
||||
END = "end",
|
||||
NUM = "num",
|
||||
START = "start",
|
||||
}
|
||||
export const TabStopType = {
|
||||
LEFT: "left",
|
||||
RIGHT: "right",
|
||||
CENTER: "center",
|
||||
BAR: "bar",
|
||||
CLEAR: "clear",
|
||||
DECIMAL: "decimal",
|
||||
END: "end",
|
||||
NUM: "num",
|
||||
START: "start",
|
||||
} as const;
|
||||
|
||||
export enum LeaderType {
|
||||
DOT = "dot",
|
||||
HYPHEN = "hyphen",
|
||||
MIDDLE_DOT = "middleDot",
|
||||
NONE = "none",
|
||||
UNDERSCORE = "underscore",
|
||||
}
|
||||
export const LeaderType = {
|
||||
DOT: "dot",
|
||||
HYPHEN: "hyphen",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
MIDDLE_DOT: "middleDot",
|
||||
NONE: "none",
|
||||
UNDERSCORE: "underscore",
|
||||
} as const;
|
||||
|
||||
export enum TabStopPosition {
|
||||
MAX = 9026,
|
||||
}
|
||||
export const TabStopPosition = {
|
||||
MAX: 9026,
|
||||
} as const;
|
||||
|
||||
export class TabAttributes extends XmlAttributeComponent<{
|
||||
readonly val: TabStopType;
|
||||
readonly val: (typeof TabStopType)[keyof typeof TabStopType];
|
||||
readonly pos: string | number;
|
||||
readonly leader?: LeaderType;
|
||||
readonly leader?: (typeof LeaderType)[keyof typeof LeaderType];
|
||||
}> {
|
||||
protected readonly xmlKeys = { val: "w:val", pos: "w:pos", leader: "w:leader" };
|
||||
}
|
||||
|
@ -3,43 +3,44 @@ import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared/ali
|
||||
import { HeightRule } from "@file/table";
|
||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
|
||||
export enum DropCapType {
|
||||
NONE = "none",
|
||||
DROP = "drop",
|
||||
MARGIN = "margin",
|
||||
}
|
||||
export const DropCapType = {
|
||||
NONE: "none",
|
||||
DROP: "drop",
|
||||
MARGIN: "margin",
|
||||
} as const;
|
||||
|
||||
export enum FrameAnchorType {
|
||||
MARGIN = "margin",
|
||||
PAGE = "page",
|
||||
TEXT = "text",
|
||||
}
|
||||
export const FrameAnchorType = {
|
||||
MARGIN: "margin",
|
||||
PAGE: "page",
|
||||
TEXT: "text",
|
||||
} as const;
|
||||
|
||||
export enum FrameWrap {
|
||||
AROUND = "around",
|
||||
AUTO = "auto",
|
||||
NONE = "none",
|
||||
NOT_BESIDE = "notBeside",
|
||||
THROUGH = "through",
|
||||
TIGHT = "tight",
|
||||
}
|
||||
export const FrameWrap = {
|
||||
AROUND: "around",
|
||||
AUTO: "auto",
|
||||
NONE: "none",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
NOT_BESIDE: "notBeside",
|
||||
THROUGH: "through",
|
||||
TIGHT: "tight",
|
||||
} as const;
|
||||
|
||||
interface IBaseFrameOptions {
|
||||
readonly anchorLock?: boolean;
|
||||
readonly dropCap?: DropCapType;
|
||||
readonly dropCap?: (typeof DropCapType)[keyof typeof DropCapType];
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly wrap?: FrameWrap;
|
||||
readonly wrap?: (typeof FrameWrap)[keyof typeof FrameWrap];
|
||||
readonly lines?: number;
|
||||
readonly anchor: {
|
||||
readonly horizontal: FrameAnchorType;
|
||||
readonly vertical: FrameAnchorType;
|
||||
readonly horizontal: (typeof FrameAnchorType)[keyof typeof FrameAnchorType];
|
||||
readonly vertical: (typeof FrameAnchorType)[keyof typeof FrameAnchorType];
|
||||
};
|
||||
readonly space?: {
|
||||
readonly horizontal: number;
|
||||
readonly vertical: number;
|
||||
};
|
||||
readonly rule?: HeightRule;
|
||||
readonly rule?: (typeof HeightRule)[keyof typeof HeightRule];
|
||||
}
|
||||
|
||||
export interface IXYFrameOptions extends IBaseFrameOptions {
|
||||
@ -51,8 +52,8 @@ export interface IXYFrameOptions extends IBaseFrameOptions {
|
||||
|
||||
export interface IAlignmentFrameOptions extends IBaseFrameOptions {
|
||||
readonly alignment: {
|
||||
readonly x: HorizontalPositionAlign;
|
||||
readonly y: VerticalPositionAlign;
|
||||
readonly x: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];
|
||||
readonly y: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,20 +63,20 @@ export type IFrameOptions = IXYFrameOptions | IAlignmentFrameOptions;
|
||||
|
||||
export class FramePropertiesAttributes extends XmlAttributeComponent<{
|
||||
readonly anchorLock?: boolean;
|
||||
readonly dropCap?: DropCapType;
|
||||
readonly dropCap?: (typeof DropCapType)[keyof typeof DropCapType];
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly x?: number;
|
||||
readonly y?: number;
|
||||
readonly wrap?: FrameWrap;
|
||||
readonly wrap?: (typeof FrameWrap)[keyof typeof FrameWrap];
|
||||
readonly lines?: number;
|
||||
readonly anchorHorizontal?: FrameAnchorType;
|
||||
readonly anchorVertical?: FrameAnchorType;
|
||||
readonly anchorHorizontal?: (typeof FrameAnchorType)[keyof typeof FrameAnchorType];
|
||||
readonly anchorVertical?: (typeof FrameAnchorType)[keyof typeof FrameAnchorType];
|
||||
readonly spaceHorizontal?: number;
|
||||
readonly spaceVertical?: number;
|
||||
readonly rule?: HeightRule;
|
||||
readonly alignmentX?: HorizontalPositionAlign;
|
||||
readonly alignmentY?: VerticalPositionAlign;
|
||||
readonly rule?: (typeof HeightRule)[keyof typeof HeightRule];
|
||||
readonly alignmentX?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];
|
||||
readonly alignmentY?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];
|
||||
}> {
|
||||
protected readonly xmlKeys = {
|
||||
anchorLock: "w:anchorLock",
|
||||
|
@ -5,10 +5,10 @@ import { uniqueId } from "@util/convenience-functions";
|
||||
import { ParagraphChild } from "../paragraph";
|
||||
import { HyperlinkAttributes, IHyperlinkAttributesProperties } from "./hyperlink-attributes";
|
||||
|
||||
export enum HyperlinkType {
|
||||
INTERNAL = "INTERNAL",
|
||||
EXTERNAL = "EXTERNAL",
|
||||
}
|
||||
export const HyperlinkType = {
|
||||
INTERNAL: "INTERNAL",
|
||||
EXTERNAL: "EXTERNAL",
|
||||
} as const;
|
||||
|
||||
export class ConcreteHyperlink extends XmlComponent {
|
||||
public readonly linkId: string;
|
||||
@ -39,7 +39,12 @@ export class InternalHyperlink extends ConcreteHyperlink {
|
||||
}
|
||||
|
||||
export class ExternalHyperlink extends XmlComponent {
|
||||
public constructor(public readonly options: { readonly children: readonly ParagraphChild[]; readonly link: string }) {
|
||||
public constructor(
|
||||
public readonly options: {
|
||||
readonly children: readonly ParagraphChild[];
|
||||
readonly link: string;
|
||||
},
|
||||
) {
|
||||
super("w:externalHyperlink");
|
||||
}
|
||||
}
|
||||
|
@ -158,5 +158,37 @@ describe("ParagraphProperties", () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should create with the run property", () => {
|
||||
const properties = new ParagraphProperties({
|
||||
run: {
|
||||
size: "10pt",
|
||||
},
|
||||
});
|
||||
const tree = new Formatter().format(properties);
|
||||
|
||||
expect(tree).to.deep.equal({
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:rPr": [
|
||||
{
|
||||
"w:sz": {
|
||||
_attr: {
|
||||
"w:val": "10pt",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:szCs": {
|
||||
_attr: {
|
||||
"w:val": "10pt",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -15,9 +15,10 @@ import { NumberProperties } from "./formatting/unordered-list";
|
||||
import { WordWrap } from "./formatting/word-wrap";
|
||||
import { FrameProperties, IFrameOptions } from "./frame/frame-properties";
|
||||
import { OutlineLevel } from "./links";
|
||||
import { IRunOptions, RunProperties } from ".";
|
||||
|
||||
export interface ILevelParagraphStylePropertiesOptions {
|
||||
readonly alignment?: AlignmentType;
|
||||
readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
|
||||
readonly thematicBreak?: boolean;
|
||||
readonly contextualSpacing?: boolean;
|
||||
readonly rightTabStop?: number;
|
||||
@ -46,7 +47,7 @@ export interface IParagraphStylePropertiesOptions extends ILevelParagraphStylePr
|
||||
|
||||
export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOptions {
|
||||
readonly border?: IBordersOptions;
|
||||
readonly heading?: HeadingLevel;
|
||||
readonly heading?: (typeof HeadingLevel)[keyof typeof HeadingLevel];
|
||||
readonly bidirectional?: boolean;
|
||||
readonly pageBreakBefore?: boolean;
|
||||
readonly tabStops?: readonly TabStopDefinition[];
|
||||
@ -65,6 +66,10 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
|
||||
* This only works in Microsoft Word. It is not part of the ECMA-376 OOXML standard.
|
||||
*/
|
||||
readonly autoSpaceEastAsianText?: boolean;
|
||||
/**
|
||||
* Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.3.1.29.
|
||||
*/
|
||||
readonly run?: IRunOptions;
|
||||
}
|
||||
|
||||
export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
|
||||
@ -152,9 +157,9 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
|
||||
* Ensure there is only one w:tabs tag with multiple w:tab
|
||||
*/
|
||||
const tabDefinitions: readonly TabStopDefinition[] = [
|
||||
...(options.rightTabStop ? [{ type: TabStopType.RIGHT, position: options.rightTabStop }] : []),
|
||||
...(options.rightTabStop !== undefined ? [{ type: TabStopType.RIGHT, position: options.rightTabStop }] : []),
|
||||
...(options.tabStops ? options.tabStops : []),
|
||||
...(options.leftTabStop ? [{ type: TabStopType.LEFT, position: options.leftTabStop }] : []),
|
||||
...(options.leftTabStop !== undefined ? [{ type: TabStopType.LEFT, position: options.leftTabStop }] : []),
|
||||
];
|
||||
|
||||
if (tabDefinitions.length > 0) {
|
||||
@ -195,6 +200,10 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
|
||||
if (options.autoSpaceEastAsianText !== undefined) {
|
||||
this.push(new OnOffElement("w:autoSpaceDN", options.autoSpaceEastAsianText));
|
||||
}
|
||||
|
||||
if (options.run) {
|
||||
this.push(new RunProperties(options.run));
|
||||
}
|
||||
}
|
||||
|
||||
public push(item: XmlComponent): void {
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { Attributes, XmlComponent } from "@file/xml-components";
|
||||
|
||||
export enum EmphasisMarkType {
|
||||
DOT = "dot",
|
||||
}
|
||||
export const EmphasisMarkType = {
|
||||
DOT: "dot",
|
||||
} as const;
|
||||
|
||||
export abstract class BaseEmphasisMark extends XmlComponent {
|
||||
protected constructor(emphasisMarkType: EmphasisMarkType) {
|
||||
protected constructor(emphasisMarkType: (typeof EmphasisMarkType)[keyof typeof EmphasisMarkType]) {
|
||||
super("w:em");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
@ -16,7 +16,7 @@ export abstract class BaseEmphasisMark extends XmlComponent {
|
||||
}
|
||||
|
||||
export class EmphasisMark extends BaseEmphasisMark {
|
||||
public constructor(emphasisMarkType: EmphasisMarkType = EmphasisMarkType.DOT) {
|
||||
public constructor(emphasisMarkType: (typeof EmphasisMarkType)[keyof typeof EmphasisMarkType] = EmphasisMarkType.DOT) {
|
||||
super(emphasisMarkType);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
|
||||
enum FieldCharacterType {
|
||||
BEGIN = "begin",
|
||||
END = "end",
|
||||
SEPARATE = "separate",
|
||||
}
|
||||
const FieldCharacterType = {
|
||||
BEGIN: "begin",
|
||||
END: "end",
|
||||
SEPARATE: "separate",
|
||||
} as const;
|
||||
|
||||
class FidCharAttrs extends XmlAttributeComponent<{ readonly type: FieldCharacterType; readonly dirty?: boolean }> {
|
||||
class FidCharAttrs extends XmlAttributeComponent<{
|
||||
readonly type: (typeof FieldCharacterType)[keyof typeof FieldCharacterType];
|
||||
readonly dirty?: boolean;
|
||||
}> {
|
||||
protected readonly xmlKeys = { type: "w:fldCharType", dirty: "w:dirty" };
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,11 @@ import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
// <xsd:enumeration value="right" />
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PositionalTabAlignment {
|
||||
LEFT = "left",
|
||||
CENTER = "center",
|
||||
RIGHT = "right",
|
||||
}
|
||||
export const PositionalTabAlignment = {
|
||||
LEFT: "left",
|
||||
CENTER: "center",
|
||||
RIGHT: "right",
|
||||
} as const;
|
||||
|
||||
// <xsd:simpleType name="ST_PTabRelativeTo">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
@ -19,10 +19,10 @@ export enum PositionalTabAlignment {
|
||||
// <xsd:enumeration value="indent" />
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PositionalTabRelativeTo {
|
||||
MARGIN = "margin",
|
||||
INDENT = "indent",
|
||||
}
|
||||
export const PositionalTabRelativeTo = {
|
||||
MARGIN: "margin",
|
||||
INDENT: "indent",
|
||||
} as const;
|
||||
|
||||
// <xsd:simpleType name="ST_PTabLeader">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
@ -33,18 +33,19 @@ export enum PositionalTabRelativeTo {
|
||||
// <xsd:enumeration value="middleDot" />
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum PositionalTabLeader {
|
||||
NONE = "none",
|
||||
DOT = "dot",
|
||||
HYPHEN = "hyphen",
|
||||
UNDERSCORE = "underscore",
|
||||
MIDDLE_DOT = "middleDot",
|
||||
}
|
||||
export const PositionalTabLeader = {
|
||||
NONE: "none",
|
||||
DOT: "dot",
|
||||
HYPHEN: "hyphen",
|
||||
UNDERSCORE: "underscore",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
MIDDLE_DOT: "middleDot",
|
||||
} as const;
|
||||
|
||||
export interface PositionalTabOptions {
|
||||
readonly alignment: PositionalTabAlignment;
|
||||
readonly relativeTo: PositionalTabRelativeTo;
|
||||
readonly leader: PositionalTabLeader;
|
||||
readonly alignment: (typeof PositionalTabAlignment)[keyof typeof PositionalTabAlignment];
|
||||
readonly relativeTo: (typeof PositionalTabRelativeTo)[keyof typeof PositionalTabRelativeTo];
|
||||
readonly leader: (typeof PositionalTabLeader)[keyof typeof PositionalTabLeader];
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_PTab">
|
||||
@ -58,9 +59,9 @@ export class PositionalTab extends XmlComponent {
|
||||
|
||||
this.root.push(
|
||||
new NextAttributeComponent<{
|
||||
readonly alignment: PositionalTabAlignment;
|
||||
readonly relativeTo: PositionalTabRelativeTo;
|
||||
readonly leader: PositionalTabLeader;
|
||||
readonly alignment: (typeof PositionalTabAlignment)[keyof typeof PositionalTabAlignment];
|
||||
readonly relativeTo: (typeof PositionalTabRelativeTo)[keyof typeof PositionalTabRelativeTo];
|
||||
readonly leader: (typeof PositionalTabLeader)[keyof typeof PositionalTabLeader];
|
||||
}>({
|
||||
alignment: {
|
||||
key: "w:alignment",
|
||||
|
@ -25,15 +25,18 @@ interface IFontOptions {
|
||||
readonly hint?: string;
|
||||
}
|
||||
|
||||
export enum TextEffect {
|
||||
BLINK_BACKGROUND = "blinkBackground",
|
||||
LIGHTS = "lights",
|
||||
ANTS_BLACK = "antsBlack",
|
||||
ANTS_RED = "antsRed",
|
||||
SHIMMER = "shimmer",
|
||||
SPARKLE = "sparkle",
|
||||
NONE = "none",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const TextEffect = {
|
||||
BLINK_BACKGROUND: "blinkBackground",
|
||||
LIGHTS: "lights",
|
||||
ANTS_BLACK: "antsBlack",
|
||||
ANTS_RED: "antsRed",
|
||||
SHIMMER: "shimmer",
|
||||
SPARKLE: "sparkle",
|
||||
NONE: "none",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
export interface IRunStylePropertiesOptions {
|
||||
readonly noProof?: boolean;
|
||||
@ -43,11 +46,11 @@ export interface IRunStylePropertiesOptions {
|
||||
readonly italicsComplexScript?: boolean;
|
||||
readonly underline?: {
|
||||
readonly color?: string;
|
||||
readonly type?: UnderlineType;
|
||||
readonly type?: (typeof UnderlineType)[keyof typeof UnderlineType];
|
||||
};
|
||||
readonly effect?: TextEffect;
|
||||
readonly effect?: (typeof TextEffect)[keyof typeof TextEffect];
|
||||
readonly emphasisMark?: {
|
||||
readonly type?: EmphasisMarkType;
|
||||
readonly type?: (typeof EmphasisMarkType)[keyof typeof EmphasisMarkType];
|
||||
};
|
||||
readonly color?: string;
|
||||
readonly kern?: number | PositiveUniversalMeasure;
|
||||
@ -127,6 +130,8 @@ export interface IRunPropertiesChangeOptions extends IRunPropertiesOptions, ICha
|
||||
// <xsd:element name="oMath" type="CT_OnOff"/>
|
||||
// </xsd:choice>
|
||||
// </xsd:group>
|
||||
/* eslint-disable functional/immutable-data */
|
||||
|
||||
export class RunProperties extends IgnoreIfEmptyXmlComponent {
|
||||
public constructor(options?: IRunPropertiesOptions) {
|
||||
super("w:rPr");
|
||||
@ -261,7 +266,7 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent {
|
||||
this.push(new BorderElement("w:bdr", options.border));
|
||||
}
|
||||
|
||||
if (options.snapToGrid) {
|
||||
if (options.snapToGrid !== undefined) {
|
||||
this.push(new OnOffElement("w:snapToGrid", options.snapToGrid));
|
||||
}
|
||||
|
||||
@ -294,6 +299,8 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
export class RunPropertiesChange extends XmlComponent {
|
||||
public constructor(options: IRunPropertiesChangeOptions) {
|
||||
super("w:rPrChange");
|
||||
|
@ -12,7 +12,7 @@ import { TextAttributes } from "../text-attributes";
|
||||
// </xsd:complexType>
|
||||
|
||||
interface ITextOptions {
|
||||
readonly space?: SpaceType;
|
||||
readonly space?: (typeof SpaceType)[keyof typeof SpaceType];
|
||||
readonly text?: string;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ export interface IRunOptions extends IRunPropertiesOptions {
|
||||
| FieldInstruction
|
||||
| Separate
|
||||
| End
|
||||
| PageNumber
|
||||
| (typeof PageNumber)[keyof typeof PageNumber]
|
||||
| FootnoteReferenceRun
|
||||
| Break
|
||||
| AnnotationReference
|
||||
@ -98,11 +98,14 @@ export interface IRunOptions extends IRunPropertiesOptions {
|
||||
readonly text?: string;
|
||||
}
|
||||
|
||||
export enum PageNumber {
|
||||
CURRENT = "CURRENT",
|
||||
TOTAL_PAGES = "TOTAL_PAGES",
|
||||
TOTAL_PAGES_IN_SECTION = "TOTAL_PAGES_IN_SECTION",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const PageNumber = {
|
||||
CURRENT: "CURRENT",
|
||||
TOTAL_PAGES: "TOTAL_PAGES",
|
||||
TOTAL_PAGES_IN_SECTION: "TOTAL_PAGES_IN_SECTION",
|
||||
} as const;
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
export class Run extends XmlComponent {
|
||||
protected readonly properties: RunProperties;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { SpaceType } from "@file/shared";
|
||||
import { XmlAttributeComponent } from "@file/xml-components";
|
||||
|
||||
export class TextAttributes extends XmlAttributeComponent<{ readonly space: SpaceType }> {
|
||||
export class TextAttributes extends XmlAttributeComponent<{
|
||||
readonly space: (typeof SpaceType)[keyof typeof SpaceType];
|
||||
}> {
|
||||
protected readonly xmlKeys = { space: "xml:space" };
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
import { Attributes, XmlComponent } from "@file/xml-components";
|
||||
import { hexColorValue } from "@util/values";
|
||||
|
||||
export enum UnderlineType {
|
||||
SINGLE = "single",
|
||||
WORDS = "words",
|
||||
DOUBLE = "double",
|
||||
THICK = "thick",
|
||||
DOTTED = "dotted",
|
||||
DOTTEDHEAVY = "dottedHeavy",
|
||||
DASH = "dash",
|
||||
DASHEDHEAVY = "dashedHeavy",
|
||||
DASHLONG = "dashLong",
|
||||
DASHLONGHEAVY = "dashLongHeavy",
|
||||
DOTDASH = "dotDash",
|
||||
DASHDOTHEAVY = "dashDotHeavy",
|
||||
DOTDOTDASH = "dotDotDash",
|
||||
DASHDOTDOTHEAVY = "dashDotDotHeavy",
|
||||
WAVE = "wave",
|
||||
WAVYHEAVY = "wavyHeavy",
|
||||
WAVYDOUBLE = "wavyDouble",
|
||||
NONE = "none",
|
||||
}
|
||||
export const UnderlineType = {
|
||||
SINGLE: "single",
|
||||
WORDS: "words",
|
||||
DOUBLE: "double",
|
||||
THICK: "thick",
|
||||
DOTTED: "dotted",
|
||||
DOTTEDHEAVY: "dottedHeavy",
|
||||
DASH: "dash",
|
||||
DASHEDHEAVY: "dashedHeavy",
|
||||
DASHLONG: "dashLong",
|
||||
DASHLONGHEAVY: "dashLongHeavy",
|
||||
DOTDASH: "dotDash",
|
||||
DASHDOTHEAVY: "dashDotHeavy",
|
||||
DOTDOTDASH: "dotDotDash",
|
||||
DASHDOTDOTHEAVY: "dashDotDotHeavy",
|
||||
WAVE: "wave",
|
||||
WAVYHEAVY: "wavyHeavy",
|
||||
WAVYDOUBLE: "wavyDouble",
|
||||
NONE: "none",
|
||||
} as const;
|
||||
|
||||
export class Underline extends XmlComponent {
|
||||
public constructor(underlineType: UnderlineType = UnderlineType.SINGLE, color?: string) {
|
||||
public constructor(underlineType: (typeof UnderlineType)[keyof typeof UnderlineType] = UnderlineType.SINGLE, color?: string) {
|
||||
super("w:u");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
|
@ -19,12 +19,17 @@ export type RelationshipType =
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
|
||||
|
||||
export enum TargetModeType {
|
||||
EXTERNAL = "External",
|
||||
}
|
||||
export const TargetModeType = {
|
||||
EXTERNAL: "External",
|
||||
} as const;
|
||||
|
||||
export class Relationship extends XmlComponent {
|
||||
public constructor(id: string, type: RelationshipType, target: string, targetMode?: TargetModeType) {
|
||||
public constructor(
|
||||
id: string,
|
||||
type: RelationshipType,
|
||||
target: string,
|
||||
targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType],
|
||||
) {
|
||||
super("Relationship");
|
||||
|
||||
this.root.push(
|
||||
|
@ -12,7 +12,12 @@ export class Relationships extends XmlComponent {
|
||||
);
|
||||
}
|
||||
|
||||
public createRelationship(id: number | string, type: RelationshipType, target: string, targetMode?: TargetModeType): Relationship {
|
||||
public createRelationship(
|
||||
id: number | string,
|
||||
type: RelationshipType,
|
||||
target: string,
|
||||
targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType],
|
||||
): Relationship {
|
||||
const relationship = new Relationship(`rId${id}`, type, target, targetMode);
|
||||
this.root.push(relationship);
|
||||
|
||||
|
@ -112,6 +112,23 @@ describe("Settings", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should add defaultTabStop setting with version", () => {
|
||||
const settings = new Settings({
|
||||
defaultTabStop: 100,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(settings);
|
||||
expect(Object.keys(tree)).has.length(1);
|
||||
expect(tree["w:settings"]).to.be.an("array");
|
||||
expect(tree["w:settings"]).to.deep.include({
|
||||
"w:defaultTabStop": {
|
||||
_attr: {
|
||||
"w:val": 100,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Remove when deprecating compatibilityModeVersion
|
||||
it("should add compatibility setting with legacy version", () => {
|
||||
const settings = new Settings({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { OnOffElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
import { NumberValueElement, OnOffElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
|
||||
import { Compatibility, ICompatibilityOptions } from "./compatibility";
|
||||
|
||||
@ -152,6 +152,7 @@ export interface ISettingsOptions {
|
||||
readonly trackRevisions?: boolean;
|
||||
readonly updateFields?: boolean;
|
||||
readonly compatibility?: ICompatibilityOptions;
|
||||
readonly defaultTabStop?: number;
|
||||
}
|
||||
|
||||
export class Settings extends XmlComponent {
|
||||
@ -198,6 +199,11 @@ export class Settings extends XmlComponent {
|
||||
this.root.push(new OnOffElement("w:updateFields", options.updateFields));
|
||||
}
|
||||
|
||||
// https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_defaultTabStop_topic_ID0EIXSX.html
|
||||
if (options.defaultTabStop !== undefined) {
|
||||
this.root.push(new NumberValueElement("w:defaultTabStop", options.defaultTabStop));
|
||||
}
|
||||
|
||||
this.root.push(
|
||||
new Compatibility({
|
||||
...(options.compatibility ?? {}),
|
||||
|
@ -23,7 +23,7 @@ import { hexColorValue } from "@util/values";
|
||||
export interface IShadingAttributesProperties {
|
||||
readonly fill?: string;
|
||||
readonly color?: string;
|
||||
readonly type?: ShadingType;
|
||||
readonly type?: (typeof ShadingType)[keyof typeof ShadingType];
|
||||
}
|
||||
|
||||
class ShadingAttributes extends XmlAttributeComponent<IShadingAttributesProperties> {
|
||||
@ -47,42 +47,44 @@ export class Shading extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export enum ShadingType {
|
||||
CLEAR = "clear",
|
||||
DIAGONAL_CROSS = "diagCross",
|
||||
DIAGONAL_STRIPE = "diagStripe",
|
||||
HORIZONTAL_CROSS = "horzCross",
|
||||
HORIZONTAL_STRIPE = "horzStripe",
|
||||
NIL = "nil",
|
||||
PERCENT_5 = "pct5",
|
||||
PERCENT_10 = "pct10",
|
||||
PERCENT_12 = "pct12",
|
||||
PERCENT_15 = "pct15",
|
||||
PERCENT_20 = "pct20",
|
||||
PERCENT_25 = "pct25",
|
||||
PERCENT_30 = "pct30",
|
||||
PERCENT_35 = "pct35",
|
||||
PERCENT_37 = "pct37",
|
||||
PERCENT_40 = "pct40",
|
||||
PERCENT_45 = "pct45",
|
||||
PERCENT_50 = "pct50",
|
||||
PERCENT_55 = "pct55",
|
||||
PERCENT_60 = "pct60",
|
||||
PERCENT_62 = "pct62",
|
||||
PERCENT_65 = "pct65",
|
||||
PERCENT_70 = "pct70",
|
||||
PERCENT_75 = "pct75",
|
||||
PERCENT_80 = "pct80",
|
||||
PERCENT_85 = "pct85",
|
||||
PERCENT_87 = "pct87",
|
||||
PERCENT_90 = "pct90",
|
||||
PERCENT_95 = "pct95",
|
||||
REVERSE_DIAGONAL_STRIPE = "reverseDiagStripe",
|
||||
SOLID = "solid",
|
||||
THIN_DIAGONAL_CROSS = "thinDiagCross",
|
||||
THIN_DIAGONAL_STRIPE = "thinDiagStripe",
|
||||
THIN_HORIZONTAL_CROSS = "thinHorzCross",
|
||||
THIN_REVERSE_DIAGONAL_STRIPE = "thinReverseDiagStripe",
|
||||
THIN_VERTICAL_STRIPE = "thinVertStripe",
|
||||
VERTICAL_STRIPE = "vertStripe",
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const ShadingType = {
|
||||
CLEAR: "clear",
|
||||
DIAGONAL_CROSS: "diagCross",
|
||||
DIAGONAL_STRIPE: "diagStripe",
|
||||
HORIZONTAL_CROSS: "horzCross",
|
||||
HORIZONTAL_STRIPE: "horzStripe",
|
||||
NIL: "nil",
|
||||
PERCENT_5: "pct5",
|
||||
PERCENT_10: "pct10",
|
||||
PERCENT_12: "pct12",
|
||||
PERCENT_15: "pct15",
|
||||
PERCENT_20: "pct20",
|
||||
PERCENT_25: "pct25",
|
||||
PERCENT_30: "pct30",
|
||||
PERCENT_35: "pct35",
|
||||
PERCENT_37: "pct37",
|
||||
PERCENT_40: "pct40",
|
||||
PERCENT_45: "pct45",
|
||||
PERCENT_50: "pct50",
|
||||
PERCENT_55: "pct55",
|
||||
PERCENT_60: "pct60",
|
||||
PERCENT_62: "pct62",
|
||||
PERCENT_65: "pct65",
|
||||
PERCENT_70: "pct70",
|
||||
PERCENT_75: "pct75",
|
||||
PERCENT_80: "pct80",
|
||||
PERCENT_85: "pct85",
|
||||
PERCENT_87: "pct87",
|
||||
PERCENT_90: "pct90",
|
||||
PERCENT_95: "pct95",
|
||||
REVERSE_DIAGONAL_STRIPE: "reverseDiagStripe",
|
||||
SOLID: "solid",
|
||||
THIN_DIAGONAL_CROSS: "thinDiagCross",
|
||||
THIN_DIAGONAL_STRIPE: "thinDiagStripe",
|
||||
THIN_HORIZONTAL_CROSS: "thinHorzCross",
|
||||
THIN_REVERSE_DIAGONAL_STRIPE: "thinReverseDiagStripe",
|
||||
THIN_VERTICAL_STRIPE: "thinVertStripe",
|
||||
VERTICAL_STRIPE: "vertStripe",
|
||||
} as const;
|
||||
/* eslint-enable */
|
||||
|
@ -1,15 +1,15 @@
|
||||
export enum HorizontalPositionAlign {
|
||||
CENTER = "center",
|
||||
INSIDE = "inside",
|
||||
LEFT = "left",
|
||||
OUTSIDE = "outside",
|
||||
RIGHT = "right",
|
||||
}
|
||||
export const HorizontalPositionAlign = {
|
||||
CENTER: "center",
|
||||
INSIDE: "inside",
|
||||
LEFT: "left",
|
||||
OUTSIDE: "outside",
|
||||
RIGHT: "right",
|
||||
} as const;
|
||||
|
||||
export enum VerticalPositionAlign {
|
||||
BOTTOM = "bottom",
|
||||
CENTER = "center",
|
||||
INSIDE = "inside",
|
||||
OUTSIDE = "outside",
|
||||
TOP = "top",
|
||||
}
|
||||
export const VerticalPositionAlign = {
|
||||
BOTTOM: "bottom",
|
||||
CENTER: "center",
|
||||
INSIDE: "inside",
|
||||
OUTSIDE: "outside",
|
||||
TOP: "top",
|
||||
} as const;
|
||||
|
@ -66,68 +66,70 @@
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
|
||||
export enum NumberFormat {
|
||||
DECIMAL = "decimal",
|
||||
UPPER_ROMAN = "upperRoman",
|
||||
LOWER_ROMAN = "lowerRoman",
|
||||
UPPER_LETTER = "upperLetter",
|
||||
LOWER_LETTER = "lowerLetter",
|
||||
ORDINAL = "ordinal",
|
||||
CARDINAL_TEXT = "cardinalText",
|
||||
ORDINAL_TEXT = "ordinalText",
|
||||
HEX = "hex",
|
||||
CHICAGO = "chicago",
|
||||
IDEOGRAPH_DIGITAL = "ideographDigital",
|
||||
JAPANESE_COUNTING = "japaneseCounting",
|
||||
AIUEO = "aiueo",
|
||||
IROHA = "iroha",
|
||||
DECIMAL_FULL_WIDTH = "decimalFullWidth",
|
||||
DECIMAL_HALF_WIDTH = "decimalHalfWidth",
|
||||
JAPANESE_LEGAL = "japaneseLegal",
|
||||
JAPANESE_DIGITAL_TEN_THOUSAND = "japaneseDigitalTenThousand",
|
||||
DECIMAL_ENCLOSED_CIRCLE = "decimalEnclosedCircle",
|
||||
DECIMAL_FULL_WIDTH_2 = "decimalFullWidth2",
|
||||
AIUEO_FULL_WIDTH = "aiueoFullWidth",
|
||||
IROHA_FULL_WIDTH = "irohaFullWidth",
|
||||
DECIMAL_ZERO = "decimalZero",
|
||||
BULLET = "bullet",
|
||||
GANADA = "ganada",
|
||||
CHOSUNG = "chosung",
|
||||
DECIMAL_ENCLOSED_FULL_STOP = "decimalEnclosedFullstop",
|
||||
DECIMAL_ENCLOSED_PAREN = "decimalEnclosedParen",
|
||||
DECIMAL_ENCLOSED_CIRCLE_CHINESE = "decimalEnclosedCircleChinese",
|
||||
IDEOGRAPH_ENCLOSED_CIRCLE = "ideographEnclosedCircle",
|
||||
IDEOGRAPH_TRADITIONAL = "ideographTraditional",
|
||||
IDEOGRAPH_ZODIAC = "ideographZodiac",
|
||||
IDEOGRAPH_ZODIAC_TRADITIONAL = "ideographZodiacTraditional",
|
||||
TAIWANESE_COUNTING = "taiwaneseCounting",
|
||||
IDEOGRAPH_LEGAL_TRADITIONAL = "ideographLegalTraditional",
|
||||
TAIWANESE_COUNTING_THOUSAND = "taiwaneseCountingThousand",
|
||||
TAIWANESE_DIGITAL = "taiwaneseDigital",
|
||||
CHINESE_COUNTING = "chineseCounting",
|
||||
CHINESE_LEGAL_SIMPLIFIED = "chineseLegalSimplified",
|
||||
CHINESE_COUNTING_TEN_THOUSAND = "chineseCountingThousand",
|
||||
KOREAN_DIGITAL = "koreanDigital",
|
||||
KOREAN_COUNTING = "koreanCounting",
|
||||
KOREAN_LEGAL = "koreanLegal",
|
||||
KOREAN_DIGITAL_2 = "koreanDigital2",
|
||||
VIETNAMESE_COUNTING = "vietnameseCounting",
|
||||
RUSSIAN_LOWER = "russianLower",
|
||||
RUSSIAN_UPPER = "russianUpper",
|
||||
NONE = "none",
|
||||
NUMBER_IN_DASH = "numberInDash",
|
||||
HEBREW_1 = "hebrew1",
|
||||
HEBREW_2 = "hebrew2",
|
||||
ARABIC_ALPHA = "arabicAlpha",
|
||||
ARABIC_ABJAD = "arabicAbjad",
|
||||
HINDI_VOWELS = "hindiVowels",
|
||||
HINDI_CONSONANTS = "hindiConsonants",
|
||||
HINDI_NUMBERS = "hindiNumbers",
|
||||
HINDI_COUNTING = "hindiCounting",
|
||||
THAI_LETTERS = "thaiLetters",
|
||||
THAI_NUMBERS = "thaiNumbers",
|
||||
THAI_COUNTING = "thaiCounting",
|
||||
BAHT_TEXT = "bahtText",
|
||||
DOLLAR_TEXT = "dollarText",
|
||||
/* eslint-disable @typescript-eslint/naming-convention*/
|
||||
export const NumberFormat = {
|
||||
DECIMAL: "decimal",
|
||||
UPPER_ROMAN: "upperRoman",
|
||||
LOWER_ROMAN: "lowerRoman",
|
||||
UPPER_LETTER: "upperLetter",
|
||||
LOWER_LETTER: "lowerLetter",
|
||||
ORDINAL: "ordinal",
|
||||
CARDINAL_TEXT: "cardinalText",
|
||||
ORDINAL_TEXT: "ordinalText",
|
||||
HEX: "hex",
|
||||
CHICAGO: "chicago",
|
||||
IDEOGRAPH_DIGITAL: "ideographDigital",
|
||||
JAPANESE_COUNTING: "japaneseCounting",
|
||||
AIUEO: "aiueo",
|
||||
IROHA: "iroha",
|
||||
DECIMAL_FULL_WIDTH: "decimalFullWidth",
|
||||
DECIMAL_HALF_WIDTH: "decimalHalfWidth",
|
||||
JAPANESE_LEGAL: "japaneseLegal",
|
||||
JAPANESE_DIGITAL_TEN_THOUSAND: "japaneseDigitalTenThousand",
|
||||
DECIMAL_ENCLOSED_CIRCLE: "decimalEnclosedCircle",
|
||||
DECIMAL_FULL_WIDTH_2: "decimalFullWidth2",
|
||||
AIUEO_FULL_WIDTH: "aiueoFullWidth",
|
||||
IROHA_FULL_WIDTH: "irohaFullWidth",
|
||||
DECIMAL_ZERO: "decimalZero",
|
||||
BULLET: "bullet",
|
||||
GANADA: "ganada",
|
||||
CHOSUNG: "chosung",
|
||||
DECIMAL_ENCLOSED_FULL_STOP: "decimalEnclosedFullstop",
|
||||
DECIMAL_ENCLOSED_PAREN: "decimalEnclosedParen",
|
||||
DECIMAL_ENCLOSED_CIRCLE_CHINESE: "decimalEnclosedCircleChinese",
|
||||
IDEOGRAPH_ENCLOSED_CIRCLE: "ideographEnclosedCircle",
|
||||
IDEOGRAPH_TRADITIONAL: "ideographTraditional",
|
||||
IDEOGRAPH_ZODIAC: "ideographZodiac",
|
||||
IDEOGRAPH_ZODIAC_TRADITIONAL: "ideographZodiacTraditional",
|
||||
TAIWANESE_COUNTING: "taiwaneseCounting",
|
||||
IDEOGRAPH_LEGAL_TRADITIONAL: "ideographLegalTraditional",
|
||||
TAIWANESE_COUNTING_THOUSAND: "taiwaneseCountingThousand",
|
||||
TAIWANESE_DIGITAL: "taiwaneseDigital",
|
||||
CHINESE_COUNTING: "chineseCounting",
|
||||
CHINESE_LEGAL_SIMPLIFIED: "chineseLegalSimplified",
|
||||
CHINESE_COUNTING_TEN_THOUSAND: "chineseCountingThousand",
|
||||
KOREAN_DIGITAL: "koreanDigital",
|
||||
KOREAN_COUNTING: "koreanCounting",
|
||||
KOREAN_LEGAL: "koreanLegal",
|
||||
KOREAN_DIGITAL_2: "koreanDigital2",
|
||||
VIETNAMESE_COUNTING: "vietnameseCounting",
|
||||
RUSSIAN_LOWER: "russianLower",
|
||||
RUSSIAN_UPPER: "russianUpper",
|
||||
NONE: "none",
|
||||
NUMBER_IN_DASH: "numberInDash",
|
||||
HEBREW_1: "hebrew1",
|
||||
HEBREW_2: "hebrew2",
|
||||
ARABIC_ALPHA: "arabicAlpha",
|
||||
ARABIC_ABJAD: "arabicAbjad",
|
||||
HINDI_VOWELS: "hindiVowels",
|
||||
HINDI_CONSONANTS: "hindiConsonants",
|
||||
HINDI_NUMBERS: "hindiNumbers",
|
||||
HINDI_COUNTING: "hindiCounting",
|
||||
THAI_LETTERS: "thaiLetters",
|
||||
THAI_NUMBERS: "thaiNumbers",
|
||||
THAI_COUNTING: "thaiCounting",
|
||||
BAHT_TEXT: "bahtText",
|
||||
DOLLAR_TEXT: "dollarText",
|
||||
// <xsd:enumeration value="custom"/>
|
||||
}
|
||||
} as const;
|
||||
/* eslint-enable */
|
||||
|
@ -1,4 +1,4 @@
|
||||
export enum SpaceType {
|
||||
DEFAULT = "default",
|
||||
PRESERVE = "preserve",
|
||||
}
|
||||
export const SpaceType = {
|
||||
DEFAULT: "default",
|
||||
PRESERVE: "preserve",
|
||||
} as const;
|
||||
|
@ -80,18 +80,20 @@ export class GridSpan extends XmlComponent {
|
||||
/**
|
||||
* Vertical merge types.
|
||||
*/
|
||||
export enum VerticalMergeType {
|
||||
export const VerticalMergeType = {
|
||||
/**
|
||||
* Cell that is merged with upper one.
|
||||
*/
|
||||
CONTINUE = "continue",
|
||||
CONTINUE: "continue",
|
||||
/**
|
||||
* Cell that is starting the vertical merge.
|
||||
*/
|
||||
RESTART = "restart",
|
||||
}
|
||||
RESTART: "restart",
|
||||
} as const;
|
||||
|
||||
class VerticalMergeAttributes extends XmlAttributeComponent<{ readonly val: VerticalMergeType }> {
|
||||
class VerticalMergeAttributes extends XmlAttributeComponent<{
|
||||
readonly val: (typeof VerticalMergeType)[keyof typeof VerticalMergeType];
|
||||
}> {
|
||||
protected readonly xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
||||
@ -99,7 +101,7 @@ class VerticalMergeAttributes extends XmlAttributeComponent<{ readonly val: Vert
|
||||
* Vertical merge element. Should be used in a table cell.
|
||||
*/
|
||||
export class VerticalMerge extends XmlComponent {
|
||||
public constructor(value: VerticalMergeType) {
|
||||
public constructor(value: (typeof VerticalMergeType)[keyof typeof VerticalMergeType]) {
|
||||
super("w:vMerge");
|
||||
|
||||
this.root.push(
|
||||
@ -110,13 +112,18 @@ export class VerticalMerge extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export enum TextDirection {
|
||||
BOTTOM_TO_TOP_LEFT_TO_RIGHT = "btLr",
|
||||
LEFT_TO_RIGHT_TOP_TO_BOTTOM = "lrTb",
|
||||
TOP_TO_BOTTOM_RIGHT_TO_LEFT = "tbRl",
|
||||
}
|
||||
export const TextDirection = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
BOTTOM_TO_TOP_LEFT_TO_RIGHT: "btLr",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl",
|
||||
} as const;
|
||||
|
||||
class TDirectionAttributes extends XmlAttributeComponent<{ readonly val: TextDirection }> {
|
||||
class TDirectionAttributes extends XmlAttributeComponent<{
|
||||
readonly val: (typeof TextDirection)[keyof typeof TextDirection];
|
||||
}> {
|
||||
protected readonly xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
||||
@ -124,7 +131,7 @@ class TDirectionAttributes extends XmlAttributeComponent<{ readonly val: TextDir
|
||||
* Text Direction within a table cell
|
||||
*/
|
||||
export class TDirection extends XmlComponent {
|
||||
public constructor(value: TextDirection) {
|
||||
public constructor(value: (typeof TextDirection)[keyof typeof TextDirection]) {
|
||||
super("w:textDirection");
|
||||
|
||||
this.root.push(
|
||||
|
@ -17,9 +17,9 @@ import {
|
||||
export interface ITableCellPropertiesOptions {
|
||||
readonly shading?: IShadingAttributesProperties;
|
||||
readonly margins?: ITableCellMarginOptions;
|
||||
readonly verticalAlign?: VerticalAlign;
|
||||
readonly textDirection?: TextDirection;
|
||||
readonly verticalMerge?: VerticalMergeType;
|
||||
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
||||
readonly textDirection?: (typeof TextDirection)[keyof typeof TextDirection];
|
||||
readonly verticalMerge?: (typeof VerticalMergeType)[keyof typeof VerticalMergeType];
|
||||
readonly width?: ITableWidthProperties;
|
||||
readonly columnSpan?: number;
|
||||
readonly rowSpan?: number;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { IgnoreIfEmptyXmlComponent } from "@file/xml-components";
|
||||
import { TableWidthElement, WidthType } from "../table-width";
|
||||
import { TableWidthElement, WidthType } from "@file/table";
|
||||
|
||||
export interface ITableCellMarginOptions {
|
||||
readonly marginUnitType?: WidthType;
|
||||
readonly marginUnitType?: (typeof WidthType)[keyof typeof WidthType];
|
||||
readonly top?: number;
|
||||
readonly bottom?: number;
|
||||
readonly left?: number;
|
||||
@ -33,14 +33,15 @@ export interface ITableCellMarginOptions {
|
||||
// </xsd:sequence>
|
||||
// </xsd:complexType>
|
||||
|
||||
export enum TableCellMarginElementType {
|
||||
TABLE = "w:tblCellMar",
|
||||
TABLE_CELL = "w:tcMar",
|
||||
}
|
||||
export const TableCellMarginElementType = {
|
||||
TABLE: "w:tblCellMar",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
TABLE_CELL: "w:tcMar",
|
||||
} as const;
|
||||
|
||||
export class TableCellMargin extends IgnoreIfEmptyXmlComponent {
|
||||
public constructor(
|
||||
type: TableCellMarginElementType,
|
||||
type: (typeof TableCellMarginElementType)[keyof typeof TableCellMarginElementType],
|
||||
{ marginUnitType = WidthType.DXA, top, left, bottom, right }: ITableCellMarginOptions,
|
||||
) {
|
||||
super(type);
|
||||
|
@ -1,28 +1,28 @@
|
||||
import { NextAttributeComponent, StringEnumValueElement, XmlComponent } from "@file/xml-components";
|
||||
import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values";
|
||||
|
||||
export enum TableAnchorType {
|
||||
MARGIN = "margin",
|
||||
PAGE = "page",
|
||||
TEXT = "text",
|
||||
}
|
||||
export const TableAnchorType = {
|
||||
MARGIN: "margin",
|
||||
PAGE: "page",
|
||||
TEXT: "text",
|
||||
} as const;
|
||||
|
||||
export enum RelativeHorizontalPosition {
|
||||
CENTER = "center",
|
||||
INSIDE = "inside",
|
||||
LEFT = "left",
|
||||
OUTSIDE = "outside",
|
||||
RIGHT = "right",
|
||||
}
|
||||
export const RelativeHorizontalPosition = {
|
||||
CENTER: "center",
|
||||
INSIDE: "inside",
|
||||
LEFT: "left",
|
||||
OUTSIDE: "outside",
|
||||
RIGHT: "right",
|
||||
} as const;
|
||||
|
||||
export enum RelativeVerticalPosition {
|
||||
CENTER = "center",
|
||||
INSIDE = "inside",
|
||||
BOTTOM = "bottom",
|
||||
OUTSIDE = "outside",
|
||||
INLINE = "inline",
|
||||
TOP = "top",
|
||||
}
|
||||
export const RelativeVerticalPosition = {
|
||||
CENTER: "center",
|
||||
INSIDE: "inside",
|
||||
BOTTOM: "bottom",
|
||||
OUTSIDE: "outside",
|
||||
INLINE: "inline",
|
||||
TOP: "top",
|
||||
} as const;
|
||||
|
||||
// <xsd:simpleType name="ST_TblOverlap">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
@ -30,10 +30,10 @@ export enum RelativeVerticalPosition {
|
||||
// <xsd:enumeration value="overlap"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum OverlapType {
|
||||
NEVER = "never",
|
||||
OVERLAP = "overlap",
|
||||
}
|
||||
export const OverlapType = {
|
||||
NEVER: "never",
|
||||
OVERLAP: "overlap",
|
||||
} as const;
|
||||
|
||||
export type ITableFloatOptions = {
|
||||
/* cSpell:disable */
|
||||
@ -46,7 +46,7 @@ export type ITableFloatOptions = {
|
||||
* If omitted, the value is assumed to be page.
|
||||
*/
|
||||
/* cSpell:enable */
|
||||
readonly horizontalAnchor?: TableAnchorType;
|
||||
readonly horizontalAnchor?: (typeof TableAnchorType)[keyof typeof TableAnchorType];
|
||||
|
||||
/**
|
||||
* Specifies an absolute horizontal position for the table, relative to the horizontalAnchor.
|
||||
@ -67,7 +67,7 @@ export type ITableFloatOptions = {
|
||||
* outside - the table should be outside of the anchor
|
||||
* right - the table should be right aligned with respect to the anchor
|
||||
*/
|
||||
readonly relativeHorizontalPosition?: RelativeHorizontalPosition;
|
||||
readonly relativeHorizontalPosition?: (typeof RelativeHorizontalPosition)[keyof typeof RelativeHorizontalPosition];
|
||||
|
||||
/**
|
||||
* Specifies the vertical anchor or the base object from which the vertical positioning
|
||||
@ -77,7 +77,7 @@ export type ITableFloatOptions = {
|
||||
* text - relative to the horizontal edge of the text margin for the column in which the anchor paragraph is located
|
||||
* If omitted, the value is assumed to be page.
|
||||
*/
|
||||
readonly verticalAnchor?: TableAnchorType;
|
||||
readonly verticalAnchor?: (typeof TableAnchorType)[keyof typeof TableAnchorType];
|
||||
|
||||
/**
|
||||
* Specifies an absolute vertical position for the table, relative to the verticalAnchor anchor.
|
||||
@ -98,7 +98,7 @@ export type ITableFloatOptions = {
|
||||
* inline - the table should be vertically aligned in line with the surrounding text (so as to not allow any text wrapping around it)
|
||||
* top - the table should be vertically aligned to the top edge of the anchor
|
||||
*/
|
||||
readonly relativeVerticalPosition?: RelativeVerticalPosition;
|
||||
readonly relativeVerticalPosition?: (typeof RelativeVerticalPosition)[keyof typeof RelativeVerticalPosition];
|
||||
|
||||
/**
|
||||
* Specifies the minimum distance to be maintained between the table and the top of text in the paragraph
|
||||
@ -123,7 +123,7 @@ export type ITableFloatOptions = {
|
||||
* to the right of the table. The value is in twentieths of a point. If omitted, the value is assumed to be zero.
|
||||
*/
|
||||
readonly rightFromText?: number | PositiveUniversalMeasure;
|
||||
readonly overlap?: OverlapType;
|
||||
readonly overlap?: (typeof OverlapType)[keyof typeof OverlapType];
|
||||
};
|
||||
|
||||
// <xsd:complexType name="CT_TblPPr">
|
||||
@ -156,12 +156,18 @@ export class TableFloatProperties extends XmlComponent {
|
||||
super("w:tblpPr");
|
||||
this.root.push(
|
||||
new NextAttributeComponent<Omit<ITableFloatOptions, "overlap">>({
|
||||
leftFromText: { key: "w:leftFromText", value: leftFromText === undefined ? undefined : twipsMeasureValue(leftFromText) },
|
||||
leftFromText: {
|
||||
key: "w:leftFromText",
|
||||
value: leftFromText === undefined ? undefined : twipsMeasureValue(leftFromText),
|
||||
},
|
||||
rightFromText: {
|
||||
key: "w:rightFromText",
|
||||
value: rightFromText === undefined ? undefined : twipsMeasureValue(rightFromText),
|
||||
},
|
||||
topFromText: { key: "w:topFromText", value: topFromText === undefined ? undefined : twipsMeasureValue(topFromText) },
|
||||
topFromText: {
|
||||
key: "w:topFromText",
|
||||
value: topFromText === undefined ? undefined : twipsMeasureValue(topFromText),
|
||||
},
|
||||
bottomFromText: {
|
||||
key: "w:bottomFromText",
|
||||
value: bottomFromText === undefined ? undefined : twipsMeasureValue(bottomFromText),
|
||||
@ -197,7 +203,7 @@ export class TableFloatProperties extends XmlComponent {
|
||||
// <xsd:complexType name="CT_TblOverlap">
|
||||
// <xsd:attribute name="val" type="ST_TblOverlap" use="required"/>
|
||||
// </xsd:complexType>
|
||||
this.root.push(new StringEnumValueElement<OverlapType>("w:tblOverlap", overlap));
|
||||
this.root.push(new StringEnumValueElement<(typeof OverlapType)[keyof typeof OverlapType]>("w:tblOverlap", overlap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
// <xsd:enumeration value="autofit"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum TableLayoutType {
|
||||
AUTOFIT = "autofit",
|
||||
FIXED = "fixed",
|
||||
}
|
||||
export const TableLayoutType = {
|
||||
AUTOFIT: "autofit",
|
||||
FIXED: "fixed",
|
||||
} as const;
|
||||
|
||||
class TableLayoutAttributes extends XmlAttributeComponent<{ readonly type: TableLayoutType }> {
|
||||
class TableLayoutAttributes extends XmlAttributeComponent<{
|
||||
readonly type: (typeof TableLayoutType)[keyof typeof TableLayoutType];
|
||||
}> {
|
||||
protected readonly xmlKeys = { type: "w:type" };
|
||||
}
|
||||
|
||||
@ -19,7 +21,7 @@ class TableLayoutAttributes extends XmlAttributeComponent<{ readonly type: Table
|
||||
// <xsd:attribute name="type" type="ST_TblLayoutType"/>
|
||||
// </xsd:complexType>
|
||||
export class TableLayout extends XmlComponent {
|
||||
public constructor(type: TableLayoutType) {
|
||||
public constructor(type: (typeof TableLayoutType)[keyof typeof TableLayoutType]) {
|
||||
super("w:tblLayout");
|
||||
this.root.push(new TableLayoutAttributes({ type }));
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ import { TableLayout, TableLayoutType } from "./table-layout";
|
||||
export interface ITablePropertiesOptions {
|
||||
readonly width?: ITableWidthProperties;
|
||||
readonly indent?: ITableWidthProperties;
|
||||
readonly layout?: TableLayoutType;
|
||||
readonly layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];
|
||||
readonly borders?: ITableBordersOptions;
|
||||
readonly float?: ITableFloatOptions;
|
||||
readonly shading?: IShadingAttributesProperties;
|
||||
readonly style?: string;
|
||||
readonly alignment?: AlignmentType;
|
||||
readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
|
||||
readonly cellMargin?: ITableCellMarginOptions;
|
||||
readonly visuallyRightToLeft?: boolean;
|
||||
}
|
||||
|
@ -13,24 +13,24 @@ import { PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
|
||||
// <xsd:enumeration value="atLeast"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum HeightRule {
|
||||
export const HeightRule = {
|
||||
/** Height is determined based on the content, so value is ignored. */
|
||||
AUTO = "auto",
|
||||
AUTO: "auto",
|
||||
/** At least the value specified */
|
||||
ATLEAST = "atLeast",
|
||||
ATLEAST: "atLeast",
|
||||
/** Exactly the value specified */
|
||||
EXACT = "exact",
|
||||
}
|
||||
EXACT: "exact",
|
||||
} as const;
|
||||
|
||||
export class TableRowHeightAttributes extends XmlAttributeComponent<{
|
||||
readonly value: number | string;
|
||||
readonly rule: HeightRule;
|
||||
readonly rule: (typeof HeightRule)[keyof typeof HeightRule];
|
||||
}> {
|
||||
protected readonly xmlKeys = { value: "w:val", rule: "w:hRule" };
|
||||
}
|
||||
|
||||
export class TableRowHeight extends XmlComponent {
|
||||
public constructor(value: number | PositiveUniversalMeasure, rule: HeightRule) {
|
||||
public constructor(value: number | PositiveUniversalMeasure, rule: (typeof HeightRule)[keyof typeof HeightRule]) {
|
||||
super("w:trHeight");
|
||||
|
||||
this.root.push(
|
||||
|
@ -37,7 +37,7 @@ export interface ITableRowPropertiesOptions {
|
||||
readonly tableHeader?: boolean;
|
||||
readonly height?: {
|
||||
readonly value: number | PositiveUniversalMeasure;
|
||||
readonly rule: HeightRule;
|
||||
readonly rule: (typeof HeightRule)[keyof typeof HeightRule];
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -10,16 +10,17 @@ import { measurementOrPercentValue, Percentage, UniversalMeasure } from "@util/v
|
||||
// <xsd:enumeration value="auto"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum WidthType {
|
||||
|
||||
export const WidthType = {
|
||||
/** Auto. */
|
||||
AUTO = "auto",
|
||||
AUTO: "auto",
|
||||
/** Value is in twentieths of a point */
|
||||
DXA = "dxa",
|
||||
DXA: "dxa",
|
||||
/** No (empty) value. */
|
||||
NIL = "nil",
|
||||
NIL: "nil",
|
||||
/** Value is in percentage. */
|
||||
PERCENTAGE = "pct",
|
||||
}
|
||||
PERCENTAGE: "pct",
|
||||
} as const;
|
||||
|
||||
// <xsd:complexType name="CT_TblWidth">
|
||||
// <xsd:attribute name="w" type="ST_MeasurementOrPercent"/>
|
||||
@ -27,7 +28,7 @@ export enum WidthType {
|
||||
// </xsd:complexType>
|
||||
export type ITableWidthProperties = {
|
||||
readonly size: number | Percentage | UniversalMeasure;
|
||||
readonly type?: WidthType;
|
||||
readonly type?: (typeof WidthType)[keyof typeof WidthType];
|
||||
};
|
||||
|
||||
export class TableWidthElement extends XmlComponent {
|
||||
|
@ -27,10 +27,10 @@ export interface ITableOptions {
|
||||
readonly margins?: ITableCellMarginOptions;
|
||||
readonly indent?: ITableWidthProperties;
|
||||
readonly float?: ITableFloatOptions;
|
||||
readonly layout?: TableLayoutType;
|
||||
readonly layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];
|
||||
readonly style?: string;
|
||||
readonly borders?: ITableBordersOptions;
|
||||
readonly alignment?: AlignmentType;
|
||||
readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
|
||||
readonly visuallyRightToLeft?: boolean;
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,14 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
// <xsd:enumeration value="bottom"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export enum VerticalAlign {
|
||||
BOTTOM = "bottom",
|
||||
CENTER = "center",
|
||||
TOP = "top",
|
||||
}
|
||||
export const VerticalAlign = {
|
||||
BOTTOM: "bottom",
|
||||
CENTER: "center",
|
||||
TOP: "top",
|
||||
} as const;
|
||||
|
||||
export class VerticalAlignAttributes extends XmlAttributeComponent<{
|
||||
readonly verticalAlign?: VerticalAlign;
|
||||
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
||||
}> {
|
||||
protected readonly xmlKeys = {
|
||||
verticalAlign: "w:val",
|
||||
@ -25,7 +26,7 @@ export class VerticalAlignAttributes extends XmlAttributeComponent<{
|
||||
}
|
||||
|
||||
export class VerticalAlignElement extends XmlComponent {
|
||||
public constructor(value: VerticalAlign) {
|
||||
public constructor(value: (typeof VerticalAlign)[keyof typeof VerticalAlign]) {
|
||||
super("w:vAlign");
|
||||
this.root.push(new VerticalAlignAttributes({ verticalAlign: value }));
|
||||
}
|
||||
|
@ -20,18 +20,18 @@ import { appendContentType } from "./content-types-manager";
|
||||
// eslint-disable-next-line functional/prefer-readonly-type
|
||||
type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob | NodeJS.ReadableStream;
|
||||
|
||||
export enum PatchType {
|
||||
DOCUMENT = "file",
|
||||
PARAGRAPH = "paragraph",
|
||||
}
|
||||
export const PatchType = {
|
||||
DOCUMENT: "file",
|
||||
PARAGRAPH: "paragraph",
|
||||
} as const;
|
||||
|
||||
type ParagraphPatch = {
|
||||
readonly type: PatchType.PARAGRAPH;
|
||||
readonly type: typeof PatchType.PARAGRAPH;
|
||||
readonly children: readonly ParagraphChild[];
|
||||
};
|
||||
|
||||
type FilePatch = {
|
||||
readonly type: PatchType.DOCUMENT;
|
||||
readonly type: typeof PatchType.DOCUMENT;
|
||||
readonly children: readonly FileChild[];
|
||||
};
|
||||
|
||||
@ -83,7 +83,12 @@ export const patchDocument = async (data: InputDataType, options: PatchDocumentO
|
||||
file,
|
||||
viewWrapper: {
|
||||
Relationships: {
|
||||
createRelationship: (linkId: string, _: string, target: string, __: TargetModeType) => {
|
||||
createRelationship: (
|
||||
linkId: string,
|
||||
_: string,
|
||||
target: string,
|
||||
__: (typeof TargetModeType)[keyof typeof TargetModeType],
|
||||
) => {
|
||||
// eslint-disable-next-line functional/immutable-data
|
||||
hyperlinkRelationshipAdditions.push({
|
||||
key,
|
||||
|
@ -3,11 +3,11 @@ import { Element } from "xml-js";
|
||||
import { createTextElementContents, patchSpaceAttribute } from "./util";
|
||||
import { IRenderedParagraphNode } from "./run-renderer";
|
||||
|
||||
enum ReplaceMode {
|
||||
START,
|
||||
MIDDLE,
|
||||
END,
|
||||
}
|
||||
const ReplaceMode = {
|
||||
START: 0,
|
||||
MIDDLE: 1,
|
||||
END: 2,
|
||||
} as const;
|
||||
|
||||
export const replaceTokenInParagraphElement = ({
|
||||
paragraphElement,
|
||||
@ -23,7 +23,7 @@ export const replaceTokenInParagraphElement = ({
|
||||
const startIndex = renderedParagraph.text.indexOf(originalText);
|
||||
const endIndex = startIndex + originalText.length - 1;
|
||||
|
||||
let replaceMode = ReplaceMode.START;
|
||||
let replaceMode: (typeof ReplaceMode)[keyof typeof ReplaceMode] = ReplaceMode.START;
|
||||
|
||||
for (const run of renderedParagraph.runs) {
|
||||
for (const { text, index, start, end } of run.parts) {
|
||||
|
@ -23,7 +23,7 @@ export const appendRelationship = (
|
||||
id: number | string,
|
||||
type: RelationshipType,
|
||||
target: string,
|
||||
targetMode?: TargetModeType,
|
||||
targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType],
|
||||
): readonly Element[] => {
|
||||
const relationshipElements = getFirstLevelElements(relationships, "Relationships");
|
||||
// eslint-disable-next-line functional/immutable-data
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"target": "ES2015",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"lib": ["ES2015", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
@ -35,14 +35,5 @@
|
||||
"@shared": ["./shared/index.ts"]
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"esm": true,
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user