Compare commits
154 Commits
Author | SHA1 | Date | |
---|---|---|---|
a708475539 | |||
9c60cfcbc7 | |||
a5454edc61 | |||
7152abfe48 | |||
075eeb7e3c | |||
f0acb3f3fb | |||
ae048833a1 | |||
ebae72004c | |||
13744abff5 | |||
492ef29d7f | |||
a6e6463a36 | |||
2ef596543b | |||
85005c3c07 | |||
0d2b433446 | |||
b1f67652e9 | |||
4e2befb7ef | |||
a887927968 | |||
ee6db1429a | |||
170309a7ed | |||
05fcf6edd4 | |||
eb2174e566 | |||
2a56360875 | |||
ba862766a6 | |||
71291dab8f | |||
974ba7b450 | |||
8f7df39c07 | |||
ca3d8f0121 | |||
46c517d195 | |||
ff37f3b460 | |||
7b9b474484 | |||
e80a50d36c | |||
df99f96469 | |||
f87ad6a43c | |||
8bf5220e31 | |||
da8148251a | |||
01183ac34d | |||
d553e4763a | |||
213c3d29f3 | |||
697c1d91c6 | |||
b22de4ac4f | |||
0af9d27dcc | |||
b89b571c4e | |||
64505a295f | |||
c247bbf409 | |||
4c60e6a0c0 | |||
086e5ef184 | |||
7e81f7b368 | |||
defa431aa9 | |||
17eb4fe8c4 | |||
3997ce538d | |||
3654eb0800 | |||
c6bb255641 | |||
05a3cf5b43 | |||
dece0f58e1 | |||
7f3c5615c9 | |||
56d23176b7 | |||
958538c96a | |||
9fa6d5392b | |||
d7fdbf9736 | |||
0af1279b1d | |||
2bb2333cb9 | |||
78c511cab9 | |||
4016e961a9 | |||
9f3888d94f | |||
316891a1f2 | |||
0a9d844dcc | |||
15b8d85562 | |||
d1f3df5600 | |||
0fc0921aa9 | |||
7ad4c5409c | |||
a645accf5d | |||
b64cb2d448 | |||
cfcea6c863 | |||
d1cd17ff6e | |||
408869fa96 | |||
ed146fbffd | |||
e49e1cc7b9 | |||
2c9233c021 | |||
b2ad04e4e7 | |||
2381ba8a05 | |||
9cff0b2a57 | |||
a4754ebcfe | |||
8988f471c3 | |||
5f4ff94e26 | |||
6f531c5abc | |||
c761a362d1 | |||
2e155ddebc | |||
9c8a07eadc | |||
9cb9c8c462 | |||
4268c9d466 | |||
26f77eb45f | |||
dea23e4349 | |||
0ade4b1557 | |||
165d48323b | |||
179598cc07 | |||
a8656ca3fe | |||
020e0eb669 | |||
e5dfce523a | |||
b53b4a77b4 | |||
dd86cf3d27 | |||
32953b3696 | |||
cfec058c9d | |||
a1c07d5a8e | |||
5be745b081 | |||
b4fcfd6386 | |||
6e371d42a7 | |||
e8564d58c6 | |||
368aa431a0 | |||
afcd1ae060 | |||
244d2b8904 | |||
6dae62e1ab | |||
5810cb5f02 | |||
11c26af3a9 | |||
1b9b815214 | |||
c342137c6f | |||
eefc8bd8a5 | |||
9873861210 | |||
cf7a05e05d | |||
6eb11d8842 | |||
3ad68337e7 | |||
07f363fcb7 | |||
2d2e4cdab2 | |||
0cadec7f58 | |||
e86dbd3398 | |||
021f1b0c4d | |||
5aa2027252 | |||
2fc297ef3c | |||
3fe216846c | |||
649a50f7c5 | |||
dc14123a5a | |||
048a035a5d | |||
f212cf0251 | |||
1f2f5988e1 | |||
f1359a4750 | |||
f2775ed13c | |||
3ae749278e | |||
0bcc6910f4 | |||
c15951550c | |||
8308b6413e | |||
5b75875684 | |||
28029f4c1c | |||
824d7f9893 | |||
b3aea4b9a0 | |||
32377d187d | |||
a80815822d | |||
c198154fdc | |||
618c7a8578 | |||
ef7b930d4d | |||
8296895cc6 | |||
1dce6fee15 | |||
444e7771b4 | |||
962795743c | |||
f98f852a55 | |||
e379a7fe04 |
@ -8,11 +8,14 @@
|
|||||||
// words - list of words to be always considered correct
|
// words - list of words to be always considered correct
|
||||||
"words": [
|
"words": [
|
||||||
"Abjad",
|
"Abjad",
|
||||||
|
"aink",
|
||||||
"aiueo",
|
"aiueo",
|
||||||
"ATLEAST",
|
"ATLEAST",
|
||||||
"chosung",
|
"chosung",
|
||||||
"clippy",
|
"clippy",
|
||||||
"datas",
|
"datas",
|
||||||
|
"dcmitype",
|
||||||
|
"dcterms",
|
||||||
"docsify",
|
"docsify",
|
||||||
"dolan",
|
"dolan",
|
||||||
"execa",
|
"execa",
|
||||||
@ -32,6 +35,7 @@
|
|||||||
"panose",
|
"panose",
|
||||||
"rels",
|
"rels",
|
||||||
"rsid",
|
"rsid",
|
||||||
|
"sdtdh",
|
||||||
"twip",
|
"twip",
|
||||||
"twips",
|
"twips",
|
||||||
"Xmlable",
|
"Xmlable",
|
||||||
|
238
.eslintrc.yml
238
.eslintrc.yml
@ -1,238 +0,0 @@
|
|||||||
extends: eslint:recommended
|
|
||||||
env:
|
|
||||||
browser: true
|
|
||||||
es6: true
|
|
||||||
node: true
|
|
||||||
parser: "@typescript-eslint/parser"
|
|
||||||
parserOptions:
|
|
||||||
project:
|
|
||||||
- tsconfig.json
|
|
||||||
sourceType: module
|
|
||||||
plugins:
|
|
||||||
- eslint-plugin-import
|
|
||||||
- eslint-plugin-no-null
|
|
||||||
- eslint-plugin-unicorn
|
|
||||||
- eslint-plugin-jsdoc
|
|
||||||
- eslint-plugin-prefer-arrow
|
|
||||||
- "@typescript-eslint"
|
|
||||||
- eslint-plugin-functional
|
|
||||||
root: true
|
|
||||||
rules:
|
|
||||||
no-undef: "off"
|
|
||||||
no-extra-boolean-cast: "off"
|
|
||||||
no-alert: error
|
|
||||||
no-self-compare: error
|
|
||||||
no-unreachable-loop: error
|
|
||||||
no-template-curly-in-string: error
|
|
||||||
no-unused-private-class-members: error
|
|
||||||
no-extend-native: error
|
|
||||||
no-floating-decimal: error
|
|
||||||
no-implied-eval: error
|
|
||||||
no-iterator: error
|
|
||||||
no-lone-blocks: error
|
|
||||||
no-loop-func: error
|
|
||||||
no-new-object: error
|
|
||||||
no-proto: error
|
|
||||||
no-useless-catch: error
|
|
||||||
one-var-declaration-per-line: error
|
|
||||||
prefer-arrow-callback: error
|
|
||||||
prefer-destructuring: error
|
|
||||||
prefer-exponentiation-operator: error
|
|
||||||
prefer-promise-reject-errors: error
|
|
||||||
prefer-regex-literals: error
|
|
||||||
prefer-spread: error
|
|
||||||
prefer-template: error
|
|
||||||
require-await: error
|
|
||||||
"@typescript-eslint/adjacent-overload-signatures": error
|
|
||||||
"@typescript-eslint/array-type":
|
|
||||||
- error
|
|
||||||
- default: array
|
|
||||||
"@typescript-eslint/ban-types":
|
|
||||||
- error
|
|
||||||
- types:
|
|
||||||
Object:
|
|
||||||
message: Avoid using the `Object` type. Did you mean `object`?
|
|
||||||
Function:
|
|
||||||
message: >-
|
|
||||||
Avoid using the `Function` type. Prefer a specific function type,
|
|
||||||
like `() => void`.
|
|
||||||
Boolean:
|
|
||||||
message: Avoid using the `Boolean` type. Did you mean `boolean`?
|
|
||||||
Number:
|
|
||||||
message: Avoid using the `Number` type. Did you mean `number`?
|
|
||||||
String:
|
|
||||||
message: Avoid using the `String` type. Did you mean `string`?
|
|
||||||
Symbol:
|
|
||||||
message: Avoid using the `Symbol` type. Did you mean `symbol`?
|
|
||||||
"@typescript-eslint/consistent-type-assertions": error
|
|
||||||
"@typescript-eslint/dot-notation": error
|
|
||||||
"@typescript-eslint/explicit-function-return-type":
|
|
||||||
- error
|
|
||||||
- allowExpressions: true
|
|
||||||
allowTypedFunctionExpressions: true
|
|
||||||
allowHigherOrderFunctions: false
|
|
||||||
allowDirectConstAssertionInArrowFunctions: true
|
|
||||||
allowConciseArrowFunctionExpressionsStartingWithVoid: true
|
|
||||||
"@typescript-eslint/explicit-member-accessibility":
|
|
||||||
- error
|
|
||||||
- accessibility: explicit
|
|
||||||
overrides:
|
|
||||||
accessors: explicit
|
|
||||||
"@typescript-eslint/explicit-module-boundary-types":
|
|
||||||
- error
|
|
||||||
- allowArgumentsExplicitlyTypedAsAny: true
|
|
||||||
allowDirectConstAssertionInArrowFunctions: true
|
|
||||||
allowHigherOrderFunctions: false
|
|
||||||
allowTypedFunctionExpressions: false
|
|
||||||
"@typescript-eslint/naming-convention":
|
|
||||||
- error
|
|
||||||
- selector:
|
|
||||||
- objectLiteralProperty
|
|
||||||
leadingUnderscore: allow
|
|
||||||
format:
|
|
||||||
- camelCase
|
|
||||||
- PascalCase
|
|
||||||
- UPPER_CASE # for constants
|
|
||||||
filter:
|
|
||||||
regex: (^[a-z]+:.+)|_attr|[0-9]
|
|
||||||
match: false
|
|
||||||
"@typescript-eslint/no-empty-function": error
|
|
||||||
"@typescript-eslint/no-empty-interface": error
|
|
||||||
"@typescript-eslint/no-explicit-any": error
|
|
||||||
"@typescript-eslint/no-misused-new": error
|
|
||||||
"@typescript-eslint/no-namespace": error
|
|
||||||
"@typescript-eslint/no-parameter-properties": "off"
|
|
||||||
"@typescript-eslint/no-require-imports": error
|
|
||||||
"@typescript-eslint/no-shadow":
|
|
||||||
- error
|
|
||||||
- hoist: all
|
|
||||||
"@typescript-eslint/no-this-alias": error
|
|
||||||
"@typescript-eslint/no-unused-expressions": error
|
|
||||||
"@typescript-eslint/no-use-before-define": "off"
|
|
||||||
"@typescript-eslint/no-var-requires": error
|
|
||||||
"@typescript-eslint/prefer-for-of": error
|
|
||||||
"@typescript-eslint/prefer-function-type": error
|
|
||||||
"@typescript-eslint/prefer-namespace-keyword": error
|
|
||||||
"@typescript-eslint/prefer-readonly": error
|
|
||||||
"@typescript-eslint/triple-slash-reference":
|
|
||||||
- error
|
|
||||||
- path: always
|
|
||||||
types: prefer-import
|
|
||||||
lib: always
|
|
||||||
"@typescript-eslint/typedef":
|
|
||||||
- error
|
|
||||||
- parameter: true
|
|
||||||
propertyDeclaration: true
|
|
||||||
"@typescript-eslint/unified-signatures": error
|
|
||||||
arrow-body-style: error
|
|
||||||
complexity: "off"
|
|
||||||
consistent-return: error
|
|
||||||
constructor-super: error
|
|
||||||
curly: error
|
|
||||||
dot-notation: "off"
|
|
||||||
eqeqeq:
|
|
||||||
- error
|
|
||||||
- smart
|
|
||||||
guard-for-in: error
|
|
||||||
id-denylist:
|
|
||||||
- error
|
|
||||||
- any
|
|
||||||
- Number
|
|
||||||
- number
|
|
||||||
- String
|
|
||||||
- string
|
|
||||||
- Boolean
|
|
||||||
- boolean
|
|
||||||
- Undefined
|
|
||||||
- undefined
|
|
||||||
id-match: error
|
|
||||||
import/no-default-export: error
|
|
||||||
import/no-extraneous-dependencies: "off"
|
|
||||||
import/no-internal-modules: "off"
|
|
||||||
import/order: error
|
|
||||||
indent: "off"
|
|
||||||
jsdoc/check-alignment: error
|
|
||||||
jsdoc/check-indentation: "off"
|
|
||||||
max-classes-per-file: "off"
|
|
||||||
max-len: "off"
|
|
||||||
new-parens: error
|
|
||||||
no-bitwise: error
|
|
||||||
no-caller: error
|
|
||||||
no-cond-assign: error
|
|
||||||
no-console: error
|
|
||||||
no-debugger: error
|
|
||||||
no-duplicate-case: error
|
|
||||||
no-duplicate-imports: error
|
|
||||||
no-empty: error
|
|
||||||
no-empty-function: "off"
|
|
||||||
no-eval: error
|
|
||||||
no-extra-bind: error
|
|
||||||
no-fallthrough: "off"
|
|
||||||
no-invalid-this: "off"
|
|
||||||
no-multiple-empty-lines: error
|
|
||||||
no-new-func: error
|
|
||||||
no-new-wrappers: error
|
|
||||||
no-null/no-null: error
|
|
||||||
no-param-reassign: error
|
|
||||||
no-redeclare: error
|
|
||||||
no-return-await: error
|
|
||||||
no-sequences: error
|
|
||||||
no-shadow: "off"
|
|
||||||
no-sparse-arrays: error
|
|
||||||
no-throw-literal: error
|
|
||||||
no-trailing-spaces: error
|
|
||||||
no-undef-init: error
|
|
||||||
no-underscore-dangle:
|
|
||||||
- error
|
|
||||||
- allow:
|
|
||||||
- _attr
|
|
||||||
no-unsafe-finally: error
|
|
||||||
no-unused-expressions: "off"
|
|
||||||
no-unused-labels: error
|
|
||||||
no-use-before-define: "off"
|
|
||||||
no-useless-constructor: error
|
|
||||||
no-var: error
|
|
||||||
object-shorthand: "off"
|
|
||||||
one-var:
|
|
||||||
- error
|
|
||||||
- never
|
|
||||||
prefer-arrow/prefer-arrow-functions: error
|
|
||||||
prefer-const: error
|
|
||||||
prefer-object-spread: error
|
|
||||||
radix: error
|
|
||||||
space-in-parens:
|
|
||||||
- error
|
|
||||||
- never
|
|
||||||
spaced-comment:
|
|
||||||
- error
|
|
||||||
- always
|
|
||||||
- markers:
|
|
||||||
- /
|
|
||||||
unicorn/filename-case: error
|
|
||||||
unicorn/prefer-ternary: error
|
|
||||||
use-isnan: error
|
|
||||||
valid-typeof: "off"
|
|
||||||
functional/immutable-data:
|
|
||||||
- error
|
|
||||||
- ignoreImmediateMutation: true
|
|
||||||
ignoreAccessorPattern:
|
|
||||||
- "**.root*"
|
|
||||||
- "**.numberingReferences*"
|
|
||||||
- "**.sections*"
|
|
||||||
- "**.properties*"
|
|
||||||
functional/prefer-property-signatures: error
|
|
||||||
functional/no-mixed-types: error
|
|
||||||
functional/prefer-readonly-type: error
|
|
||||||
no-unused-vars:
|
|
||||||
- error
|
|
||||||
- argsIgnorePattern: ^[_]+$
|
|
||||||
ignorePatterns:
|
|
||||||
- vite.config.ts
|
|
||||||
overrides:
|
|
||||||
- files:
|
|
||||||
- "*.spec.ts"
|
|
||||||
rules:
|
|
||||||
"@typescript-eslint/no-unused-expressions": "off"
|
|
||||||
"@typescript-eslint/dot-notation": "off"
|
|
||||||
prefer-destructuring: "off"
|
|
||||||
"@typescript-eslint/explicit-function-return-type": "off"
|
|
18
.github/workflows/default.yml
vendored
18
.github/workflows/default.yml
vendored
@ -13,10 +13,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- uses: "./.github/actions/install-and-build"
|
- uses: "./.github/actions/install-and-build"
|
||||||
- name: Archive Production Artifact
|
- name: Archive Production Artifact
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build
|
name: build
|
||||||
path: build
|
path: build
|
||||||
@ -25,22 +25,24 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm run test:ci
|
run: npm run test:ci
|
||||||
- name: Codecov
|
- name: Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
verbose: true
|
verbose: true
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Lint
|
- name: Lint
|
||||||
@ -50,7 +52,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Prettier
|
- name: Prettier
|
||||||
@ -60,8 +62,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Prettier
|
- name: CSpell
|
||||||
run: npm run cspell
|
run: npm run cspell
|
||||||
|
2
.github/workflows/demos.yml
vendored
2
.github/workflows/demos.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
name: Demos
|
name: Demos
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v4
|
||||||
- uses: "./.github/actions/install-and-build"
|
- uses: "./.github/actions/install-and-build"
|
||||||
- name: Run Demos
|
- name: Run Demos
|
||||||
run: npm run run-ts -- ./demo/1-basic.ts
|
run: npm run run-ts -- ./demo/1-basic.ts
|
||||||
|
8
.github/workflows/github-pages.yml
vendored
8
.github/workflows/github-pages.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Build 🔧
|
- name: Build 🔧
|
||||||
@ -19,7 +19,7 @@ jobs:
|
|||||||
echo "docx.js.org" > docs/.nojekyll
|
echo "docx.js.org" > docs/.nojekyll
|
||||||
echo "docx.js.org" > docs/CNAME
|
echo "docx.js.org" > docs/CNAME
|
||||||
- name: Archive Production Artifact
|
- name: Archive Production Artifact
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docs
|
name: docs
|
||||||
path: docs
|
path: docs
|
||||||
@ -28,11 +28,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo 🛎️
|
- name: Checkout Repo 🛎️
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Download Artifact
|
- name: Download Artifact
|
||||||
uses: actions/download-artifact@master
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docs
|
name: docs
|
||||||
path: docs
|
path: docs
|
||||||
|
46
.github/workflows/npm-publish.yml
vendored
Normal file
46
.github/workflows/npm-publish.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
||||||
|
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
||||||
|
|
||||||
|
name: Node.js Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
- run: npm ci --force
|
||||||
|
- run: npm run cspell
|
||||||
|
- run: npm run prettier
|
||||||
|
- run: npm run lint
|
||||||
|
- run: npm run test:ci
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
- run: npm ci --force
|
||||||
|
- run: npm run build
|
||||||
|
|
||||||
|
publish-npm:
|
||||||
|
needs: [test, build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
registry-url: https://registry.npmjs.org/
|
||||||
|
- run: npm ci --force
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -33,8 +33,7 @@ node_modules
|
|||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
# build
|
# build
|
||||||
build
|
dist
|
||||||
build-tests
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
docs/api/
|
docs/api/
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -5,5 +5,6 @@
|
|||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"prettier.tabWidth": 4,
|
"prettier.tabWidth": 4,
|
||||||
"prettier.arrowParens": "always",
|
"prettier.arrowParens": "always",
|
||||||
"prettier.bracketSpacing": true
|
"prettier.bracketSpacing": true,
|
||||||
|
"eslint.useFlatConfig": true
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
[![Known Vulnerabilities][snky-image]][snky-url]
|
[![Known Vulnerabilities][snky-image]][snky-url]
|
||||||
[![PRs Welcome][pr-image]][pr-url]
|
[![PRs Welcome][pr-image]][pr-url]
|
||||||
[![codecov][codecov-image]][codecov-url]
|
[![codecov][codecov-image]][codecov-url]
|
||||||
|
[![Docx.js Editor][docxjs-editor-image]][docxjs-editor-url]
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://i.imgur.com/QeL1HuU.png" alt="drawing"/>
|
<img src="https://i.imgur.com/QeL1HuU.png" alt="drawing"/>
|
||||||
@ -64,6 +65,10 @@ More [here](https://github.com/dolanmiu/docx/tree/master/demo)
|
|||||||
|
|
||||||
Please refer to the [documentation at https://docx.js.org/](https://docx.js.org/) for details on how to use this library, examples and much more!
|
Please refer to the [documentation at https://docx.js.org/](https://docx.js.org/) for details on how to use this library, examples and much more!
|
||||||
|
|
||||||
|
# Playground
|
||||||
|
|
||||||
|
Experience `docx` in action through [Docx.js Editor][docxjs-editor-url], an interactive playground where you can code and preview the results in real-time.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
Check the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
|
Check the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
|
||||||
@ -88,6 +93,7 @@ Read the contribution guidelines [here](https://docx.js.org/#/contribution-guide
|
|||||||
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
|
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
|
||||||
[<img src="https://i.imgur.com/AKGhtlh.png" alt="drawing"/>](https://lexense.com/)
|
[<img src="https://i.imgur.com/AKGhtlh.png" alt="drawing"/>](https://lexense.com/)
|
||||||
[<img src="https://i.imgur.com/9tqJaHw.png" alt="drawing" height="50"/>](https://novelpad.co/)
|
[<img src="https://i.imgur.com/9tqJaHw.png" alt="drawing" height="50"/>](https://novelpad.co/)
|
||||||
|
[<img src="https://i.imgur.com/5bLKFeP.png" alt="drawing" height="50"/>](https://proton.me/)
|
||||||
|
|
||||||
...and many more!
|
...and many more!
|
||||||
|
|
||||||
@ -114,3 +120,5 @@ Made with 💖
|
|||||||
[patreon-url]: https://www.patreon.com/dolanmiu
|
[patreon-url]: https://www.patreon.com/dolanmiu
|
||||||
[browserstack-image]: https://user-images.githubusercontent.com/2917613/54233552-128e9d00-4505-11e9-88fb-025a4e04007c.png
|
[browserstack-image]: https://user-images.githubusercontent.com/2917613/54233552-128e9d00-4505-11e9-88fb-025a4e04007c.png
|
||||||
[browserstack-url]: https://www.browserstack.com
|
[browserstack-url]: https://www.browserstack.com
|
||||||
|
[docxjs-editor-image]: https://img.shields.io/badge/Docx.js%20Editor-2b579a.svg?style=flat&logo=javascript&logoColor=white
|
||||||
|
[docxjs-editor-url]: https://docxjs-editor.vercel.app/
|
||||||
|
24
SECURITY.md
Normal file
24
SECURITY.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Use this section to tell people about which versions of your project are
|
||||||
|
currently being supported with security updates.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 9.0.x | :white_check_mark: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
We encourage responsible disclosure of security vulnerabilities. If you believe you have found a security vulnerability in this project, please report it via the [Security Tab](https://github.com/dolanmiu/docx/security/advisories)
|
||||||
|
|
||||||
|
Please include the following information in your report:
|
||||||
|
|
||||||
|
* A description of the vulnerability
|
||||||
|
* Steps to reproduce the vulnerability
|
||||||
|
* Impact of the vulnerability
|
||||||
|
|
||||||
|
We will investigate all reported vulnerabilities and take appropriate action.
|
||||||
|
|
||||||
|
We appreciate your help in keeping this project secure.
|
72
demo/93-template-document.ts
Normal file
72
demo/93-template-document.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// Patch a document with patches
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { patchDocument, PatchType, TextRun } from "docx";
|
||||||
|
|
||||||
|
patchDocument({
|
||||||
|
outputType: "nodebuffer",
|
||||||
|
data: fs.readFileSync("demo/assets/field-trip.docx"),
|
||||||
|
patches: {
|
||||||
|
todays_date: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: new Date().toLocaleDateString() })],
|
||||||
|
},
|
||||||
|
|
||||||
|
school_name: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
address: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "blah blah" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
city: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
state: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
zip: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
phone: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
first_name: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
last_name: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
email_address: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
ft_dates: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
|
||||||
|
grade: {
|
||||||
|
type: PatchType.PARAGRAPH,
|
||||||
|
children: [new TextRun({ text: "test" })],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).then((doc) => {
|
||||||
|
fs.writeFileSync("My Document.docx", doc);
|
||||||
|
});
|
43
demo/94-texbox.ts
Normal file
43
demo/94-texbox.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Simple example to add textbox to a document
|
||||||
|
import { Document, Packer, Paragraph, Textbox, TextRun } from "docx";
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Textbox({
|
||||||
|
alignment: "center",
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hi i'm a textbox!")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
style: {
|
||||||
|
width: "200pt",
|
||||||
|
height: "auto",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new Textbox({
|
||||||
|
alignment: "center",
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hi i'm a textbox with a hidden box!")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
style: {
|
||||||
|
width: "300pt",
|
||||||
|
height: 400,
|
||||||
|
visibility: "hidden",
|
||||||
|
zIndex: "auto",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
60
demo/95-paragraph-style-with-shading-and-borders.ts
Normal file
60
demo/95-paragraph-style-with-shading-and-borders.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import * as fs from "fs";
|
||||||
|
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
styles: {
|
||||||
|
paragraphStyles: [
|
||||||
|
{
|
||||||
|
id: "withSingleBlackBordersAndYellowShading",
|
||||||
|
name: "Paragraph Style with Black Borders and Yellow Shading",
|
||||||
|
basedOn: "Normal",
|
||||||
|
paragraph: {
|
||||||
|
shading: {
|
||||||
|
color: "#fff000",
|
||||||
|
type: "solid",
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
top: {
|
||||||
|
style: BorderStyle.SINGLE,
|
||||||
|
color: "#000000",
|
||||||
|
size: 4,
|
||||||
|
},
|
||||||
|
bottom: {
|
||||||
|
style: BorderStyle.SINGLE,
|
||||||
|
color: "#000000",
|
||||||
|
size: 4,
|
||||||
|
},
|
||||||
|
left: {
|
||||||
|
style: BorderStyle.SINGLE,
|
||||||
|
color: "#000000",
|
||||||
|
size: 4,
|
||||||
|
},
|
||||||
|
right: {
|
||||||
|
style: BorderStyle.SINGLE,
|
||||||
|
color: "#000000",
|
||||||
|
size: 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
style: "withSingleBlackBordersAndYellowShading",
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
BIN
demo/assets/field-trip.docx
Normal file
BIN
demo/assets/field-trip.docx
Normal file
Binary file not shown.
@ -22,7 +22,7 @@ const doc = new Document({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
}];
|
}]
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -22,19 +22,30 @@ const doc = new docx.Document({
|
|||||||
|
|
||||||
### Full list of options:
|
### Full list of options:
|
||||||
|
|
||||||
- creator
|
| Property | Type | Notes |
|
||||||
- description
|
| -------------------------- | -------------------------------------------------------- | -------- |
|
||||||
- title
|
| sections | `ISectionOptions[]` | Optional |
|
||||||
- subject
|
| title | `string` | Optional |
|
||||||
- keywords
|
| subject | `string` | Optional |
|
||||||
- lastModifiedBy
|
| creator | `string` | Optional |
|
||||||
- revision
|
| keywords | `string` | Optional |
|
||||||
- externalStyles
|
| description | `string` | Optional |
|
||||||
- styles
|
| lastModifiedBy | `string` | Optional |
|
||||||
- numbering
|
| revision | `number` | Optional |
|
||||||
- footnotes
|
| externalStyles | `string` | Optional |
|
||||||
- hyperlinks
|
| styles | `IStylesOptions` | Optional |
|
||||||
- background
|
| numbering | `INumberingOptions` | Optional |
|
||||||
|
| comments | `ICommentsOptions` | Optional |
|
||||||
|
| footnotes | `Record<string, { children: Paragraph[] }>` | Optional |
|
||||||
|
| background | `IDocumentBackgroundOptions` | Optional |
|
||||||
|
| features | `{ trackRevisions?: boolean; updateFields?: boolean; }` | Optional |
|
||||||
|
| compatabilityModeVersion | `number` | Optional |
|
||||||
|
| compatibility | `ICompatibilityOptions` | Optional |
|
||||||
|
| customProperties | ` ICustomPropertyOptions`[] | Optional |
|
||||||
|
| evenAndOddHeaderAndFooters | `boolean` | Optional |
|
||||||
|
| defaultTabStop | `number` | Optional |
|
||||||
|
| fonts | ` FontOptions[]` | Optional |
|
||||||
|
| hyphenation | `IHyphenationOptions` | Optional |
|
||||||
|
|
||||||
### Change background color of Document
|
### Change background color of Document
|
||||||
|
|
||||||
|
@ -130,6 +130,62 @@ new Paragraph({
|
|||||||
}),
|
}),
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Disabling numbering inherited from paragraph style
|
||||||
|
|
||||||
|
If the numbering is set on a paragraph style, you may wish to disable it for a specific paragraph:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const doc = new Document({
|
||||||
|
...
|
||||||
|
numbering: {
|
||||||
|
config: [
|
||||||
|
{
|
||||||
|
reference: "my-bullet-points",
|
||||||
|
levels: [
|
||||||
|
{
|
||||||
|
level: 0,
|
||||||
|
format: LevelFormat.BULLET,
|
||||||
|
text: "\u1F60",
|
||||||
|
alignment: AlignmentType.LEFT,
|
||||||
|
style: {
|
||||||
|
paragraph: {
|
||||||
|
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.25) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
styles: {
|
||||||
|
paragraphStyles: [
|
||||||
|
{
|
||||||
|
id: 'bullet',
|
||||||
|
name: 'Bullet',
|
||||||
|
basedOn: 'Normal',
|
||||||
|
next: 'Normal',
|
||||||
|
run: {},
|
||||||
|
paragraph: {
|
||||||
|
numbering: {
|
||||||
|
reference: 'my-bullet-points',
|
||||||
|
level: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new Paragraph({
|
||||||
|
text: "No bullet points!",
|
||||||
|
style: "Bullet",
|
||||||
|
numbering: false,
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
## Full Example
|
## Full Example
|
||||||
|
|
||||||
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/3-numbering-and-bullet-points.ts ":include")
|
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/3-numbering-and-bullet-points.ts ":include")
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
> Packers are the way in which `docx` turns your code into `.docx` format. It is completely decoupled from the `docx.Document`.
|
> Packers are the way in which `docx` turns your code into `.docx` format. It is completely decoupled from the `docx.Document`.
|
||||||
|
|
||||||
Packers works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob` or `base64 string`. It is up to you to take that and persist it with node's `fs`, send it down as a downloadable file, or anything else you wish. As of `version 4+`, this library will not have options to export to PDF.
|
Packers works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob`, `string`, `base64 string`, `ArrayBuffer`, or `Stream`. It is up to you to take that and persist it with node's `fs`, send it down as a downloadable file, or anything else you wish. As of `version 4+`, this library will not have options to export to PDF.
|
||||||
|
|
||||||
### Export as Buffer
|
### Export as Buffer
|
||||||
|
|
||||||
@ -14,6 +14,14 @@ Packer.toBuffer(doc).then((buffer) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Export as string
|
||||||
|
|
||||||
|
```ts
|
||||||
|
Packer.toString(doc).then((string) => {
|
||||||
|
console.log(string);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Export as a `base64` string
|
### Export as a `base64` string
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@ -32,3 +40,46 @@ Packer.toBlob(doc).then((blob) => {
|
|||||||
saveAs(blob, "example.docx");
|
saveAs(blob, "example.docx");
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Export as ArrayBuffer
|
||||||
|
|
||||||
|
This may be useful when working in a Node.js worker.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
Packer.toArrayBuffer(doc).then((arrayBuffer) => {
|
||||||
|
port.postMessage(arrayBuffer, [arrayBuffer]);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Export as a Stream
|
||||||
|
|
||||||
|
```ts
|
||||||
|
Packer.toStream(doc).then((stream) => {
|
||||||
|
// read from stream
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Export using optional arguments
|
||||||
|
|
||||||
|
The `Packer` methods support 2 optional arguments.
|
||||||
|
|
||||||
|
The first is for controlling the indentation of the xml and should be a `boolean` or `keyof typeof PrettifyType`.
|
||||||
|
|
||||||
|
The second is an array of subfile overrides (`{path: string, data: string}[]`). These overrides can be used to write additional subfiles to the result or even override default subfiles in the case that the default handling of these subfiles does not meet your needs.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const overrides = [{ path: "word/commentsExtended.xml", data: "string_data" }];
|
||||||
|
Packer.toString(doc, true, overrides).then((string) => {
|
||||||
|
console.log(string);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Export to arbitrary formats
|
||||||
|
|
||||||
|
You can also use the lower-level `Packer.pack` method to export to any specified type.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
Packer.pack(doc, 'string').then((string) => {
|
||||||
|
console.log(string);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
@ -35,6 +35,9 @@ interface Patch {
|
|||||||
| type | `PatchType` | Required | `DOCUMENT`, `PARAGRAPH` |
|
| type | `PatchType` | Required | `DOCUMENT`, `PARAGRAPH` |
|
||||||
| children | `FileChild[] or ParagraphChild[]` | Required | The contents to replace with. A `FileChild` is a `Paragraph` or `Table`, whereas a `ParagraphChild` is typical `Paragraph` children. |
|
| children | `FileChild[] or ParagraphChild[]` | Required | The contents to replace with. A `FileChild` is a `Paragraph` or `Table`, whereas a `ParagraphChild` is typical `Paragraph` children. |
|
||||||
|
|
||||||
|
|
||||||
|
The patcher also takes in a `keepOriginalStyles` boolean, which will preserve the styles of the patched text when set to true.
|
||||||
|
|
||||||
### How to patch existing document
|
### How to patch existing document
|
||||||
|
|
||||||
1. Open your existing word document in your favorite Word Processor
|
1. Open your existing word document in your favorite Word Processor
|
||||||
|
@ -126,10 +126,10 @@ const doc = new Document({
|
|||||||
next: "Normal",
|
next: "Normal",
|
||||||
quickFormat: true,
|
quickFormat: true,
|
||||||
run: {
|
run: {
|
||||||
size: 26
|
size: 26,
|
||||||
bold: true,
|
bold: true,
|
||||||
color: "999999",
|
color: "999999",
|
||||||
{
|
underline: {
|
||||||
type: UnderlineType.DOUBLE,
|
type: UnderlineType.DOUBLE,
|
||||||
color: "FF0000",
|
color: "FF0000",
|
||||||
},
|
},
|
||||||
|
@ -22,7 +22,7 @@ Then add the table in the `section`
|
|||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [{
|
sections: [{
|
||||||
children: [table],
|
children: [table],
|
||||||
}];
|
}],
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
26
docs/usage/text-box.md
Normal file
26
docs/usage/text-box.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Text Box
|
||||||
|
|
||||||
|
Similar `Text Frames`, but the difference being that it is `VML` `Shape` based.
|
||||||
|
|
||||||
|
!> `Text Boxes` requires an understanding of [Paragraphs](usage/paragraph.md).
|
||||||
|
|
||||||
|
> `Text boxes` are paragraphs of text in a document which are positioned in a separate region or frame in the document, and can be positioned with a specific size and position relative to non-frame paragraphs in the current document.
|
||||||
|
|
||||||
|
## Intro
|
||||||
|
|
||||||
|
To make a `Text Box`, simply create a `Textbox` object inside the `Document`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new Textbox({
|
||||||
|
alignment: "center",
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hi i'm a textbox!")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
style: {
|
||||||
|
width: "200pt",
|
||||||
|
height: "auto",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
@ -1,6 +1,6 @@
|
|||||||
# Text Frames
|
# Text Frames
|
||||||
|
|
||||||
Also known as `Text Boxes`
|
> Similar to `Text Boxes`!
|
||||||
|
|
||||||
!> Text Frames requires an understanding of [Paragraphs](usage/paragraph.md).
|
!> Text Frames requires an understanding of [Paragraphs](usage/paragraph.md).
|
||||||
|
|
||||||
|
370
eslint.config.ts
Normal file
370
eslint.config.ts
Normal file
@ -0,0 +1,370 @@
|
|||||||
|
import eslint from "@eslint/js";
|
||||||
|
import type { Linter } from "eslint";
|
||||||
|
import importPlugin from "eslint-plugin-import";
|
||||||
|
import unicorn from "eslint-plugin-unicorn";
|
||||||
|
import jsdoc from "eslint-plugin-jsdoc";
|
||||||
|
import preferArrow from "eslint-plugin-prefer-arrow";
|
||||||
|
import functional from "eslint-plugin-functional";
|
||||||
|
import globals from "globals";
|
||||||
|
import tsEslint from "typescript-eslint";
|
||||||
|
|
||||||
|
const config: Linter.Config<Linter.RulesRecord>[] = [
|
||||||
|
{
|
||||||
|
ignores: ["**/vite.config.ts", "**/dist/**", "**/coverage/**", "**/*.js", "eslint.config.ts", "**/demo/**", "**/scripts/**"],
|
||||||
|
},
|
||||||
|
eslint.configs.recommended,
|
||||||
|
importPlugin.flatConfigs.recommended,
|
||||||
|
...tsEslint.configs.recommended,
|
||||||
|
...tsEslint.configs.stylistic,
|
||||||
|
{
|
||||||
|
files: ["**/src/**/*.ts"],
|
||||||
|
plugins: {
|
||||||
|
unicorn,
|
||||||
|
jsdoc,
|
||||||
|
"prefer-arrow": preferArrow,
|
||||||
|
functional,
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
projectService: true,
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
"import/resolver": {
|
||||||
|
typescript: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"no-undef": "off",
|
||||||
|
"no-extra-boolean-cast": "off",
|
||||||
|
"no-alert": "error",
|
||||||
|
"no-self-compare": "error",
|
||||||
|
"no-unreachable-loop": "error",
|
||||||
|
"no-template-curly-in-string": "error",
|
||||||
|
"no-unused-private-class-members": "error",
|
||||||
|
"no-extend-native": "error",
|
||||||
|
"no-floating-decimal": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"no-iterator": "error",
|
||||||
|
"no-lone-blocks": "error",
|
||||||
|
"no-loop-func": "error",
|
||||||
|
"no-new-object": "error",
|
||||||
|
"no-proto": "error",
|
||||||
|
"no-useless-catch": "error",
|
||||||
|
"one-var-declaration-per-line": "error",
|
||||||
|
"prefer-arrow-callback": "error",
|
||||||
|
"prefer-destructuring": "error",
|
||||||
|
"prefer-exponentiation-operator": "error",
|
||||||
|
"prefer-promise-reject-errors": "error",
|
||||||
|
"prefer-regex-literals": "error",
|
||||||
|
"prefer-spread": "error",
|
||||||
|
"prefer-template": "error",
|
||||||
|
"require-await": "error",
|
||||||
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||||
|
|
||||||
|
"@typescript-eslint/array-type": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
default: "array",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/no-restricted-types": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
types: {
|
||||||
|
Object: {
|
||||||
|
message: "Avoid using the `Object` type. Did you mean `object`?",
|
||||||
|
fixWith: "object",
|
||||||
|
},
|
||||||
|
|
||||||
|
Function: {
|
||||||
|
message: "Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
|
||||||
|
},
|
||||||
|
|
||||||
|
Boolean: {
|
||||||
|
message: "Avoid using the `Boolean` type. Did you mean `boolean`?",
|
||||||
|
fixWith: "boolean",
|
||||||
|
},
|
||||||
|
|
||||||
|
Number: {
|
||||||
|
message: "Avoid using the `Number` type. Did you mean `number`?",
|
||||||
|
fixWith: "number",
|
||||||
|
},
|
||||||
|
|
||||||
|
String: {
|
||||||
|
message: "Avoid using the `String` type. Did you mean `string`?",
|
||||||
|
fixWith: "string",
|
||||||
|
},
|
||||||
|
|
||||||
|
Symbol: {
|
||||||
|
message: "Avoid using the `Symbol` type. Did you mean `symbol`?",
|
||||||
|
fixWith: "symbol",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/consistent-type-assertions": "error",
|
||||||
|
"@typescript-eslint/dot-notation": "error",
|
||||||
|
|
||||||
|
"@typescript-eslint/explicit-function-return-type": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowExpressions: true,
|
||||||
|
allowTypedFunctionExpressions: true,
|
||||||
|
allowHigherOrderFunctions: false,
|
||||||
|
allowDirectConstAssertionInArrowFunctions: true,
|
||||||
|
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/explicit-member-accessibility": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
accessibility: "explicit",
|
||||||
|
|
||||||
|
overrides: {
|
||||||
|
accessors: "explicit",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/explicit-module-boundary-types": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowArgumentsExplicitlyTypedAsAny: true,
|
||||||
|
allowDirectConstAssertionInArrowFunctions: true,
|
||||||
|
allowHigherOrderFunctions: false,
|
||||||
|
allowTypedFunctionExpressions: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/naming-convention": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
selector: ["objectLiteralProperty"],
|
||||||
|
leadingUnderscore: "allow",
|
||||||
|
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
||||||
|
|
||||||
|
filter: {
|
||||||
|
regex: "(^[a-z]+:.+)|_attr|[0-9]",
|
||||||
|
match: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/no-empty-function": "error",
|
||||||
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"@typescript-eslint/no-misused-new": "error",
|
||||||
|
"@typescript-eslint/no-namespace": "error",
|
||||||
|
"@typescript-eslint/no-parameter-properties": "off",
|
||||||
|
"@typescript-eslint/no-require-imports": "error",
|
||||||
|
|
||||||
|
"@typescript-eslint/no-shadow": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
hoist: "all",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
||||||
|
|
||||||
|
"@typescript-eslint/no-this-alias": "error",
|
||||||
|
"@typescript-eslint/no-unused-expressions": "error",
|
||||||
|
"@typescript-eslint/no-use-before-define": "off",
|
||||||
|
"@typescript-eslint/no-var-requires": "error",
|
||||||
|
"@typescript-eslint/prefer-for-of": "error",
|
||||||
|
"@typescript-eslint/prefer-function-type": "error",
|
||||||
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||||
|
"@typescript-eslint/prefer-readonly": "error",
|
||||||
|
|
||||||
|
"@typescript-eslint/triple-slash-reference": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
path: "always",
|
||||||
|
types: "prefer-import",
|
||||||
|
lib: "always",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/typedef": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
parameter: true,
|
||||||
|
propertyDeclaration: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"@typescript-eslint/no-inferrable-types": "off",
|
||||||
|
|
||||||
|
"@typescript-eslint/unified-signatures": "error",
|
||||||
|
"arrow-body-style": "error",
|
||||||
|
complexity: "off",
|
||||||
|
"consistent-return": "error",
|
||||||
|
"constructor-super": "error",
|
||||||
|
curly: "error",
|
||||||
|
"dot-notation": "off",
|
||||||
|
eqeqeq: ["error", "smart"],
|
||||||
|
"guard-for-in": "error",
|
||||||
|
|
||||||
|
"id-denylist": ["error", "any", "Number", "number", "String", "string", "Boolean", "boolean", "Undefined", "undefined"],
|
||||||
|
|
||||||
|
"id-match": "error",
|
||||||
|
"import/no-default-export": "error",
|
||||||
|
"import/no-extraneous-dependencies": "off",
|
||||||
|
"import/no-internal-modules": "off",
|
||||||
|
"sort-imports": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowSeparatedGroups: true,
|
||||||
|
ignoreDeclarationSort: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"import/order": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
groups: [["external", "builtin"], "internal", ["sibling", "parent", "index"]],
|
||||||
|
"newlines-between": "always",
|
||||||
|
pathGroups: [
|
||||||
|
{ pattern: "@file/**/*", group: "internal" },
|
||||||
|
{ pattern: "@file/**", group: "internal" },
|
||||||
|
{ pattern: "@export/**", group: "internal" },
|
||||||
|
],
|
||||||
|
pathGroupsExcludedImportTypes: ["internal"],
|
||||||
|
alphabetize: {
|
||||||
|
order: "asc",
|
||||||
|
caseInsensitive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
indent: "off",
|
||||||
|
"jsdoc/check-alignment": "error",
|
||||||
|
"jsdoc/check-indentation": "off",
|
||||||
|
"max-classes-per-file": "off",
|
||||||
|
"max-len": "off",
|
||||||
|
"new-parens": "error",
|
||||||
|
"no-bitwise": "error",
|
||||||
|
"no-caller": "error",
|
||||||
|
"no-cond-assign": "error",
|
||||||
|
"no-console": "error",
|
||||||
|
"no-debugger": "error",
|
||||||
|
"no-duplicate-case": "error",
|
||||||
|
"no-duplicate-imports": "error",
|
||||||
|
"no-empty": "error",
|
||||||
|
"no-empty-function": "off",
|
||||||
|
"no-eval": "error",
|
||||||
|
"no-extra-bind": "error",
|
||||||
|
"no-fallthrough": "off",
|
||||||
|
"no-invalid-this": "off",
|
||||||
|
"no-multiple-empty-lines": "error",
|
||||||
|
"no-new-func": "error",
|
||||||
|
"no-new-wrappers": "error",
|
||||||
|
"no-param-reassign": "error",
|
||||||
|
"no-redeclare": "error",
|
||||||
|
"no-return-await": "error",
|
||||||
|
"no-sequences": "error",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"no-sparse-arrays": "error",
|
||||||
|
"no-throw-literal": "error",
|
||||||
|
"no-trailing-spaces": "error",
|
||||||
|
"no-undef-init": "error",
|
||||||
|
|
||||||
|
"no-underscore-dangle": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allow: ["_attr"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"no-unsafe-finally": "error",
|
||||||
|
"no-unused-expressions": "off",
|
||||||
|
"no-unused-labels": "error",
|
||||||
|
"no-use-before-define": "off",
|
||||||
|
"no-useless-constructor": "error",
|
||||||
|
"no-var": "error",
|
||||||
|
"object-shorthand": "off",
|
||||||
|
"one-var": ["error", "never"],
|
||||||
|
"prefer-arrow/prefer-arrow-functions": "error",
|
||||||
|
"prefer-const": "error",
|
||||||
|
"prefer-object-spread": "error",
|
||||||
|
radix: "error",
|
||||||
|
"space-in-parens": ["error", "never"],
|
||||||
|
|
||||||
|
"spaced-comment": [
|
||||||
|
"error",
|
||||||
|
"always",
|
||||||
|
{
|
||||||
|
markers: ["/"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"unicorn/filename-case": "error",
|
||||||
|
"unicorn/prefer-ternary": "error",
|
||||||
|
"use-isnan": "error",
|
||||||
|
"valid-typeof": "off",
|
||||||
|
|
||||||
|
"functional/immutable-data": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
ignoreImmediateMutation: true,
|
||||||
|
ignoreAccessorPattern: ["**.root*", "**.numberingReferences*", "**.sections*", "**.properties*"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"functional/prefer-property-signatures": "error",
|
||||||
|
"functional/no-mixed-types": "error",
|
||||||
|
"functional/prefer-readonly-type": "error",
|
||||||
|
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
argsIgnorePattern: "^[_]+$",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.spec.ts"],
|
||||||
|
plugins: {
|
||||||
|
unicorn,
|
||||||
|
jsdoc,
|
||||||
|
"prefer-arrow": preferArrow,
|
||||||
|
functional,
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.node,
|
||||||
|
},
|
||||||
|
|
||||||
|
sourceType: "module",
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
projectService: true,
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
project: ["tsconfig.json"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-unused-expressions": "off",
|
||||||
|
"@typescript-eslint/dot-notation": "off",
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
|
"no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
argsIgnorePattern: "^[_]+$",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default config;
|
14675
package-lock.json
generated
14675
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
71
package.json
71
package.json
@ -1,28 +1,32 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "8.5.0",
|
"version": "9.2.0",
|
||||||
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "build/index.umd.js",
|
"main": "dist/index.umd.cjs",
|
||||||
"module": "./build/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./build/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"require": "./build/index.cjs",
|
"import": {
|
||||||
"types": "./build/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./build/index.mjs",
|
"default": "./dist/index.mjs"
|
||||||
"default": "./build/index.mjs"
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./dist/index.d.cts",
|
||||||
|
"default": "./dist/index.cjs"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"build"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"test": "vitest --ui --coverage",
|
"test": "vitest --ui --coverage",
|
||||||
"test:ci": "vitest run --coverage",
|
"test:ci": "vitest run --coverage",
|
||||||
"prepublishOnly": "npm run build --omit=dev",
|
"prepublishOnly": "npm run build --omit=dev",
|
||||||
"lint": "eslint --ext .ts src",
|
"lint": "eslint --flag unstable_ts_config --config eslint.config.ts",
|
||||||
"predemo": "npm run build",
|
"predemo": "npm run build",
|
||||||
"demo": "tsx ./demo/index.ts",
|
"demo": "tsx ./demo/index.ts",
|
||||||
"typedoc": "typedoc src/index.ts --tsconfig tsconfig.typedoc.json",
|
"typedoc": "typedoc src/index.ts --tsconfig tsconfig.typedoc.json",
|
||||||
@ -54,9 +58,10 @@
|
|||||||
"clippy"
|
"clippy"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^20.3.1",
|
"@types/node": "^22.7.5",
|
||||||
|
"hash.js": "^1.1.7",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"nanoid": "^5.0.4",
|
"nanoid": "^5.1.3",
|
||||||
"xml": "^1.0.1",
|
"xml": "^1.0.1",
|
||||||
"xml-js": "^1.6.8"
|
"xml-js": "^1.6.8"
|
||||||
},
|
},
|
||||||
@ -67,39 +72,43 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://docx.js.org",
|
"homepage": "https://docx.js.org",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/eslint__js": "^8.42.3",
|
||||||
"@types/inquirer": "^9.0.3",
|
"@types/inquirer": "^9.0.3",
|
||||||
"@types/prompt": "^1.1.1",
|
"@types/prompt": "^1.1.1",
|
||||||
"@types/unzipper": "^0.10.4",
|
"@types/unzipper": "^0.10.4",
|
||||||
"@types/xml": "^1.0.8",
|
"@types/xml": "^1.0.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
"@typescript-eslint/eslint-plugin": "^8.8.1",
|
||||||
"@typescript-eslint/parser": "^6.9.1",
|
"@typescript-eslint/parser": "^8.8.1",
|
||||||
"@vitest/coverage-v8": "^1.1.0",
|
"@vitest/coverage-v8": "^3.0.8",
|
||||||
"@vitest/ui": "^1.1.0",
|
"@vitest/ui": "^3.0.8",
|
||||||
"cspell": "^8.2.3",
|
"cspell": "^8.2.3",
|
||||||
"docsify-cli": "^4.3.0",
|
"docsify-cli": "^4.3.0",
|
||||||
"eslint": "^8.23.0",
|
"eslint": "^9.13.0",
|
||||||
"eslint-plugin-functional": "^6.0.0",
|
"eslint-import-resolver-typescript": "^3.6.3",
|
||||||
|
"eslint-plugin-functional": "^7.0.2",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-jsdoc": "^48.0.2",
|
"eslint-plugin-jsdoc": "^50.3.1",
|
||||||
"eslint-plugin-no-null": "^1.0.2",
|
"eslint-plugin-no-null": "^1.0.2",
|
||||||
"eslint-plugin-prefer-arrow": "^1.2.3",
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||||
"eslint-plugin-unicorn": "^50.0.1",
|
"eslint-plugin-unicorn": "^56.0.0",
|
||||||
"execa": "^8.0.1",
|
"execa": "^9.4.0",
|
||||||
"glob": "^10.2.7",
|
"glob": "^11.0.0",
|
||||||
"inquirer": "^9.2.7",
|
"inquirer": "^12.0.0",
|
||||||
"jsdom": "^23.0.1",
|
"jiti": "^2.3.3",
|
||||||
|
"jsdom": "^26.0.0",
|
||||||
"pre-commit": "^1.2.2",
|
"pre-commit": "^1.2.2",
|
||||||
"prettier": "^3.1.1",
|
"prettier": "^3.1.1",
|
||||||
"tsconfig-paths": "^4.0.0",
|
"tsconfig-paths": "^4.0.0",
|
||||||
"tsx": "^4.7.0",
|
"tsx": "^4.7.0",
|
||||||
"typedoc": "^0.25.4",
|
"typedoc": "^0.27.3",
|
||||||
"typescript": "5.3.3",
|
"typescript": "5.3.3",
|
||||||
"unzipper": "^0.10.11",
|
"typescript-eslint": "^8.10.0",
|
||||||
"vite": "^5.0.10",
|
"unzipper": "^0.12.3",
|
||||||
"vite-plugin-dts": "^3.3.1",
|
"vite": "^6.0.1",
|
||||||
"vite-plugin-node-polyfills": "^0.19.0",
|
"vite-plugin-dts": "^4.2.4",
|
||||||
"vite-tsconfig-paths": "^4.2.0",
|
"vite-plugin-node-polyfills": "^0.23.0",
|
||||||
"vitest": "^1.1.0"
|
"vite-tsconfig-paths": "^5.0.1",
|
||||||
|
"vitest": "^3.0.8"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { BaseXmlComponent, IContext, IXmlableObject } from "@file/xml-components";
|
import { BaseXmlComponent, IContext, IXmlableObject } from "@file/xml-components";
|
||||||
|
|
||||||
export class Formatter {
|
export class Formatter {
|
||||||
// tslint:disable-next-line: no-object-literal-type-assertion
|
|
||||||
public format(input: BaseXmlComponent, context: IContext = { stack: [] } as unknown as IContext): IXmlableObject {
|
public format(input: BaseXmlComponent, context: IContext = { stack: [] } as unknown as IContext): IXmlableObject {
|
||||||
const output = input.prepForXml(context);
|
const output = input.prepForXml(context);
|
||||||
|
|
||||||
|
@ -112,6 +112,41 @@ describe("Compiler", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should pack subfile overrides",
|
||||||
|
async () => {
|
||||||
|
const file = new File({
|
||||||
|
sections: [],
|
||||||
|
comments: {
|
||||||
|
children: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const subfileData1 = "comments";
|
||||||
|
const subfileData2 = "commentsExtended";
|
||||||
|
const overrides = [
|
||||||
|
{ path: "word/comments.xml", data: subfileData1 },
|
||||||
|
{ path: "word/commentsExtended.xml", data: subfileData2 },
|
||||||
|
];
|
||||||
|
const zipFile = compiler.compile(file, "", overrides);
|
||||||
|
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
|
||||||
|
|
||||||
|
expect(fileNames).is.an.instanceof(Array);
|
||||||
|
expect(fileNames).has.length(20);
|
||||||
|
|
||||||
|
expect(fileNames).to.include("word/comments.xml");
|
||||||
|
expect(fileNames).to.include("word/commentsExtended.xml");
|
||||||
|
|
||||||
|
const commentsText = await zipFile.file("word/comments.xml")?.async("text");
|
||||||
|
const commentsExtendedText = await zipFile.file("word/commentsExtended.xml")?.async("text");
|
||||||
|
|
||||||
|
expect(commentsText).toBe(subfileData1);
|
||||||
|
expect(commentsExtendedText).toBe(subfileData2);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timeout: 99999999,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it("should call the format method X times equalling X files to be formatted", () => {
|
it("should call the format method X times equalling X files to be formatted", () => {
|
||||||
// This test is required because before, there was a case where Document was formatted twice, which was inefficient
|
// This test is required because before, there was a case where Document was formatted twice, which was inefficient
|
||||||
// This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
|
// This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
|
||||||
@ -125,7 +160,6 @@ describe("Compiler", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// tslint:disable-next-line: no-string-literal
|
|
||||||
const spy = vi.spyOn(compiler["formatter"], "format");
|
const spy = vi.spyOn(compiler["formatter"], "format");
|
||||||
|
|
||||||
compiler.compile(file);
|
compiler.compile(file);
|
||||||
|
@ -9,12 +9,12 @@ import { ImageReplacer } from "./image-replacer";
|
|||||||
import { NumberingReplacer } from "./numbering-replacer";
|
import { NumberingReplacer } from "./numbering-replacer";
|
||||||
import { PrettifyType } from "./packer";
|
import { PrettifyType } from "./packer";
|
||||||
|
|
||||||
interface IXmlifyedFile {
|
export type IXmlifyedFile = {
|
||||||
readonly data: string;
|
readonly data: string;
|
||||||
readonly path: string;
|
readonly path: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
interface IXmlifyedFileMapping {
|
type IXmlifyedFileMapping = {
|
||||||
readonly Document: IXmlifyedFile;
|
readonly Document: IXmlifyedFile;
|
||||||
readonly Styles: IXmlifyedFile;
|
readonly Styles: IXmlifyedFile;
|
||||||
readonly Properties: IXmlifyedFile;
|
readonly Properties: IXmlifyedFile;
|
||||||
@ -34,7 +34,7 @@ interface IXmlifyedFileMapping {
|
|||||||
readonly Comments?: IXmlifyedFile;
|
readonly Comments?: IXmlifyedFile;
|
||||||
readonly FontTable?: IXmlifyedFile;
|
readonly FontTable?: IXmlifyedFile;
|
||||||
readonly FontTableRelationships?: IXmlifyedFile;
|
readonly FontTableRelationships?: IXmlifyedFile;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class Compiler {
|
export class Compiler {
|
||||||
private readonly formatter: Formatter;
|
private readonly formatter: Formatter;
|
||||||
@ -47,7 +47,11 @@ export class Compiler {
|
|||||||
this.numberingReplacer = new NumberingReplacer();
|
this.numberingReplacer = new NumberingReplacer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public compile(file: File, prettifyXml?: (typeof PrettifyType)[keyof typeof PrettifyType]): JSZip {
|
public compile(
|
||||||
|
file: File,
|
||||||
|
prettifyXml?: (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
|
): JSZip {
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml);
|
const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml);
|
||||||
const map = new Map<string, IXmlifyedFile | readonly IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
const map = new Map<string, IXmlifyedFile | readonly IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
||||||
@ -62,6 +66,10 @@ export class Compiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const subFile of overrides) {
|
||||||
|
zip.file(subFile.path, subFile.data);
|
||||||
|
}
|
||||||
|
|
||||||
for (const data of file.Media.Array) {
|
for (const data of file.Media.Array) {
|
||||||
if (data.type !== "svg") {
|
if (data.type !== "svg") {
|
||||||
zip.file(`word/media/${data.fileName}`, data.data);
|
zip.file(`word/media/${data.fileName}`, data.data);
|
||||||
@ -109,6 +117,12 @@ export class Compiler {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
file.Document.Relationships.createRelationship(
|
||||||
|
file.Document.Relationships.RelationshipCount + 1,
|
||||||
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
|
||||||
|
"fontTable.xml",
|
||||||
|
);
|
||||||
|
|
||||||
return xml(
|
return xml(
|
||||||
this.formatter.format(file.Document.Relationships, {
|
this.formatter.format(file.Document.Relationships, {
|
||||||
viewWrapper: file.Document,
|
viewWrapper: file.Document,
|
||||||
|
@ -46,7 +46,7 @@ describe("Packer", () => {
|
|||||||
|
|
||||||
await Packer.toString(file, true);
|
await Packer.toString(file, true);
|
||||||
|
|
||||||
expect(spy).toBeCalledWith(expect.anything(), PrettifyType.WITH_2_BLANKS);
|
expect(spy).toBeCalledWith(expect.anything(), PrettifyType.WITH_2_BLANKS, expect.anything());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use a prettify value", async () => {
|
it("should use a prettify value", async () => {
|
||||||
@ -55,7 +55,7 @@ describe("Packer", () => {
|
|||||||
|
|
||||||
await Packer.toString(file, PrettifyType.WITH_4_BLANKS);
|
await Packer.toString(file, PrettifyType.WITH_4_BLANKS);
|
||||||
|
|
||||||
expect(spy).toBeCalledWith(expect.anything(), PrettifyType.WITH_4_BLANKS);
|
expect(spy).toBeCalledWith(expect.anything(), PrettifyType.WITH_4_BLANKS, expect.anything());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use an undefined prettify value", async () => {
|
it("should use an undefined prettify value", async () => {
|
||||||
@ -64,7 +64,32 @@ describe("Packer", () => {
|
|||||||
|
|
||||||
await Packer.toString(file, false);
|
await Packer.toString(file, false);
|
||||||
|
|
||||||
expect(spy).toBeCalledWith(expect.anything(), undefined);
|
expect(spy).toBeCalledWith(expect.anything(), undefined, expect.anything());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("overrides", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
vi.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use an overrides value", async () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const spy = vi.spyOn((Packer as any).compiler, "compile");
|
||||||
|
const overrides = [{ path: "word/comments.xml", data: "comments" }];
|
||||||
|
|
||||||
|
await Packer.toString(file, true, overrides);
|
||||||
|
|
||||||
|
expect(spy).toBeCalledWith(expect.anything(), expect.anything(), overrides);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use a default overrides value", async () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const spy = vi.spyOn((Packer as any).compiler, "compile");
|
||||||
|
|
||||||
|
await Packer.toString(file);
|
||||||
|
|
||||||
|
expect(spy).toBeCalledWith(expect.anything(), undefined, []);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,7 +164,6 @@ describe("Packer", () => {
|
|||||||
it("should create a standard docx file", async () => {
|
it("should create a standard docx file", async () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({
|
vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({
|
||||||
// tslint:disable-next-line: no-empty
|
|
||||||
generateAsync: () => vi.fn(),
|
generateAsync: () => vi.fn(),
|
||||||
});
|
});
|
||||||
const str = await Packer.toBlob(file);
|
const str = await Packer.toBlob(file);
|
||||||
@ -163,11 +187,37 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#toArrayBuffer()", () => {
|
||||||
|
it("should create a standard docx file", async () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({
|
||||||
|
generateAsync: () => vi.fn(),
|
||||||
|
});
|
||||||
|
const str = await Packer.toArrayBuffer(file);
|
||||||
|
|
||||||
|
assert.isDefined(str);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle exception if it throws any", () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
vi.spyOn((Packer as any).compiler, "compile").mockImplementation(() => {
|
||||||
|
throw new Error();
|
||||||
|
});
|
||||||
|
|
||||||
|
return Packer.toArrayBuffer(file).catch((error) => {
|
||||||
|
assert.isDefined(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.resetAllMocks();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#toStream()", () => {
|
describe("#toStream()", () => {
|
||||||
it("should create a standard docx file", async () => {
|
it("should create a standard docx file", async () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({
|
vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({
|
||||||
// tslint:disable-next-line: no-empty
|
|
||||||
generateAsync: () => Promise.resolve(vi.fn()),
|
generateAsync: () => Promise.resolve(vi.fn()),
|
||||||
});
|
});
|
||||||
const stream = Packer.toStream(file);
|
const stream = Packer.toStream(file);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { Stream } from "stream";
|
import { Stream } from "stream";
|
||||||
import { File } from "@file/file";
|
|
||||||
|
|
||||||
import { Compiler } from "./next-compiler";
|
import { File } from "@file/file";
|
||||||
|
import { OutputByType, OutputType } from "@util/output-type";
|
||||||
|
|
||||||
|
import { Compiler, IXmlifyedFile } from "./next-compiler";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use blanks to prettify
|
* Use blanks to prettify
|
||||||
@ -10,7 +12,7 @@ export const PrettifyType = {
|
|||||||
NONE: "",
|
NONE: "",
|
||||||
WITH_2_BLANKS: " ",
|
WITH_2_BLANKS: " ",
|
||||||
WITH_4_BLANKS: " ",
|
WITH_4_BLANKS: " ",
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
||||||
WITH_TAB: "\t",
|
WITH_TAB: "\t",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
@ -20,53 +22,68 @@ const convertPrettifyType = (
|
|||||||
prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? undefined : prettify;
|
prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? undefined : prettify;
|
||||||
|
|
||||||
export class Packer {
|
export class Packer {
|
||||||
public static async toString(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<string> {
|
// eslint-disable-next-line require-await
|
||||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
public static async pack<T extends OutputType>(
|
||||||
const zipData = await zip.generateAsync({
|
file: File,
|
||||||
type: "string",
|
type: T,
|
||||||
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
|
): Promise<OutputByType[T]> {
|
||||||
|
const zip = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
|
||||||
|
return zip.generateAsync({
|
||||||
|
type,
|
||||||
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
compression: "DEFLATE",
|
compression: "DEFLATE",
|
||||||
});
|
});
|
||||||
|
|
||||||
return zipData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async toBuffer(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<Buffer> {
|
public static toString(
|
||||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
file: File,
|
||||||
const zipData = await zip.generateAsync({
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
type: "nodebuffer",
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
): Promise<string> {
|
||||||
compression: "DEFLATE",
|
return Packer.pack(file, "string", prettify, overrides);
|
||||||
});
|
|
||||||
|
|
||||||
return zipData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async toBase64String(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<string> {
|
public static toBuffer(
|
||||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
file: File,
|
||||||
const zipData = await zip.generateAsync({
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
type: "base64",
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
): Promise<Buffer> {
|
||||||
compression: "DEFLATE",
|
return Packer.pack(file, "nodebuffer", prettify, overrides);
|
||||||
});
|
|
||||||
|
|
||||||
return zipData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async toBlob(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Promise<Blob> {
|
public static toBase64String(
|
||||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
file: File,
|
||||||
const zipData = await zip.generateAsync({
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
type: "blob",
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
): Promise<string> {
|
||||||
compression: "DEFLATE",
|
return Packer.pack(file, "base64", prettify, overrides);
|
||||||
});
|
|
||||||
|
|
||||||
return zipData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static toStream(file: File, prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType]): Stream {
|
public static toBlob(
|
||||||
|
file: File,
|
||||||
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
|
): Promise<Blob> {
|
||||||
|
return Packer.pack(file, "blob", prettify, overrides);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static toArrayBuffer(
|
||||||
|
file: File,
|
||||||
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
|
): Promise<ArrayBuffer> {
|
||||||
|
return Packer.pack(file, "arraybuffer", prettify, overrides);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static toStream(
|
||||||
|
file: File,
|
||||||
|
prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
|
||||||
|
overrides: readonly IXmlifyedFile[] = [],
|
||||||
|
): Stream {
|
||||||
const stream = new Stream();
|
const stream = new Stream();
|
||||||
const zip = this.compiler.compile(file, convertPrettifyType(prettify));
|
const zip = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
|
||||||
|
|
||||||
zip.generateAsync({
|
zip.generateAsync({
|
||||||
type: "nodebuffer",
|
type: "nodebuffer",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { AppPropertiesAttributes } from "./app-properties-attributes";
|
import { AppPropertiesAttributes } from "./app-properties-attributes";
|
||||||
|
|
||||||
export class AppProperties extends XmlComponent {
|
export class AppProperties extends XmlComponent {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
import { eighthPointMeasureValue, hexColorValue, pointMeasureValue } from "@util/values";
|
import { eighthPointMeasureValue, hexColorValue, pointMeasureValue } from "@util/values";
|
||||||
|
|
||||||
export interface IBorderOptions {
|
export type IBorderOptions = {
|
||||||
readonly style: (typeof BorderStyle)[keyof typeof BorderStyle];
|
readonly style: (typeof BorderStyle)[keyof typeof BorderStyle];
|
||||||
/** Border color, in hex (eg 'FF00AA') */
|
/** Border color, in hex (eg 'FF00AA') */
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
@ -30,7 +30,7 @@ export interface IBorderOptions {
|
|||||||
readonly size?: number;
|
readonly size?: number;
|
||||||
/** Spacing offset. Values are specified in pt */
|
/** Spacing offset. Values are specified in pt */
|
||||||
readonly space?: number;
|
readonly space?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class BorderElement extends XmlComponent {
|
export class BorderElement extends XmlComponent {
|
||||||
public constructor(elementName: string, { color, size, space, style }: IBorderOptions) {
|
public constructor(elementName: string, { color, size, space, style }: IBorderOptions) {
|
||||||
@ -55,7 +55,6 @@ class BordersAttributes extends XmlAttributeComponent<IBorderOptions> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const BorderStyle = {
|
export const BorderStyle = {
|
||||||
SINGLE: "single",
|
SINGLE: "single",
|
||||||
DASH_DOT_STROKED: "dashDotStroked",
|
DASH_DOT_STROKED: "dashDotStroked",
|
||||||
@ -85,4 +84,3 @@ export const BorderStyle = {
|
|||||||
TRIPLE: "triple",
|
TRIPLE: "triple",
|
||||||
WAVE: "wave",
|
WAVE: "wave",
|
||||||
} as const;
|
} as const;
|
||||||
/* eslint-enable */
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { CheckBoxUtil } from ".";
|
import { CheckBoxUtil } from ".";
|
||||||
|
|
||||||
describe("CheckBoxUtil", () => {
|
describe("CheckBoxUtil", () => {
|
||||||
|
@ -7,20 +7,20 @@
|
|||||||
// </xsd:complexType>
|
// </xsd:complexType>
|
||||||
// <xsd:element name="checkbox" type="CT_SdtCheckbox"/>
|
// <xsd:element name="checkbox" type="CT_SdtCheckbox"/>
|
||||||
|
|
||||||
import { XmlComponent } from "@file/xml-components";
|
|
||||||
import { CheckBoxSymbolElement } from "@file/checkbox/checkbox-symbol";
|
import { CheckBoxSymbolElement } from "@file/checkbox/checkbox-symbol";
|
||||||
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
export interface ICheckboxSymbolProperties {
|
export type ICheckboxSymbolProperties = {
|
||||||
readonly value?: string;
|
readonly value?: string;
|
||||||
readonly font?: string;
|
readonly font?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface ICheckboxSymbolOptions {
|
export type ICheckboxSymbolOptions = {
|
||||||
readonly alias?: string;
|
readonly alias?: string;
|
||||||
readonly checked?: boolean;
|
readonly checked?: boolean;
|
||||||
readonly checkedState?: ICheckboxSymbolProperties;
|
readonly checkedState?: ICheckboxSymbolProperties;
|
||||||
readonly uncheckedState?: ICheckboxSymbolProperties;
|
readonly uncheckedState?: ICheckboxSymbolProperties;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class CheckBoxUtil extends XmlComponent {
|
export class CheckBoxUtil extends XmlComponent {
|
||||||
private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610";
|
private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610";
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { CheckBox } from "./checkbox";
|
import { CheckBox } from "./checkbox";
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { SymbolRun } from "@file/paragraph/run/symbol-run";
|
import { SymbolRun } from "@file/paragraph/run/symbol-run";
|
||||||
import { StructuredDocumentTagProperties } from "@file/table-of-contents/sdt-properties";
|
|
||||||
import { StructuredDocumentTagContent } from "@file/table-of-contents/sdt-content";
|
import { StructuredDocumentTagContent } from "@file/table-of-contents/sdt-content";
|
||||||
|
import { StructuredDocumentTagProperties } from "@file/table-of-contents/sdt-properties";
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { CheckBoxUtil, ICheckboxSymbolOptions } from "./checkbox-util";
|
import { CheckBoxUtil, ICheckboxSymbolOptions } from "./checkbox-util";
|
||||||
|
|
||||||
export class CheckBox extends XmlComponent {
|
export class CheckBox extends XmlComponent {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// tslint:disable:no-string-literal
|
|
||||||
|
|
||||||
import { beforeEach, describe, expect, it } from "vitest";
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { ContentTypeAttributes } from "./content-types-attributes";
|
import { ContentTypeAttributes } from "./content-types-attributes";
|
||||||
import { Default } from "./default/default";
|
import { Default } from "./default/default";
|
||||||
import { Override } from "./override/override";
|
import { Override } from "./override/override";
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { DefaultAttributes } from "./default-attributes";
|
import { DefaultAttributes } from "./default-attributes";
|
||||||
|
|
||||||
export class Default extends XmlComponent {
|
export class Default extends XmlComponent {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { OverrideAttributes } from "./override-attributes";
|
import { OverrideAttributes } from "./override-attributes";
|
||||||
|
|
||||||
export class Override extends XmlComponent {
|
export class Override extends XmlComponent {
|
||||||
|
@ -45,7 +45,7 @@ describe("Properties", () => {
|
|||||||
expect(tree["cp:coreProperties"]).to.be.an.instanceof(Array);
|
expect(tree["cp:coreProperties"]).to.be.an.instanceof(Array);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const key = (obj: { readonly [key: string]: any }) => Object.keys(obj)[0];
|
const key = (obj: Readonly<Record<string, any>>) => Object.keys(obj)[0];
|
||||||
expect(tree["cp:coreProperties"].map(key)).to.include.members([
|
expect(tree["cp:coreProperties"].map(key)).to.include.members([
|
||||||
"_attr",
|
"_attr",
|
||||||
"cp:keywords",
|
"cp:keywords",
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import { ICommentsOptions } from "@file/paragraph/run/comment-run";
|
|
||||||
import { ICompatibilityOptions } from "@file/settings/compatibility";
|
|
||||||
import { FontOptions } from "@file/fonts/font-table";
|
import { FontOptions } from "@file/fonts/font-table";
|
||||||
import { StringContainer, XmlComponent } from "@file/xml-components";
|
import { ICommentsOptions } from "@file/paragraph/run/comment-run";
|
||||||
|
import { IHyphenationOptions } from "@file/settings";
|
||||||
|
import { ICompatibilityOptions } from "@file/settings/compatibility";
|
||||||
|
import { StringContainer, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
import { dateTimeValue } from "@util/values";
|
import { dateTimeValue } from "@util/values";
|
||||||
|
|
||||||
import { ICustomPropertyOptions } from "../custom-properties";
|
import { ICustomPropertyOptions } from "../custom-properties";
|
||||||
import { IDocumentBackgroundOptions } from "../document";
|
import { IDocumentBackgroundOptions } from "../document";
|
||||||
|
|
||||||
import { DocumentAttributes } from "../document/document-attributes";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
import { ISectionOptions } from "../file";
|
import { ISectionOptions } from "../file";
|
||||||
import { INumberingOptions } from "../numbering";
|
import { INumberingOptions } from "../numbering";
|
||||||
import { Paragraph } from "../paragraph";
|
import { Paragraph } from "../paragraph";
|
||||||
import { IStylesOptions } from "../styles";
|
import { IStylesOptions } from "../styles";
|
||||||
|
|
||||||
export interface IPropertiesOptions {
|
export type IPropertiesOptions = {
|
||||||
readonly sections: readonly ISectionOptions[];
|
readonly sections: readonly ISectionOptions[];
|
||||||
readonly title?: string;
|
readonly title?: string;
|
||||||
readonly subject?: string;
|
readonly subject?: string;
|
||||||
@ -26,11 +26,14 @@ export interface IPropertiesOptions {
|
|||||||
readonly styles?: IStylesOptions;
|
readonly styles?: IStylesOptions;
|
||||||
readonly numbering?: INumberingOptions;
|
readonly numbering?: INumberingOptions;
|
||||||
readonly comments?: ICommentsOptions;
|
readonly comments?: ICommentsOptions;
|
||||||
readonly footnotes?: {
|
readonly footnotes?: Readonly<
|
||||||
readonly [key: string]: {
|
Record<
|
||||||
readonly children: readonly Paragraph[];
|
string,
|
||||||
};
|
{
|
||||||
};
|
readonly children: readonly Paragraph[];
|
||||||
|
}
|
||||||
|
>
|
||||||
|
>;
|
||||||
readonly background?: IDocumentBackgroundOptions;
|
readonly background?: IDocumentBackgroundOptions;
|
||||||
readonly features?: {
|
readonly features?: {
|
||||||
readonly trackRevisions?: boolean;
|
readonly trackRevisions?: boolean;
|
||||||
@ -42,7 +45,8 @@ export interface IPropertiesOptions {
|
|||||||
readonly evenAndOddHeaderAndFooters?: boolean;
|
readonly evenAndOddHeaderAndFooters?: boolean;
|
||||||
readonly defaultTabStop?: number;
|
readonly defaultTabStop?: number;
|
||||||
readonly fonts?: readonly FontOptions[];
|
readonly fonts?: readonly FontOptions[];
|
||||||
}
|
readonly hyphenation?: IHyphenationOptions;
|
||||||
|
};
|
||||||
|
|
||||||
// <xs:element name="coreProperties" type="CT_CoreProperties"/>
|
// <xs:element name="coreProperties" type="CT_CoreProperties"/>
|
||||||
|
|
||||||
@ -71,15 +75,7 @@ export interface IPropertiesOptions {
|
|||||||
export class CoreProperties extends XmlComponent {
|
export class CoreProperties extends XmlComponent {
|
||||||
public constructor(options: Omit<IPropertiesOptions, "sections">) {
|
public constructor(options: Omit<IPropertiesOptions, "sections">) {
|
||||||
super("cp:coreProperties");
|
super("cp:coreProperties");
|
||||||
this.root.push(
|
this.root.push(new DocumentAttributes(["cp", "dc", "dcterms", "dcmitype", "xsi"]));
|
||||||
new DocumentAttributes({
|
|
||||||
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
||||||
dc: "http://purl.org/dc/elements/1.1/",
|
|
||||||
dcterms: "http://purl.org/dc/terms/",
|
|
||||||
dcmitype: "http://purl.org/dc/dcmitype/",
|
|
||||||
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (options.title) {
|
if (options.title) {
|
||||||
this.root.push(new StringContainer("dc:title", options.title));
|
this.root.push(new StringContainer("dc:title", options.title));
|
||||||
}
|
}
|
||||||
@ -106,11 +102,15 @@ export class CoreProperties extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TimestampElementProperties extends XmlAttributeComponent<{ readonly type: string }> {
|
||||||
|
protected readonly xmlKeys = { type: "xsi:type" };
|
||||||
|
}
|
||||||
|
|
||||||
class TimestampElement extends XmlComponent {
|
class TimestampElement extends XmlComponent {
|
||||||
public constructor(name: string) {
|
public constructor(name: string) {
|
||||||
super(name);
|
super(name);
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new DocumentAttributes({
|
new TimestampElementProperties({
|
||||||
type: "dcterms:W3CDTF",
|
type: "dcterms:W3CDTF",
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
|
import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { CustomPropertiesAttributes } from "./custom-properties-attributes";
|
import { CustomPropertiesAttributes } from "./custom-properties-attributes";
|
||||||
import { CustomProperty, ICustomPropertyOptions } from "./custom-property";
|
import { CustomProperty, ICustomPropertyOptions } from "./custom-property";
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { CustomPropertyAttributes } from "./custom-property-attributes";
|
import { CustomPropertyAttributes } from "./custom-property-attributes";
|
||||||
|
|
||||||
export interface ICustomPropertyOptions {
|
export type ICustomPropertyOptions = {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly value: string;
|
readonly value: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class CustomProperty extends XmlComponent {
|
export class CustomProperty extends XmlComponent {
|
||||||
public constructor(id: number, properties: ICustomPropertyOptions) {
|
public constructor(id: number, properties: ICustomPropertyOptions) {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { XmlComponent } from "./xml-components";
|
|
||||||
import { Document, IDocumentOptions } from "./document";
|
import { Document, IDocumentOptions } from "./document";
|
||||||
import { Footer } from "./footer/footer";
|
import { Footer } from "./footer/footer";
|
||||||
import { FootNotes } from "./footnotes";
|
import { FootNotes } from "./footnotes";
|
||||||
import { Header } from "./header/header";
|
import { Header } from "./header/header";
|
||||||
import { Relationships } from "./relationships";
|
import { Relationships } from "./relationships";
|
||||||
|
import { XmlComponent } from "./xml-components";
|
||||||
|
|
||||||
export interface IViewWrapper {
|
export type IViewWrapper = {
|
||||||
readonly View: Document | Footer | Header | FootNotes | XmlComponent;
|
readonly View: Document | Footer | Header | FootNotes | XmlComponent;
|
||||||
readonly Relationships: Relationships;
|
readonly Relationships: Relationships;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class DocumentWrapper implements IViewWrapper {
|
export class DocumentWrapper implements IViewWrapper {
|
||||||
private readonly document: Document;
|
private readonly document: Document;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
|
import { PositiveUniversalMeasure, decimalNumber, twipsMeasureValue } from "@util/values";
|
||||||
|
|
||||||
import { Column } from "./column";
|
import { Column } from "./column";
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import { decimalNumber } from "@util/values";
|
|||||||
// <xsd:attribute name="charSpace" type="ST_DecimalNumber"/>
|
// <xsd:attribute name="charSpace" type="ST_DecimalNumber"/>
|
||||||
// </xsd:complexType>
|
// </xsd:complexType>
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const DocumentGridType = {
|
export const DocumentGridType = {
|
||||||
DEFAULT: "default",
|
DEFAULT: "default",
|
||||||
LINES: "lines",
|
LINES: "lines",
|
||||||
@ -25,12 +24,11 @@ export const DocumentGridType = {
|
|||||||
SNAP_TO_CHARS: "snapToChars",
|
SNAP_TO_CHARS: "snapToChars",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/* eslint-enable */
|
export type IDocGridAttributesProperties = {
|
||||||
export interface IDocGridAttributesProperties {
|
|
||||||
readonly type?: (typeof DocumentGridType)[keyof typeof DocumentGridType];
|
readonly type?: (typeof DocumentGridType)[keyof typeof DocumentGridType];
|
||||||
readonly linePitch?: number;
|
readonly linePitch?: number;
|
||||||
readonly charSpace?: number;
|
readonly charSpace?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesProperties> {
|
export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesProperties> {
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./header-footer-reference";
|
import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./header-footer-reference";
|
||||||
|
|
||||||
describe("HeaderFooterReference", () => {
|
describe("HeaderFooterReference", () => {
|
||||||
|
@ -32,10 +32,10 @@ export const HeaderFooterReferenceType = {
|
|||||||
// <xsd:attribute ref="r:id" use="required"/>
|
// <xsd:attribute ref="r:id" use="required"/>
|
||||||
// </xsd:complexType>
|
// </xsd:complexType>
|
||||||
|
|
||||||
export interface IHeaderFooterOptions {
|
export type IHeaderFooterOptions = {
|
||||||
readonly type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
readonly type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
||||||
readonly id?: number;
|
readonly id?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
class FooterReferenceAttributes extends XmlAttributeComponent<{
|
class FooterReferenceAttributes extends XmlAttributeComponent<{
|
||||||
readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
|
import { createLineNumberType } from "./line-number";
|
||||||
|
|
||||||
|
describe("createLineNumberType", () => {
|
||||||
|
it("should work", () => {
|
||||||
|
const textDirection = createLineNumberType({ countBy: 0, start: 0, restart: "newPage", distance: 10 });
|
||||||
|
|
||||||
|
const tree = new Formatter().format(textDirection);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:lnNumType": { _attr: { "w:countBy": 0, "w:start": 0, "w:restart": "newPage", "w:distance": 10 } },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with string measures for distance", () => {
|
||||||
|
const textDirection = createLineNumberType({ countBy: 0, start: 0, restart: "newPage", distance: "10mm" });
|
||||||
|
|
||||||
|
const tree = new Formatter().format(textDirection);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:lnNumType": { _attr: { "w:countBy": 0, "w:start": 0, "w:restart": "newPage", "w:distance": "10mm" } },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with blank entries", () => {
|
||||||
|
const textDirection = createLineNumberType({});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(textDirection);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:lnNumType": { _attr: {} },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,6 +1,6 @@
|
|||||||
// http://officeopenxml.com/WPsectionLineNumbering.php
|
// http://officeopenxml.com/WPsectionLineNumbering.php
|
||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
|
import { PositiveUniversalMeasure, decimalNumber, twipsMeasureValue } from "@util/values";
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_LineNumberRestart">
|
// <xsd:simpleType name="ST_LineNumberRestart">
|
||||||
// <xsd:restriction base="xsd:string">
|
// <xsd:restriction base="xsd:string">
|
||||||
@ -10,13 +10,11 @@ import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@uti
|
|||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const LineNumberRestartFormat = {
|
export const LineNumberRestartFormat = {
|
||||||
NEW_PAGE: "newPage",
|
NEW_PAGE: "newPage",
|
||||||
NEW_SECTION: "newSection",
|
NEW_SECTION: "newSection",
|
||||||
CONTINUOUS: "continuous",
|
CONTINUOUS: "continuous",
|
||||||
} as const;
|
} as const;
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// <xsd:complexType name="CT_LineNumber">
|
// <xsd:complexType name="CT_LineNumber">
|
||||||
// <xsd:attribute name="countBy" type="ST_DecimalNumber" use="optional"/>
|
// <xsd:attribute name="countBy" type="ST_DecimalNumber" use="optional"/>
|
||||||
|
@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
|||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
import { BorderStyle } from "@file/border";
|
import { BorderStyle } from "@file/border";
|
||||||
|
|
||||||
import { PageBorderDisplay, PageBorders, PageBorderZOrder } from "./page-borders";
|
import { PageBorderDisplay, PageBorderZOrder, PageBorders } from "./page-borders";
|
||||||
|
|
||||||
describe("PageBorders", () => {
|
describe("PageBorders", () => {
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
@ -10,13 +10,11 @@ import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent } from "@file/xml-comp
|
|||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const PageBorderDisplay = {
|
export const PageBorderDisplay = {
|
||||||
ALL_PAGES: "allPages",
|
ALL_PAGES: "allPages",
|
||||||
FIRST_PAGE: "firstPage",
|
FIRST_PAGE: "firstPage",
|
||||||
NOT_FIRST_PAGE: "notFirstPage",
|
NOT_FIRST_PAGE: "notFirstPage",
|
||||||
} as const;
|
} as const;
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_PageBorderOffset">
|
// <xsd:simpleType name="ST_PageBorderOffset">
|
||||||
// <xsd:restriction base="xsd:string">
|
// <xsd:restriction base="xsd:string">
|
||||||
@ -40,19 +38,19 @@ export const PageBorderZOrder = {
|
|||||||
FRONT: "front",
|
FRONT: "front",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export interface IPageBorderAttributes {
|
export type IPageBorderAttributes = {
|
||||||
readonly display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay];
|
readonly display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay];
|
||||||
readonly offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom];
|
readonly offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom];
|
||||||
readonly zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder];
|
readonly zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder];
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface IPageBordersOptions {
|
export type IPageBordersOptions = {
|
||||||
readonly pageBorders?: IPageBorderAttributes;
|
readonly pageBorders?: IPageBorderAttributes;
|
||||||
readonly pageBorderTop?: IBorderOptions;
|
readonly pageBorderTop?: IBorderOptions;
|
||||||
readonly pageBorderRight?: IBorderOptions;
|
readonly pageBorderRight?: IBorderOptions;
|
||||||
readonly pageBorderBottom?: IBorderOptions;
|
readonly pageBorderBottom?: IBorderOptions;
|
||||||
readonly pageBorderLeft?: IBorderOptions;
|
readonly pageBorderLeft?: IBorderOptions;
|
||||||
}
|
};
|
||||||
|
|
||||||
class PageBordersAttributes extends XmlAttributeComponent<IPageBorderAttributes> {
|
class PageBordersAttributes extends XmlAttributeComponent<IPageBorderAttributes> {
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values";
|
import { PositiveUniversalMeasure, UniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue } from "@util/values";
|
||||||
|
|
||||||
// <xsd:complexType name="CT_PageMar">
|
// <xsd:complexType name="CT_PageMar">
|
||||||
// <xsd:attribute name="top" type="ST_SignedTwipsMeasure" use="required"/>
|
// <xsd:attribute name="top" type="ST_SignedTwipsMeasure" use="required"/>
|
||||||
|
@ -13,7 +13,6 @@ import { decimalNumber } from "@util/values";
|
|||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const PageNumberSeparator = {
|
export const PageNumberSeparator = {
|
||||||
HYPHEN: "hyphen",
|
HYPHEN: "hyphen",
|
||||||
PERIOD: "period",
|
PERIOD: "period",
|
||||||
@ -22,13 +21,11 @@ export const PageNumberSeparator = {
|
|||||||
EN_DASH: "endash",
|
EN_DASH: "endash",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/* eslint-enable */
|
export type IPageNumberTypeAttributes = {
|
||||||
|
|
||||||
export interface IPageNumberTypeAttributes {
|
|
||||||
readonly start?: number;
|
readonly start?: number;
|
||||||
readonly formatType?: (typeof NumberFormat)[keyof typeof NumberFormat];
|
readonly formatType?: (typeof NumberFormat)[keyof typeof NumberFormat];
|
||||||
readonly separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator];
|
readonly separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator];
|
||||||
}
|
};
|
||||||
|
|
||||||
// <xsd:complexType name="CT_PageNumber">
|
// <xsd:complexType name="CT_PageNumber">
|
||||||
// <xsd:attribute name="fmt" type="ST_NumberFormat" use="optional" default="decimal"/>
|
// <xsd:attribute name="fmt" type="ST_NumberFormat" use="optional" default="decimal"/>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { PageTextDirection, PageTextDirectionType } from "./page-text-direction";
|
import { PageTextDirection, PageTextDirectionType } from "./page-text-direction";
|
||||||
|
|
||||||
describe("PageTextDirection", () => {
|
describe("PageTextDirection", () => {
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const PageTextDirectionType = {
|
export const PageTextDirectionType = {
|
||||||
LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb",
|
LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb",
|
||||||
TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl",
|
TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
class PageTextDirectionAttributes extends XmlAttributeComponent<{
|
class PageTextDirectionAttributes extends XmlAttributeComponent<{
|
||||||
readonly val: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];
|
readonly val: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];
|
||||||
}> {
|
}> {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { SectionType, Type } from "./section-type";
|
import { SectionType, Type } from "./section-type";
|
||||||
|
|
||||||
describe("Type", () => {
|
describe("Type", () => {
|
||||||
|
@ -11,7 +11,6 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const SectionType = {
|
export const SectionType = {
|
||||||
NEXT_PAGE: "nextPage",
|
NEXT_PAGE: "nextPage",
|
||||||
NEXT_COLUMN: "nextColumn",
|
NEXT_COLUMN: "nextColumn",
|
||||||
@ -19,7 +18,6 @@ export const SectionType = {
|
|||||||
EVEN_PAGE: "evenPage",
|
EVEN_PAGE: "evenPage",
|
||||||
ODD_PAGE: "oddPage",
|
ODD_PAGE: "oddPage",
|
||||||
} as const;
|
} as const;
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// <xsd:complexType name="CT_SectType">
|
// <xsd:complexType name="CT_SectType">
|
||||||
// <xsd:attribute name="val" type="ST_SectionMark"/>
|
// <xsd:attribute name="val" type="ST_SectionMark"/>
|
||||||
|
@ -15,7 +15,7 @@ import { LineNumberRestartFormat } from "./properties/line-number";
|
|||||||
import { PageBorderOffsetFrom } from "./properties/page-borders";
|
import { PageBorderOffsetFrom } from "./properties/page-borders";
|
||||||
import { PageTextDirectionType } from "./properties/page-text-direction";
|
import { PageTextDirectionType } from "./properties/page-text-direction";
|
||||||
import { SectionType } from "./properties/section-type";
|
import { SectionType } from "./properties/section-type";
|
||||||
import { sectionMarginDefaults, sectionPageSizeDefaults, SectionProperties } from "./section-properties";
|
import { SectionProperties, sectionMarginDefaults, sectionPageSizeDefaults } from "./section-properties";
|
||||||
|
|
||||||
const DEFAULT_MARGINS = {
|
const DEFAULT_MARGINS = {
|
||||||
"w:bottom": sectionMarginDefaults.BOTTOM,
|
"w:bottom": sectionMarginDefaults.BOTTOM,
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
// http://officeopenxml.com/WPsection.php
|
// http://officeopenxml.com/WPsection.php
|
||||||
// tslint:disable: no-unnecessary-initializer
|
|
||||||
|
|
||||||
import { FooterWrapper } from "@file/footer-wrapper";
|
import { FooterWrapper } from "@file/footer-wrapper";
|
||||||
import { HeaderWrapper } from "@file/header-wrapper";
|
import { HeaderWrapper } from "@file/header-wrapper";
|
||||||
import { VerticalAlign, VerticalAlignElement } from "@file/vertical-align";
|
import { VerticalAlign, VerticalAlignElement } from "@file/vertical-align";
|
||||||
import { OnOffElement, XmlComponent } from "@file/xml-components";
|
import { OnOffElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./properties/header-footer-reference";
|
|
||||||
import { Columns, IColumnsAttributes } from "./properties/columns";
|
import { Columns, IColumnsAttributes } from "./properties/columns";
|
||||||
import { DocumentGrid, IDocGridAttributesProperties } from "./properties/doc-grid";
|
import { DocumentGrid, IDocGridAttributesProperties } from "./properties/doc-grid";
|
||||||
|
import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./properties/header-footer-reference";
|
||||||
import { ILineNumberAttributes, createLineNumberType } from "./properties/line-number";
|
import { ILineNumberAttributes, createLineNumberType } from "./properties/line-number";
|
||||||
import { IPageBordersOptions, PageBorders } from "./properties/page-borders";
|
import { IPageBordersOptions, PageBorders } from "./properties/page-borders";
|
||||||
import { IPageMarginAttributes, PageMargin } from "./properties/page-margin";
|
import { IPageMarginAttributes, PageMargin } from "./properties/page-margin";
|
||||||
@ -17,13 +16,13 @@ import { IPageSizeAttributes, PageOrientation, PageSize } from "./properties/pag
|
|||||||
import { PageTextDirection, PageTextDirectionType } from "./properties/page-text-direction";
|
import { PageTextDirection, PageTextDirectionType } from "./properties/page-text-direction";
|
||||||
import { SectionType, Type } from "./properties/section-type";
|
import { SectionType, Type } from "./properties/section-type";
|
||||||
|
|
||||||
export interface IHeaderFooterGroup<T> {
|
export type IHeaderFooterGroup<T> = {
|
||||||
readonly default?: T;
|
readonly default?: T;
|
||||||
readonly first?: T;
|
readonly first?: T;
|
||||||
readonly even?: T;
|
readonly even?: T;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface ISectionPropertiesOptions {
|
export type ISectionPropertiesOptions = {
|
||||||
readonly page?: {
|
readonly page?: {
|
||||||
readonly size?: IPageSizeAttributes;
|
readonly size?: IPageSizeAttributes;
|
||||||
readonly margin?: IPageMarginAttributes;
|
readonly margin?: IPageMarginAttributes;
|
||||||
@ -39,7 +38,7 @@ export interface ISectionPropertiesOptions {
|
|||||||
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
||||||
readonly column?: IColumnsAttributes;
|
readonly column?: IColumnsAttributes;
|
||||||
readonly type?: (typeof SectionType)[keyof typeof SectionType];
|
readonly type?: (typeof SectionType)[keyof typeof SectionType];
|
||||||
}
|
};
|
||||||
|
|
||||||
// <xsd:complexType name="CT_SectPr">
|
// <xsd:complexType name="CT_SectPr">
|
||||||
// <xsd:sequence>
|
// <xsd:sequence>
|
||||||
|
@ -1,89 +1,60 @@
|
|||||||
import { XmlAttributeComponent } from "@file/xml-components";
|
import { AttributeMap, XmlAttributeComponent } from "@file/xml-components";
|
||||||
|
|
||||||
/* cSpell:disable */
|
/* cSpell:disable */
|
||||||
export interface IDocumentAttributesProperties {
|
export const DocumentAttributeNamespaces = {
|
||||||
readonly wpc?: string;
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
||||||
readonly mc?: string;
|
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||||
readonly o?: string;
|
o: "urn:schemas-microsoft-com:office:office",
|
||||||
readonly r?: string;
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||||
readonly m?: string;
|
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
||||||
readonly v?: string;
|
v: "urn:schemas-microsoft-com:vml",
|
||||||
readonly wp14?: string;
|
wp14: "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
||||||
readonly wp?: string;
|
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
||||||
readonly w10?: string;
|
w10: "urn:schemas-microsoft-com:office:word",
|
||||||
readonly w?: string;
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||||
readonly w14?: string;
|
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||||
readonly w15?: string;
|
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||||
readonly wpg?: string;
|
wpg: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
|
||||||
readonly wpi?: string;
|
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
||||||
readonly wne?: string;
|
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
||||||
readonly wps?: string;
|
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||||
readonly Ignorable?: string;
|
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
||||||
readonly cp?: string;
|
dc: "http://purl.org/dc/elements/1.1/",
|
||||||
readonly dc?: string;
|
dcterms: "http://purl.org/dc/terms/",
|
||||||
readonly dcterms?: string;
|
dcmitype: "http://purl.org/dc/dcmitype/",
|
||||||
readonly dcmitype?: string;
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
readonly xsi?: string;
|
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
||||||
readonly type?: string;
|
cx1: "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",
|
||||||
readonly cx?: string;
|
cx2: "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",
|
||||||
readonly cx1?: string;
|
cx3: "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",
|
||||||
readonly cx2?: string;
|
cx4: "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",
|
||||||
readonly cx3?: string;
|
cx5: "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",
|
||||||
readonly cx4?: string;
|
cx6: "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",
|
||||||
readonly cx5?: string;
|
cx7: "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",
|
||||||
readonly cx6?: string;
|
cx8: "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",
|
||||||
readonly cx7?: string;
|
aink: "http://schemas.microsoft.com/office/drawing/2016/ink",
|
||||||
readonly cx8?: string;
|
am3d: "http://schemas.microsoft.com/office/drawing/2017/model3d",
|
||||||
readonly aink?: string;
|
w16cex: "http://schemas.microsoft.com/office/word/2018/wordml/cex",
|
||||||
readonly am3d?: string;
|
w16cid: "http://schemas.microsoft.com/office/word/2016/wordml/cid",
|
||||||
readonly w16cex?: string;
|
w16: "http://schemas.microsoft.com/office/word/2018/wordml",
|
||||||
readonly w16cid?: string;
|
w16sdtdh: "http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash",
|
||||||
readonly w16?: string;
|
w16se: "http://schemas.microsoft.com/office/word/2015/wordml/symex",
|
||||||
readonly w16sdtdh?: string;
|
};
|
||||||
readonly w16se?: string;
|
|
||||||
}
|
|
||||||
/* cSpell:enable */
|
/* cSpell:enable */
|
||||||
|
|
||||||
|
export type DocumentAttributeNamespace = keyof typeof DocumentAttributeNamespaces;
|
||||||
|
|
||||||
|
export type IDocumentAttributesProperties = Partial<Record<DocumentAttributeNamespace, string>> & {
|
||||||
|
readonly Ignorable?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export class DocumentAttributes extends XmlAttributeComponent<IDocumentAttributesProperties> {
|
export class DocumentAttributes extends XmlAttributeComponent<IDocumentAttributesProperties> {
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
wpc: "xmlns:wpc",
|
|
||||||
mc: "xmlns:mc",
|
|
||||||
o: "xmlns:o",
|
|
||||||
r: "xmlns:r",
|
|
||||||
m: "xmlns:m",
|
|
||||||
v: "xmlns:v",
|
|
||||||
wp14: "xmlns:wp14",
|
|
||||||
wp: "xmlns:wp",
|
|
||||||
w10: "xmlns:w10",
|
|
||||||
w: "xmlns:w",
|
|
||||||
w14: "xmlns:w14",
|
|
||||||
w15: "xmlns:w15",
|
|
||||||
wpg: "xmlns:wpg",
|
|
||||||
wpi: "xmlns:wpi",
|
|
||||||
wne: "xmlns:wne",
|
|
||||||
wps: "xmlns:wps",
|
|
||||||
Ignorable: "mc:Ignorable",
|
Ignorable: "mc:Ignorable",
|
||||||
cp: "xmlns:cp",
|
...Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`])),
|
||||||
dc: "xmlns:dc",
|
} as AttributeMap<IDocumentAttributesProperties>;
|
||||||
dcterms: "xmlns:dcterms",
|
|
||||||
dcmitype: "xmlns:dcmitype",
|
public constructor(ns: readonly DocumentAttributeNamespace[], Ignorable?: string) {
|
||||||
xsi: "xmlns:xsi",
|
super({ Ignorable, ...Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]])) });
|
||||||
type: "xsi:type",
|
}
|
||||||
cx: "xmlns:cx",
|
|
||||||
cx1: "xmlns:cx1",
|
|
||||||
cx2: "xmlns:cx2",
|
|
||||||
cx3: "xmlns:cx3",
|
|
||||||
cx4: "xmlns:cx4",
|
|
||||||
cx5: "xmlns:cx5",
|
|
||||||
cx6: "xmlns:cx6",
|
|
||||||
cx7: "xmlns:cx7",
|
|
||||||
cx8: "xmlns:cx8",
|
|
||||||
aink: "xmlns:aink",
|
|
||||||
am3d: "xmlns:am3d",
|
|
||||||
w16cex: "xmlns:w16cex",
|
|
||||||
w16cid: "xmlns:w16cid",
|
|
||||||
w16: "xmlns:w16",
|
|
||||||
w16sdtdh: "xmlns:w16sdtdh",
|
|
||||||
w16se: "xmlns:w16se",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ export class DocumentBackgroundAttributes extends XmlAttributeComponent<{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDocumentBackgroundOptions {
|
export type IDocumentBackgroundOptions = {
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
readonly themeColor?: string;
|
readonly themeColor?: string;
|
||||||
readonly themeShade?: string;
|
readonly themeShade?: string;
|
||||||
readonly themeTint?: string;
|
readonly themeTint?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
// <xsd:complexType name="CT_Background">
|
// <xsd:complexType name="CT_Background">
|
||||||
// <xsd:sequence>
|
// <xsd:sequence>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/WPdocument.php
|
// http://officeopenxml.com/WPdocument.php
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { ConcreteHyperlink, Paragraph } from "../paragraph";
|
import { ConcreteHyperlink, Paragraph } from "../paragraph";
|
||||||
import { Table } from "../table";
|
import { Table } from "../table";
|
||||||
import { TableOfContents } from "../table-of-contents";
|
import { TableOfContents } from "../table-of-contents";
|
||||||
@ -7,9 +8,9 @@ import { Body } from "./body";
|
|||||||
import { DocumentAttributes } from "./document-attributes";
|
import { DocumentAttributes } from "./document-attributes";
|
||||||
import { DocumentBackground, IDocumentBackgroundOptions } from "./document-background";
|
import { DocumentBackground, IDocumentBackgroundOptions } from "./document-background";
|
||||||
|
|
||||||
export interface IDocumentOptions {
|
export type IDocumentOptions = {
|
||||||
readonly background?: IDocumentBackgroundOptions;
|
readonly background?: IDocumentBackgroundOptions;
|
||||||
}
|
};
|
||||||
|
|
||||||
// <xsd:element name="document" type="CT_Document"/>
|
// <xsd:element name="document" type="CT_Document"/>
|
||||||
//
|
//
|
||||||
@ -36,41 +37,43 @@ export class Document extends XmlComponent {
|
|||||||
public constructor(options: IDocumentOptions) {
|
public constructor(options: IDocumentOptions) {
|
||||||
super("w:document");
|
super("w:document");
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new DocumentAttributes({
|
new DocumentAttributes(
|
||||||
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
[
|
||||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
"wpc",
|
||||||
o: "urn:schemas-microsoft-com:office:office",
|
"mc",
|
||||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
"o",
|
||||||
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
"r",
|
||||||
v: "urn:schemas-microsoft-com:vml",
|
"m",
|
||||||
wp14: "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
"v",
|
||||||
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
"wp14",
|
||||||
w10: "urn:schemas-microsoft-com:office:word",
|
"wp",
|
||||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
"w10",
|
||||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
"w",
|
||||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
"w14",
|
||||||
wpg: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
|
"w15",
|
||||||
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
"wpg",
|
||||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
"wpi",
|
||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
"wne",
|
||||||
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
"wps",
|
||||||
cx1: "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",
|
"cx",
|
||||||
cx2: "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",
|
"cx1",
|
||||||
cx3: "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",
|
"cx2",
|
||||||
cx4: "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",
|
"cx3",
|
||||||
cx5: "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",
|
"cx4",
|
||||||
cx6: "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",
|
"cx5",
|
||||||
cx7: "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",
|
"cx6",
|
||||||
cx8: "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",
|
"cx7",
|
||||||
aink: "http://schemas.microsoft.com/office/drawing/2016/ink",
|
"cx8",
|
||||||
am3d: "http://schemas.microsoft.com/office/drawing/2017/model3d",
|
"aink",
|
||||||
w16cex: "http://schemas.microsoft.com/office/word/2018/wordml/cex",
|
"am3d",
|
||||||
w16cid: "http://schemas.microsoft.com/office/word/2016/wordml/cid",
|
"w16cex",
|
||||||
w16: "http://schemas.microsoft.com/office/word/2018/wordml",
|
"w16cid",
|
||||||
w16sdtdh: "http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash",
|
"w16",
|
||||||
w16se: "http://schemas.microsoft.com/office/word/2015/wordml/symex",
|
"w16sdtdh",
|
||||||
Ignorable: "w14 w15 wp14",
|
"w16se",
|
||||||
}),
|
],
|
||||||
|
"w14 w15 wp14",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
this.body = new Body();
|
this.body = new Body();
|
||||||
if (options.background) {
|
if (options.background) {
|
||||||
@ -80,7 +83,6 @@ export class Document extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public add(item: Paragraph | Table | TableOfContents | ConcreteHyperlink): Document {
|
public add(item: Paragraph | Table | TableOfContents | ConcreteHyperlink): Document {
|
||||||
// eslint-disable-next-line functional/immutable-data
|
|
||||||
this.body.push(item);
|
this.body.push(item);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import { XmlAttributeComponent } from "@file/xml-components";
|
import { XmlAttributeComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { IDistance } from "../drawing";
|
import { IDistance } from "../drawing";
|
||||||
|
|
||||||
export interface IAnchorAttributes extends IDistance {
|
export type IAnchorAttributes = {
|
||||||
readonly allowOverlap?: "0" | "1";
|
readonly allowOverlap?: "0" | "1";
|
||||||
readonly behindDoc?: "0" | "1";
|
readonly behindDoc?: "0" | "1";
|
||||||
readonly layoutInCell?: "0" | "1";
|
readonly layoutInCell?: "0" | "1";
|
||||||
readonly locked?: "0" | "1";
|
readonly locked?: "0" | "1";
|
||||||
readonly relativeHeight?: number;
|
readonly relativeHeight?: number;
|
||||||
readonly simplePos?: "0" | "1";
|
readonly simplePos?: "0" | "1";
|
||||||
}
|
} & IDistance;
|
||||||
|
|
||||||
export class AnchorAttributes extends XmlAttributeComponent<IAnchorAttributes> {
|
export class AnchorAttributes extends XmlAttributeComponent<IAnchorAttributes> {
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { assert, describe, expect, it } from "vitest";
|
import { assert, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { Utility } from "tests/utility";
|
import { Utility } from "tests/utility";
|
||||||
|
|
||||||
import { IDrawingOptions } from "../drawing";
|
import { IDrawingOptions } from "../drawing";
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// http://officeopenxml.com/drwPicFloating.php
|
// http://officeopenxml.com/drwPicFloating.php
|
||||||
import { IMediaData, IMediaDataTransformation } from "@file/media";
|
import { IMediaData, IMediaDataTransformation } from "@file/media";
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { IDrawingOptions } from "../drawing";
|
import { IDrawingOptions } from "../drawing";
|
||||||
import { HorizontalPosition, IFloating, SimplePos, VerticalPosition } from "../floating";
|
import { HorizontalPosition, IFloating, SimplePos, VerticalPosition } from "../floating";
|
||||||
import { Graphic } from "../inline/graphic";
|
import { Graphic } from "../inline/graphic";
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docPr_topic_ID0ES32OB.html
|
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docPr_topic_ID0ES32OB.html
|
||||||
import { IContext, IXmlableObject, NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
|
||||||
import { ConcreteHyperlink } from "@file/paragraph";
|
import { ConcreteHyperlink } from "@file/paragraph";
|
||||||
|
import { IContext, IXmlableObject, NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
import { docPropertiesUniqueNumericIdGen } from "@util/convenience-functions";
|
import { docPropertiesUniqueNumericIdGen } from "@util/convenience-functions";
|
||||||
|
|
||||||
import { createHyperlinkClick } from "./doc-properties-children";
|
import { createHyperlinkClick } from "./doc-properties-children";
|
||||||
@ -18,11 +17,11 @@ import { createHyperlinkClick } from "./doc-properties-children";
|
|||||||
// <attribute name="hidden" type="xsd:boolean" use="optional" default="false" />
|
// <attribute name="hidden" type="xsd:boolean" use="optional" default="false" />
|
||||||
// </complexType>
|
// </complexType>
|
||||||
|
|
||||||
export interface DocPropertiesOptions {
|
export type DocPropertiesOptions = {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly description: string;
|
readonly description: string;
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class DocProperties extends XmlComponent {
|
export class DocProperties extends XmlComponent {
|
||||||
private readonly docPropertiesUniqueNumericId = docPropertiesUniqueNumericIdGen();
|
private readonly docPropertiesUniqueNumericId = docPropertiesUniqueNumericIdGen();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { IContext } from "@file/xml-components";
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
import { IContext } from "@file/xml-components";
|
||||||
|
|
||||||
import { ConcreteHyperlink, TextRun } from "../";
|
import { ConcreteHyperlink, TextRun } from "../";
|
||||||
import { Drawing, IDrawingOptions } from "./drawing";
|
import { Drawing, IDrawingOptions } from "./drawing";
|
||||||
@ -80,7 +80,6 @@ describe("Drawing", () => {
|
|||||||
{
|
{
|
||||||
"a:graphicFrameLocks": {
|
"a:graphicFrameLocks": {
|
||||||
_attr: {
|
_attr: {
|
||||||
// tslint:disable-next-line:object-literal-key-quotes
|
|
||||||
noChangeAspect: 1,
|
noChangeAspect: 1,
|
||||||
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||||
},
|
},
|
||||||
@ -139,7 +138,6 @@ describe("Drawing", () => {
|
|||||||
{
|
{
|
||||||
"a:blip": {
|
"a:blip": {
|
||||||
_attr: {
|
_attr: {
|
||||||
// tslint:disable-next-line:object-literal-key-quotes
|
|
||||||
cstate: "none",
|
cstate: "none",
|
||||||
"r:embed": "rId{test.jpg}",
|
"r:embed": "rId{test.jpg}",
|
||||||
},
|
},
|
||||||
@ -311,7 +309,6 @@ describe("Drawing", () => {
|
|||||||
{
|
{
|
||||||
"a:graphicFrameLocks": {
|
"a:graphicFrameLocks": {
|
||||||
_attr: {
|
_attr: {
|
||||||
// tslint:disable-next-line:object-literal-key-quotes
|
|
||||||
noChangeAspect: 1,
|
noChangeAspect: 1,
|
||||||
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||||
},
|
},
|
||||||
@ -370,7 +367,6 @@ describe("Drawing", () => {
|
|||||||
{
|
{
|
||||||
"a:blip": {
|
"a:blip": {
|
||||||
_attr: {
|
_attr: {
|
||||||
// tslint:disable-next-line:object-literal-key-quotes
|
|
||||||
cstate: "none",
|
cstate: "none",
|
||||||
"r:embed": "rId{test.jpg}",
|
"r:embed": "rId{test.jpg}",
|
||||||
},
|
},
|
||||||
@ -554,7 +550,6 @@ describe("Drawing", () => {
|
|||||||
{
|
{
|
||||||
"a:graphicFrameLocks": {
|
"a:graphicFrameLocks": {
|
||||||
_attr: {
|
_attr: {
|
||||||
// tslint:disable-next-line:object-literal-key-quotes
|
|
||||||
noChangeAspect: 1,
|
noChangeAspect: 1,
|
||||||
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||||
},
|
},
|
||||||
@ -622,7 +617,6 @@ describe("Drawing", () => {
|
|||||||
{
|
{
|
||||||
"a:blip": {
|
"a:blip": {
|
||||||
_attr: {
|
_attr: {
|
||||||
// tslint:disable-next-line:object-literal-key-quotes
|
|
||||||
cstate: "none",
|
cstate: "none",
|
||||||
"r:embed": "rId{test.jpg}",
|
"r:embed": "rId{test.jpg}",
|
||||||
},
|
},
|
||||||
|
@ -14,11 +14,11 @@ export type IDistance = {
|
|||||||
readonly distR?: number;
|
readonly distR?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IDrawingOptions {
|
export type IDrawingOptions = {
|
||||||
readonly floating?: IFloating;
|
readonly floating?: IFloating;
|
||||||
readonly docProperties?: DocPropertiesOptions;
|
readonly docProperties?: DocPropertiesOptions;
|
||||||
readonly outline?: OutlineOptions;
|
readonly outline?: OutlineOptions;
|
||||||
}
|
};
|
||||||
|
|
||||||
// <xsd:complexType name="CT_Drawing">
|
// <xsd:complexType name="CT_Drawing">
|
||||||
// <xsd:choice minOccurs="1" maxOccurs="unbounded">
|
// <xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||||
|
@ -7,6 +7,12 @@ export type EffectExtentAttributes = {
|
|||||||
readonly left: number;
|
readonly left: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_EffectExtent">
|
||||||
|
// <xsd:attribute name="l" type="a:ST_Coordinate" use="required"/>
|
||||||
|
// <xsd:attribute name="t" type="a:ST_Coordinate" use="required"/>
|
||||||
|
// <xsd:attribute name="r" type="a:ST_Coordinate" use="required"/>
|
||||||
|
// <xsd:attribute name="b" type="a:ST_Coordinate" use="required"/>
|
||||||
|
// </xsd:complexType>
|
||||||
export const createEffectExtent = ({ top, right, bottom, left }: EffectExtentAttributes): XmlComponent =>
|
export const createEffectExtent = ({ top, right, bottom, left }: EffectExtentAttributes): XmlComponent =>
|
||||||
new BuilderElement<EffectExtentAttributes>({
|
new BuilderElement<EffectExtentAttributes>({
|
||||||
name: "wp:effectExtent",
|
name: "wp:effectExtent",
|
||||||
|
@ -4,7 +4,6 @@ import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared/ali
|
|||||||
|
|
||||||
import { ITextWrapping } from "../text-wrap";
|
import { ITextWrapping } from "../text-wrap";
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const HorizontalPositionRelativeFrom = {
|
export const HorizontalPositionRelativeFrom = {
|
||||||
CHARACTER: "character",
|
CHARACTER: "character",
|
||||||
COLUMN: "column",
|
COLUMN: "column",
|
||||||
@ -27,27 +26,26 @@ export const VerticalPositionRelativeFrom = {
|
|||||||
TOP_MARGIN: "topMargin",
|
TOP_MARGIN: "topMargin",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/* eslint-enable */
|
export type IHorizontalPositionOptions = {
|
||||||
export interface IHorizontalPositionOptions {
|
|
||||||
readonly relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];
|
readonly relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];
|
||||||
readonly align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];
|
readonly align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];
|
||||||
readonly offset?: number;
|
readonly offset?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface IVerticalPositionOptions {
|
export type IVerticalPositionOptions = {
|
||||||
readonly relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];
|
readonly relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];
|
||||||
readonly align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];
|
readonly align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];
|
||||||
readonly offset?: number;
|
readonly offset?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface IMargins {
|
export type IMargins = {
|
||||||
readonly left?: number;
|
readonly left?: number;
|
||||||
readonly bottom?: number;
|
readonly bottom?: number;
|
||||||
readonly top?: number;
|
readonly top?: number;
|
||||||
readonly right?: number;
|
readonly right?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface IFloating {
|
export type IFloating = {
|
||||||
readonly horizontalPosition: IHorizontalPositionOptions;
|
readonly horizontalPosition: IHorizontalPositionOptions;
|
||||||
readonly verticalPosition: IVerticalPositionOptions;
|
readonly verticalPosition: IVerticalPositionOptions;
|
||||||
readonly allowOverlap?: boolean;
|
readonly allowOverlap?: boolean;
|
||||||
@ -57,4 +55,4 @@ export interface IFloating {
|
|||||||
readonly margins?: IMargins;
|
readonly margins?: IMargins;
|
||||||
readonly wrap?: ITextWrapping;
|
readonly wrap?: ITextWrapping;
|
||||||
readonly zIndex?: number;
|
readonly zIndex?: number;
|
||||||
}
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/drwPicFloating-position.php
|
// http://officeopenxml.com/drwPicFloating-position.php
|
||||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { Align } from "./align";
|
import { Align } from "./align";
|
||||||
import { HorizontalPositionRelativeFrom, IHorizontalPositionOptions } from "./floating-position";
|
import { HorizontalPositionRelativeFrom, IHorizontalPositionOptions } from "./floating-position";
|
||||||
import { PositionOffset } from "./position-offset";
|
import { PositionOffset } from "./position-offset";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/drwPicFloating-position.php
|
// http://officeopenxml.com/drwPicFloating-position.php
|
||||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { Align } from "./align";
|
import { Align } from "./align";
|
||||||
import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floating-position";
|
import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floating-position";
|
||||||
import { PositionOffset } from "./position-offset";
|
import { PositionOffset } from "./position-offset";
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { GraphicFrameLockAttributes } from "./graphic-frame-lock-attributes";
|
import { GraphicFrameLockAttributes } from "./graphic-frame-lock-attributes";
|
||||||
|
|
||||||
export class GraphicFrameLocks extends XmlComponent {
|
export class GraphicFrameLocks extends XmlComponent {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { GraphicFrameLocks } from "./graphic-frame-locks/graphic-frame-locks";
|
import { GraphicFrameLocks } from "./graphic-frame-locks/graphic-frame-locks";
|
||||||
|
|
||||||
export class GraphicFrameProperties extends XmlComponent {
|
export class GraphicFrameProperties extends XmlComponent {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
|
||||||
import { IMediaData } from "@file/media";
|
import { IMediaData } from "@file/media";
|
||||||
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
const createSvgBlip = (mediaData: IMediaData): XmlComponent =>
|
const createSvgBlip = (mediaData: IMediaData): XmlComponent =>
|
||||||
new BuilderElement({
|
new BuilderElement({
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { IMediaData } from "@file/media";
|
import { IMediaData } from "@file/media";
|
||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { createExtentionList } from "./blip-extentions";
|
import { createExtentionList } from "./blip-extentions";
|
||||||
|
|
||||||
type BlipAttributes = {
|
type BlipAttributes = {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { PicLocks } from "./pic-locks/pic-locks";
|
import { PicLocks } from "./pic-locks/pic-locks";
|
||||||
|
|
||||||
export class ChildNonVisualProperties extends XmlComponent {
|
export class ChildNonVisualProperties extends XmlComponent {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { PicLocksAttributes } from "./pic-locks-attributes";
|
import { PicLocksAttributes } from "./pic-locks-attributes";
|
||||||
|
|
||||||
export class PicLocks extends XmlComponent {
|
export class PicLocks extends XmlComponent {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { ChildNonVisualProperties } from "./child-non-visual-pic-properties/child-non-visual-pic-properties";
|
import { ChildNonVisualProperties } from "./child-non-visual-pic-properties/child-non-visual-pic-properties";
|
||||||
import { NonVisualProperties } from "./non-visual-properties/non-visual-properties";
|
import { NonVisualProperties } from "./non-visual-properties/non-visual-properties";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
|
|
||||||
import { createHyperlinkClick } from "@file/drawing/doc-properties/doc-properties-children";
|
import { createHyperlinkClick } from "@file/drawing/doc-properties/doc-properties-children";
|
||||||
import { ConcreteHyperlink } from "@file/paragraph";
|
import { ConcreteHyperlink } from "@file/paragraph";
|
||||||
|
import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { NonVisualPropertiesAttributes } from "./non-visual-properties-attributes";
|
import { NonVisualPropertiesAttributes } from "./non-visual-properties-attributes";
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { BlipFill } from "./blip/blip-fill";
|
import { BlipFill } from "./blip/blip-fill";
|
||||||
import { NonVisualPicProperties } from "./non-visual-pic-properties/non-visual-pic-properties";
|
import { NonVisualPicProperties } from "./non-visual-pic-properties/non-visual-pic-properties";
|
||||||
import { PicAttributes } from "./pic-attributes";
|
import { PicAttributes } from "./pic-attributes";
|
||||||
import { ShapeProperties } from "./shape-properties/shape-properties";
|
|
||||||
import { OutlineOptions } from "./shape-properties/outline/outline";
|
import { OutlineOptions } from "./shape-properties/outline/outline";
|
||||||
|
import { ShapeProperties } from "./shape-properties/shape-properties";
|
||||||
|
|
||||||
export class Pic extends XmlComponent {
|
export class Pic extends XmlComponent {
|
||||||
public constructor({
|
public constructor({
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { Form } from "./form/form";
|
import { Form } from "./form/form";
|
||||||
|
|
||||||
describe("Form", () => {
|
describe("Form", () => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/drwSp-size.php
|
// http://officeopenxml.com/drwSp-size.php
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { ExtentsAttributes } from "./extents-attributes";
|
import { ExtentsAttributes } from "./extents-attributes";
|
||||||
|
|
||||||
export class Extents extends XmlComponent {
|
export class Extents extends XmlComponent {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/drwSp-size.php
|
// http://officeopenxml.com/drwSp-size.php
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { OffsetAttributes } from "./off-attributes";
|
import { OffsetAttributes } from "./off-attributes";
|
||||||
|
|
||||||
export class Offset extends XmlComponent {
|
export class Offset extends XmlComponent {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// http://officeopenxml.com/drwSp-outline.php
|
// http://officeopenxml.com/drwSp-outline.php
|
||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { createNoFill } from "./no-fill";
|
import { createNoFill } from "./no-fill";
|
||||||
import { createSolidFill } from "./solid-fill";
|
|
||||||
import { SchemeColor } from "./scheme-color";
|
import { SchemeColor } from "./scheme-color";
|
||||||
|
import { createSolidFill } from "./solid-fill";
|
||||||
|
|
||||||
// <xsd:complexType name="CT_TextOutlineEffect">
|
// <xsd:complexType name="CT_TextOutlineEffect">
|
||||||
// <xsd:sequence>
|
// <xsd:sequence>
|
||||||
|
@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest";
|
|||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { createSolidFill } from "./solid-fill";
|
|
||||||
import { SchemeColor } from "./scheme-color";
|
import { SchemeColor } from "./scheme-color";
|
||||||
|
import { createSolidFill } from "./solid-fill";
|
||||||
|
|
||||||
describe("createSolidFill", () => {
|
describe("createSolidFill", () => {
|
||||||
it("should create of rgb", () => {
|
it("should create of rgb", () => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { createSchemeColor, SchemeColor } from "./scheme-color";
|
|
||||||
import { createSolidRgbColor } from "./rgb-color";
|
import { createSolidRgbColor } from "./rgb-color";
|
||||||
|
import { SchemeColor, createSchemeColor } from "./scheme-color";
|
||||||
|
|
||||||
export type RgbColorOptions = {
|
export type RgbColorOptions = {
|
||||||
readonly type: "rgb";
|
readonly type: "rgb";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/drwSp-prstGeom.php
|
// http://officeopenxml.com/drwSp-prstGeom.php
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { AdjustmentValues } from "./adjustment-values/adjustment-values";
|
import { AdjustmentValues } from "./adjustment-values/adjustment-values";
|
||||||
import { PresetGeometryAttributes } from "./preset-geometry-attributes";
|
import { PresetGeometryAttributes } from "./preset-geometry-attributes";
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// http://officeopenxml.com/drwSp-SpPr.php
|
// http://officeopenxml.com/drwSp-SpPr.php
|
||||||
import { IMediaDataTransformation } from "@file/media";
|
import { IMediaDataTransformation } from "@file/media";
|
||||||
import { XmlComponent } from "@file/xml-components";
|
import { XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { Form } from "./form";
|
import { Form } from "./form";
|
||||||
|
import { createNoFill } from "./outline/no-fill";
|
||||||
import { OutlineOptions, createOutline } from "./outline/outline";
|
import { OutlineOptions, createOutline } from "./outline/outline";
|
||||||
import { PresetGeometry } from "./preset-geometry/preset-geometry";
|
import { PresetGeometry } from "./preset-geometry/preset-geometry";
|
||||||
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
||||||
import { createNoFill } from "./outline/no-fill";
|
|
||||||
|
|
||||||
export class ShapeProperties extends XmlComponent {
|
export class ShapeProperties extends XmlComponent {
|
||||||
private readonly form: Form;
|
private readonly form: Form;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { createInline } from "./inline";
|
import { createInline } from "./inline";
|
||||||
|
|
||||||
describe("Inline", () => {
|
describe("Inline", () => {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// http://officeopenxml.com/drwPicInline.php
|
// http://officeopenxml.com/drwPicInline.php
|
||||||
import { IMediaData, IMediaDataTransformation } from "@file/media";
|
import { IMediaData, IMediaDataTransformation } from "@file/media";
|
||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { DocProperties, DocPropertiesOptions } from "./../doc-properties/doc-properties";
|
import { DocProperties, DocPropertiesOptions } from "./../doc-properties/doc-properties";
|
||||||
import { createEffectExtent } from "./../effect-extent/effect-extent";
|
import { createEffectExtent } from "./../effect-extent/effect-extent";
|
||||||
import { Extent } from "./../extent/extent";
|
import { Extent } from "./../extent/extent";
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||||
import { IDistance } from "../drawing";
|
import { IDistance } from "../drawing";
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
export const TextWrappingType = {
|
export const TextWrappingType = {
|
||||||
NONE: 0,
|
NONE: 0,
|
||||||
SQUARE: 1,
|
SQUARE: 1,
|
||||||
@ -16,10 +15,8 @@ export const TextWrappingSide = {
|
|||||||
LARGEST: "largest",
|
LARGEST: "largest",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/* eslint-enable */
|
export type ITextWrapping = {
|
||||||
|
|
||||||
export interface ITextWrapping {
|
|
||||||
readonly type: (typeof TextWrappingType)[keyof typeof TextWrappingType];
|
readonly type: (typeof TextWrappingType)[keyof typeof TextWrappingType];
|
||||||
readonly side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
|
readonly side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
|
||||||
readonly margins?: IDistance;
|
readonly margins?: IDistance;
|
||||||
}
|
};
|
||||||
|
@ -5,9 +5,9 @@ import { IDistance } from "../drawing";
|
|||||||
import { IMargins } from "../floating";
|
import { IMargins } from "../floating";
|
||||||
import { ITextWrapping, TextWrappingSide } from "./text-wrapping";
|
import { ITextWrapping, TextWrappingSide } from "./text-wrapping";
|
||||||
|
|
||||||
interface IWrapSquareAttributes extends IDistance {
|
type IWrapSquareAttributes = {
|
||||||
readonly wrapText?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
|
readonly wrapText?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
|
||||||
}
|
} & IDistance;
|
||||||
|
|
||||||
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
|
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
|
@ -479,4 +479,41 @@ describe("File", () => {
|
|||||||
expect(doc.Styles).to.not.be.undefined;
|
expect(doc.Styles).to.not.be.undefined;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#features", () => {
|
||||||
|
it("should work with updateFields", () => {
|
||||||
|
const doc = new File({
|
||||||
|
sections: [],
|
||||||
|
features: {
|
||||||
|
updateFields: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(doc.Styles).to.not.be.undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with trackRevisions", () => {
|
||||||
|
const doc = new File({
|
||||||
|
sections: [],
|
||||||
|
features: {
|
||||||
|
trackRevisions: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(doc.Styles).to.not.be.undefined;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#hyphenation", () => {
|
||||||
|
it("should work with autoHyphenation", () => {
|
||||||
|
const doc = new File({
|
||||||
|
sections: [],
|
||||||
|
hyphenation: {
|
||||||
|
autoHyphenation: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(doc.Styles).to.not.be.undefined;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,10 @@ import { AppProperties } from "./app-properties/app-properties";
|
|||||||
import { ContentTypes } from "./content-types/content-types";
|
import { ContentTypes } from "./content-types/content-types";
|
||||||
import { CoreProperties, IPropertiesOptions } from "./core-properties";
|
import { CoreProperties, IPropertiesOptions } from "./core-properties";
|
||||||
import { CustomProperties } from "./custom-properties";
|
import { CustomProperties } from "./custom-properties";
|
||||||
import { DocumentWrapper } from "./document-wrapper";
|
|
||||||
import { HeaderFooterReferenceType, ISectionPropertiesOptions } from "./document/body/section-properties";
|
import { HeaderFooterReferenceType, ISectionPropertiesOptions } from "./document/body/section-properties";
|
||||||
|
import { DocumentWrapper } from "./document-wrapper";
|
||||||
|
import { FileChild } from "./file-child";
|
||||||
|
import { FontWrapper } from "./fonts/font-wrapper";
|
||||||
import { FooterWrapper, IDocumentFooter } from "./footer-wrapper";
|
import { FooterWrapper, IDocumentFooter } from "./footer-wrapper";
|
||||||
import { FootnotesWrapper } from "./footnotes-wrapper";
|
import { FootnotesWrapper } from "./footnotes-wrapper";
|
||||||
import { Footer, Header } from "./header";
|
import { Footer, Header } from "./header";
|
||||||
@ -16,10 +18,8 @@ import { Settings } from "./settings";
|
|||||||
import { Styles } from "./styles";
|
import { Styles } from "./styles";
|
||||||
import { ExternalStylesFactory } from "./styles/external-styles-factory";
|
import { ExternalStylesFactory } from "./styles/external-styles-factory";
|
||||||
import { DefaultStylesFactory } from "./styles/factory";
|
import { DefaultStylesFactory } from "./styles/factory";
|
||||||
import { FileChild } from "./file-child";
|
|
||||||
import { FontWrapper } from "./fonts/font-wrapper";
|
|
||||||
|
|
||||||
export interface ISectionOptions {
|
export type ISectionOptions = {
|
||||||
readonly headers?: {
|
readonly headers?: {
|
||||||
readonly default?: Header;
|
readonly default?: Header;
|
||||||
readonly first?: Header;
|
readonly first?: Header;
|
||||||
@ -32,7 +32,7 @@ export interface ISectionOptions {
|
|||||||
};
|
};
|
||||||
readonly properties?: ISectionPropertiesOptions;
|
readonly properties?: ISectionPropertiesOptions;
|
||||||
readonly children: readonly FileChild[];
|
readonly children: readonly FileChild[];
|
||||||
}
|
};
|
||||||
|
|
||||||
export class File {
|
export class File {
|
||||||
// eslint-disable-next-line functional/prefer-readonly-type
|
// eslint-disable-next-line functional/prefer-readonly-type
|
||||||
@ -80,6 +80,12 @@ export class File {
|
|||||||
trackRevisions: options.features?.trackRevisions,
|
trackRevisions: options.features?.trackRevisions,
|
||||||
updateFields: options.features?.updateFields,
|
updateFields: options.features?.updateFields,
|
||||||
defaultTabStop: options.defaultTabStop,
|
defaultTabStop: options.defaultTabStop,
|
||||||
|
hyphenation: {
|
||||||
|
autoHyphenation: options.hyphenation?.autoHyphenation,
|
||||||
|
hyphenationZone: options.hyphenation?.hyphenationZone,
|
||||||
|
consecutiveHyphenLimit: options.hyphenation?.consecutiveHyphenLimit,
|
||||||
|
doNotHyphenateCaps: options.hyphenation?.doNotHyphenateCaps,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.media = new Media();
|
this.media = new Media();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
import { createRegularFont } from "./create-regular-font";
|
import { createRegularFont } from "./create-regular-font";
|
||||||
import { FontOptionsWithKey } from "./font-wrapper";
|
|
||||||
import { CharacterSet } from "./font";
|
import { CharacterSet } from "./font";
|
||||||
|
import { FontOptionsWithKey } from "./font-wrapper";
|
||||||
|
|
||||||
// <xsd:complexType name="CT_FontsList">
|
// <xsd:complexType name="CT_FontsList">
|
||||||
// <xsd:sequence>
|
// <xsd:sequence>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BuilderElement, createStringElement, OnOffElement, XmlComponent } from "@file/xml-components";
|
import { BuilderElement, OnOffElement, XmlComponent, createStringElement } from "@file/xml-components";
|
||||||
|
|
||||||
// <xsd:complexType name="CT_Font">
|
// <xsd:complexType name="CT_Font">
|
||||||
// <xsd:sequence>
|
// <xsd:sequence>
|
||||||
@ -27,7 +27,7 @@ import { BuilderElement, createStringElement, OnOffElement, XmlComponent } from
|
|||||||
// </xsd:complexType>
|
// </xsd:complexType>
|
||||||
|
|
||||||
// http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html
|
// http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html
|
||||||
export interface IFontRelationshipOptions {
|
export type IFontRelationshipOptions = {
|
||||||
/**
|
/**
|
||||||
* Relationship to Part
|
* Relationship to Part
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,7 @@ export interface IFontRelationshipOptions {
|
|||||||
* Embedded Font Is Subsetted
|
* Embedded Font Is Subsetted
|
||||||
*/
|
*/
|
||||||
readonly subsetted?: boolean;
|
readonly subsetted?: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const CharacterSet = {
|
export const CharacterSet = {
|
||||||
ANSI: "00",
|
ANSI: "00",
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user