Compare commits

...

73 Commits
8.1.0 ... 8.2.2

Author SHA1 Message Date
63db9f290c Version bump 2023-07-20 22:44:30 +01:00
e8bd4bd6c6 Merge pull request #2256 from dolanmiu/feature/tweak-build
Remove default browser export
2023-07-20 22:42:56 +01:00
28d93b0c42 Remove default browser export
Fixes Angular issue
2023-07-20 20:46:53 +01:00
95f8e37006 Version bump 2023-07-19 02:10:13 +01:00
87083cb264 Merge pull request #2240 from dolanmiu/dependabot/npm_and_yarn/vite-plugin-dts-3.3.1
build(deps-dev): bump vite-plugin-dts from 2.3.0 to 3.3.1
2023-07-19 01:49:10 +01:00
1e8dc95c9c Merge pull request #2227 from dolanmiu/dependabot/npm_and_yarn/vitest/ui-0.33.0
build(deps-dev): bump @vitest/ui from 0.32.2 to 0.33.0
2023-07-19 01:49:04 +01:00
abfa242c28 build(deps-dev): bump @vitest/ui from 0.32.2 to 0.33.0
Bumps [@vitest/ui](https://github.com/vitest-dev/vitest/tree/HEAD/packages/ui) from 0.32.2 to 0.33.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.33.0/packages/ui)

---
updated-dependencies:
- dependency-name: "@vitest/ui"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 00:37:38 +00:00
56b5414152 build(deps-dev): bump vite-plugin-dts from 2.3.0 to 3.3.1
Bumps [vite-plugin-dts](https://github.com/qmhc/vite-plugin-dts) from 2.3.0 to 3.3.1.
- [Release notes](https://github.com/qmhc/vite-plugin-dts/releases)
- [Changelog](https://github.com/qmhc/vite-plugin-dts/blob/main/CHANGELOG.md)
- [Commits](https://github.com/qmhc/vite-plugin-dts/compare/v2.3.0...v3.3.1)

---
updated-dependencies:
- dependency-name: vite-plugin-dts
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 00:37:28 +00:00
8f46060be2 Merge pull request #2235 from dolanmiu/dependabot/npm_and_yarn/types/node-20.4.2
build(deps): bump @types/node from 20.3.2 to 20.4.2
2023-07-19 01:36:41 +01:00
93b17ca2af Merge pull request #2226 from dolanmiu/dependabot/npm_and_yarn/vitest/coverage-v8-0.33.0
build(deps-dev): bump @vitest/coverage-v8 from 0.32.2 to 0.33.0
2023-07-19 01:36:27 +01:00
66008115b8 build(deps-dev): bump @vitest/coverage-v8 from 0.32.2 to 0.33.0
Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 0.32.2 to 0.33.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.33.0/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-v8"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 00:23:34 +00:00
55697a7c32 build(deps): bump @types/node from 20.3.2 to 20.4.2
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.3.2 to 20.4.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 00:22:54 +00:00
e9b259db6b Merge pull request #2241 from dolanmiu/dependabot/npm_and_yarn/eslint-plugin-jsdoc-46.4.4
build(deps-dev): bump eslint-plugin-jsdoc from 46.4.2 to 46.4.4
2023-07-19 01:22:29 +01:00
55c51f7af1 Merge pull request #2238 from dolanmiu/dependabot/npm_and_yarn/eslint-8.45.0
build(deps-dev): bump eslint from 8.43.0 to 8.45.0
2023-07-19 01:22:22 +01:00
4e7fd6a6dc Merge pull request #2242 from dolanmiu/dependabot/npm_and_yarn/esbuild/win32-x64-0.18.14
build(deps-dev): bump @esbuild/win32-x64 from 0.18.10 to 0.18.14
2023-07-19 01:22:06 +01:00
6294ec448f Merge pull request #2234 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/parser-5.62.0
build(deps-dev): bump @typescript-eslint/parser from 5.60.1 to 5.62.0
2023-07-19 01:21:48 +01:00
668198b5d1 Merge pull request #2228 from dolanmiu/dependabot/npm_and_yarn/vitest-0.33.0
build(deps-dev): bump vitest from 0.32.2 to 0.33.0
2023-07-19 01:21:41 +01:00
56b2ffe706 Merge pull request #2209 from dolanmiu/dependabot/npm_and_yarn/typescript-5.1.6
build(deps-dev): bump typescript from 5.1.3 to 5.1.6
2023-07-19 01:21:35 +01:00
2ab06ffe36 Merge pull request #2244 from dolanmiu/feature/build-fixes
Fix `vite` build issues
2023-07-19 01:19:15 +01:00
0c51082bb9 Add logging output to demo 2023-07-18 21:07:19 +01:00
9a9a2019f6 Do not polyfill buffer 2023-07-18 21:06:35 +01:00
d94348f5ca Export correct type in patchDocument 2023-07-18 20:49:43 +01:00
4c10741862 build(deps-dev): bump @esbuild/win32-x64 from 0.18.10 to 0.18.14
Bumps [@esbuild/win32-x64](https://github.com/evanw/esbuild) from 0.18.10 to 0.18.14.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.18.10...v0.18.14)

---
updated-dependencies:
- dependency-name: "@esbuild/win32-x64"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-18 11:17:06 +00:00
222a25e4e2 Compile umd version as .js format 2023-07-18 01:53:56 +01:00
5fd4490c4f build(deps-dev): bump eslint-plugin-jsdoc from 46.4.2 to 46.4.4
Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 46.4.2 to 46.4.4.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc)
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v46.4.2...v46.4.4)

---
updated-dependencies:
- dependency-name: eslint-plugin-jsdoc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-17 11:58:39 +00:00
e1cc65cb97 build(deps-dev): bump eslint from 8.43.0 to 8.45.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.43.0 to 8.45.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.43.0...v8.45.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-17 11:57:25 +00:00
991f837bc1 build(deps-dev): bump @typescript-eslint/parser from 5.60.1 to 5.62.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.60.1 to 5.62.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.62.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 11:42:13 +00:00
87b3035465 build(deps-dev): bump vitest from 0.32.2 to 0.33.0
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 0.32.2 to 0.33.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.33.0/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-07 11:26:34 +00:00
4498305a6c Remove gitter from README 2023-07-04 12:38:54 +01:00
cac7abba91 build(deps-dev): bump typescript from 5.1.3 to 5.1.6
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.1.3 to 5.1.6.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-30 11:39:27 +00:00
b9b55b2829 Version bump 2023-06-30 01:40:40 +01:00
11365d5be5 Merge pull request #2182 from dolanmiu/dependabot/npm_and_yarn/eslint-8.43.0
build(deps-dev): bump eslint from 8.42.0 to 8.43.0
2023-06-29 17:32:50 +01:00
47a5aff40c build(deps-dev): bump eslint from 8.42.0 to 8.43.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.42.0 to 8.43.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.42.0...v8.43.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-29 16:07:10 +00:00
721fbbac67 Merge pull request #2180 from dolanmiu/dependabot/npm_and_yarn/vitest/ui-0.32.2
build(deps-dev): bump @vitest/ui from 0.32.0 to 0.32.2
2023-06-29 17:05:51 +01:00
bcca50fb40 Merge pull request #2192 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.60.1
build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.59.11 to 5.60.1
2023-06-29 17:05:45 +01:00
229d2eb689 Merge pull request #2179 from dolanmiu/dependabot/npm_and_yarn/vitest/coverage-v8-0.32.2
build(deps-dev): bump @vitest/coverage-v8 from 0.32.0 to 0.32.2
2023-06-29 17:05:39 +01:00
3ef80cc7b3 Merge pull request #2181 from dolanmiu/dependabot/npm_and_yarn/vitest-0.32.2
build(deps-dev): bump vitest from 0.32.0 to 0.32.2
2023-06-29 17:05:32 +01:00
f1f11f36e4 Merge pull request #2193 from dolanmiu/dependabot/npm_and_yarn/types/node-20.3.2
build(deps): bump @types/node from 20.3.1 to 20.3.2
2023-06-29 17:05:24 +01:00
28f187064e Merge pull request #2194 from dolanmiu/dependabot/npm_and_yarn/esbuild/win32-x64-0.18.10
build(deps-dev): bump @esbuild/win32-x64 from 0.18.3 to 0.18.10
2023-06-29 17:05:17 +01:00
c391ca533a Merge pull request #2195 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/parser-5.60.1
build(deps-dev): bump @typescript-eslint/parser from 5.59.11 to 5.60.1
2023-06-29 17:05:07 +01:00
0ca92b80f9 Merge pull request #2200 from dolanmiu/dependabot/npm_and_yarn/glob-10.3.1
build(deps-dev): bump glob from 10.2.7 to 10.3.1
2023-06-29 16:58:27 +01:00
84501b6038 Merge pull request #2206 from dolanmiu/dependabot/npm_and_yarn/eslint-plugin-jsdoc-46.4.2
build(deps-dev): bump eslint-plugin-jsdoc from 46.2.6 to 46.4.2
2023-06-29 16:58:20 +01:00
dcd3e90b19 Merge pull request #2201 from performonkey/master
Fix patch doc add duplicate content type
2023-06-29 15:05:44 +01:00
be7d84dfa0 build(deps-dev): bump eslint-plugin-jsdoc from 46.2.6 to 46.4.2
Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 46.2.6 to 46.4.2.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc)
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v46.2.6...v46.4.2)

---
updated-dependencies:
- dependency-name: eslint-plugin-jsdoc
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-29 11:17:21 +00:00
b0d60109c9 Fix prettier issue 2023-06-29 10:43:44 +08:00
b4659f9901 Merge pull request #2203 from dolanmiu/feature/do-not-override-default-styles
Fix override order in default styles
2023-06-28 23:50:33 +01:00
25f657b842 Add right align example 2023-06-28 22:02:09 +01:00
dfffb066f3 Fix override order in default styles 2023-06-28 21:40:20 +01:00
4f06d760a3 Fix patch doc add duplicate content type 2023-06-28 23:34:16 +08:00
aea2531111 build(deps-dev): bump glob from 10.2.7 to 10.3.1
Bumps [glob](https://github.com/isaacs/node-glob) from 10.2.7 to 10.3.1.
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v10.2.7...v10.3.1)

---
updated-dependencies:
- dependency-name: glob
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-28 11:57:13 +00:00
16707201b4 build(deps-dev): bump @typescript-eslint/parser from 5.59.11 to 5.60.1
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.59.11 to 5.60.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.60.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 11:57:32 +00:00
c7c9652095 build(deps-dev): bump @esbuild/win32-x64 from 0.18.3 to 0.18.10
Bumps [@esbuild/win32-x64](https://github.com/evanw/esbuild) from 0.18.3 to 0.18.10.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.18.3...v0.18.10)

---
updated-dependencies:
- dependency-name: "@esbuild/win32-x64"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 11:57:12 +00:00
05378f58ae build(deps): bump @types/node from 20.3.1 to 20.3.2
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.3.1 to 20.3.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 11:57:01 +00:00
d7549a1140 build(deps-dev): bump @typescript-eslint/eslint-plugin
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.59.11 to 5.60.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.60.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 11:56:43 +00:00
e3ee455186 Merge pull request #2189 from dolanmiu/feature/check-boxes
Feature/check boxes
2023-06-25 03:23:45 +01:00
210d9c58f2 Improve API for check boxes 2023-06-25 03:09:29 +01:00
db85c3dd2f Merge remote-tracking branch 'ric/master' into feature/check-boxes 2023-06-24 20:50:35 +01:00
414d0248f5 Update Checkbox test description 2023-06-23 15:36:08 -04:00
fa400bcf39 update CheckBox and tests to handle optional alias field 2023-06-23 13:06:18 -04:00
9e9ca526fe Prettier syntax update of sdt-properties 2023-06-23 13:05:21 -04:00
41c0fb5fc0 Update sdt-properties to make alias optional 2023-06-23 13:04:28 -04:00
58e7dbf445 Revert "Modify sdt-properties to accommodate for children elements"
This reverts commit f706d8e62d.
2023-06-22 15:39:39 -04:00
20e0213c7d Revert "Revert unnecessary changes to sdt-properties"
This reverts commit d1f75e3a42.
2023-06-22 15:37:00 -04:00
b8f83fd6ad Update CheckBox element and test file according to sdt-properties correction 2023-06-22 15:21:45 -04:00
d1f75e3a42 Revert unnecessary changes to sdt-properties 2023-06-22 15:20:56 -04:00
337ff464cf Modify/create index files to handle exporting 2023-06-22 14:51:10 -04:00
cad4a5510b Create test files for CheckBox and CheckBoxUtil 2023-06-22 14:50:07 -04:00
aa8438d8bd Create CheckBox element and supporting child elements 2023-06-22 14:49:03 -04:00
79363c2c2c Modify Pargraph's children to accept CheckBox 2023-06-22 14:43:10 -04:00
f706d8e62d Modify sdt-properties to accommodate for children elements 2023-06-22 14:42:17 -04:00
e7ee2a0fdf build(deps-dev): bump vitest from 0.32.0 to 0.32.2
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 0.32.0 to 0.32.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.32.2/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-19 11:57:31 +00:00
bd17df8e98 build(deps-dev): bump @vitest/ui from 0.32.0 to 0.32.2
Bumps [@vitest/ui](https://github.com/vitest-dev/vitest/tree/HEAD/packages/ui) from 0.32.0 to 0.32.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.32.2/packages/ui)

---
updated-dependencies:
- dependency-name: "@vitest/ui"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-19 11:57:19 +00:00
e237326319 build(deps-dev): bump @vitest/coverage-v8 from 0.32.0 to 0.32.2
Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 0.32.0 to 0.32.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.32.2/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-v8"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-19 11:56:47 +00:00
23 changed files with 1782 additions and 1180 deletions

View File

@ -12,7 +12,6 @@
[![Downloads per month][downloads-image]][downloads-url]
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
[![Known Vulnerabilities][snky-image]][snky-url]
[![Chat on Gitter][gitter-image]][gitter-url]
[![PRs Welcome][pr-image]][pr-url]
[![codecov][codecov-image]][codecov-url]
@ -107,8 +106,6 @@ Made with 💖
[github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
[snky-url]: https://snyk.io/test/github/dolanmiu/docx
[gitter-image]: https://badges.gitter.im/dolanmiu/docx.svg
[gitter-url]: https://gitter.im/docx-lib/Lobby
[pr-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[pr-url]: http://makeapullrequest.com
[codecov-image]: https://codecov.io/gh/dolanmiu/docx/branch/master/graph/badge.svg

View File

@ -43,6 +43,15 @@ const doc = new Document({
color: "#FF0000",
},
},
document: {
run: {
size: "11pt",
font: "Calibri",
},
paragraph: {
alignment: AlignmentType.RIGHT,
},
},
},
paragraphStyles: [
{

View File

@ -4,6 +4,18 @@ import * as fs from "fs";
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
styles: {
default: {
hyperlink: {
run: {
color: "FF0000",
underline: {
color: "0000FF",
},
},
},
},
},
footnotes: {
1: {
children: [

44
demo/90-check-boxes.ts Normal file
View File

@ -0,0 +1,44 @@
// Simple example to add check boxes to a document
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, CheckBox } from "docx";
const doc = new Document({
sections: [
{
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({ break: 1 }),
new CheckBox(),
new TextRun({ break: 1 }),
new CheckBox({ checked: true }),
new TextRun({ break: 1 }),
new CheckBox({ checked: true, checkedState: { value: "2611" } }),
new TextRun({ break: 1 }),
new CheckBox({ checked: true, checkedState: { value: "2611", font: "MS Gothic" } }),
new TextRun({ break: 1 }),
new CheckBox({
checked: true,
checkedState: { value: "2611", font: "MS Gothic" },
uncheckedState: { value: "2610", font: "MS Gothic" },
}),
new TextRun({ break: 1 }),
new CheckBox({
checked: true,
checkedState: { value: "2611", font: "MS Gothic" },
uncheckedState: { value: "2610", font: "MS Gothic" },
}),
new TextRun({ text: "Are you ok?", break: 1 }),
new CheckBox({ checked: true, alias: "Are you ok?" }),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="../build/index.umd.cjs"></script>
<script src="../build/index.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
</head>

View File

@ -5,9 +5,9 @@ import inquirer from "inquirer";
import { $ } from "execa";
export type Answers = {
type: "list" | "number";
demoNumber?: number;
demoFile?: number;
readonly type: "list" | "number";
readonly demoNumber?: number;
readonly demoFile?: number;
};
const dir = "./demo";
@ -15,8 +15,7 @@ const fileNames = fs.readdirSync(dir);
const keys = fileNames.map((f) => path.parse(f).name);
const getFileNumber = (file: string): number => {
const nameParts = file.split("-");
const firstPart = nameParts[0];
const [firstPart] = file.split("-");
return Number(firstPart);
};
@ -35,15 +34,15 @@ const answers = await inquirer.prompt<Answers>([
name: "demoFile",
message: "What demo do you wish to run?",
choices: demoFiles,
filter: (input) => parseInt(input.split("-")[0]),
when: (answers) => answers.type === "list",
filter: (input) => parseInt(input.split("-")[0], 10),
when: (a) => a.type === "list",
},
{
type: "number",
name: "demoNumber",
message: "What demo do you wish to run? (Enter a number)",
default: 1,
when: (answers) => answers.type === "number",
when: (a) => a.type === "number",
},
]);
@ -56,6 +55,7 @@ if (files.length === 0) {
const filePath = path.join(dir, files[0]);
console.log(`Running demo ${demoNumber}: ${files[0]}`);
await $`ts-node --project demo/tsconfig.json ${filePath}`;
const { stdout } = await $`ts-node --project demo/tsconfig.json ${filePath}`;
console.log(stdout);
console.log("Successfully created document!");
}

2286
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,13 @@
{
"name": "docx",
"version": "8.1.0",
"version": "8.2.2",
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
"type": "module",
"main": "build/index.umd.cjs",
"main": "build/index.umd.js",
"module": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"browser": {
"default": "./build/index.umd.cjs"
},
"require": "./build/index.cjs",
"types": "./build/index.d.ts",
"import": "./build/index.js",
@ -58,7 +55,6 @@
],
"dependencies": {
"@types/node": "^20.3.1",
"fflate": "^0.8.0",
"jszip": "^3.10.1",
"nanoid": "^4.0.2",
"xml": "^1.0.1",
@ -78,8 +74,8 @@
"@types/xml": "^1.0.8",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"@vitest/coverage-v8": "^0.32.0",
"@vitest/ui": "^0.32.0",
"@vitest/coverage-v8": "^0.33.0",
"@vitest/ui": "^0.33.0",
"cspell": "^6.2.2",
"docsify-cli": "^4.3.0",
"eslint": "^8.23.0",
@ -98,13 +94,13 @@
"ts-node": "^10.2.1",
"tsconfig-paths": "^4.0.0",
"typedoc": "^0.24.8",
"typescript": "5.1.3",
"typescript": "5.1.6",
"unzipper": "^0.10.11",
"vite": "^4.3.2",
"vite-plugin-dts": "^2.3.0",
"vite-plugin-dts": "^3.3.1",
"vite-plugin-node-polyfills": "^0.9.0",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.32.0"
"vitest": "^0.33.0"
},
"engines": {
"node": ">=10"

View File

@ -0,0 +1,29 @@
// This represents element type CT_SdtCheckboxSymbol element
// <xsd:complexType name="CT_SdtCheckboxSymbol">
// <xsd:attribute name="font" type="w:ST_String"/>
// <xsd:attribute name="val" type="w:ST_ShortHexNumber"/>
// </xsd:complexType>
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { shortHexNumber } from "@util/values";
class CheckboxSymbolAttributes extends XmlAttributeComponent<{
readonly val?: string | number | boolean;
readonly symbolfont?: string;
}> {
protected readonly xmlKeys = {
val: "w14:val",
symbolfont: "w14:font",
};
}
export class CheckBoxSymbolElement extends XmlComponent {
public constructor(name: string, val: string, font?: string) {
super(name);
if (font) {
this.root.push(new CheckboxSymbolAttributes({ val: shortHexNumber(val), symbolfont: font }));
} else {
this.root.push(new CheckboxSymbolAttributes({ val }));
}
}
}

View File

@ -0,0 +1,85 @@
import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter";
import { CheckBoxUtil } from ".";
describe("CheckBoxUtil", () => {
describe("#constructor()", () => {
it("should create a CheckBoxUtil with proper root and default values", () => {
const checkBoxUtil = new CheckBoxUtil();
const tree = new Formatter().format(checkBoxUtil);
expect(tree).to.deep.equal({
"w14:checkbox": [
{
"w14:checked": {
_attr: {
"w14:val": "0",
},
},
},
{
"w14:checkedState": {
_attr: {
"w14:font": "MS Gothic",
"w14:val": "2612",
},
},
},
{
"w14:uncheckedState": {
_attr: {
"w14:font": "MS Gothic",
"w14:val": "2610",
},
},
},
],
});
});
it("should create a CheckBoxUtil with proper structure and custom values", () => {
const checkBoxUtil = new CheckBoxUtil({
checked: true,
checkedState: {
value: "2713",
font: "Segoe UI Symbol",
},
uncheckedState: {
value: "2705",
font: "Segoe UI Symbol",
},
});
const tree = new Formatter().format(checkBoxUtil);
expect(tree).to.deep.equal({
"w14:checkbox": [
{
"w14:checked": {
_attr: {
"w14:val": "1",
},
},
},
{
"w14:checkedState": {
_attr: {
"w14:font": "Segoe UI Symbol",
"w14:val": "2713",
},
},
},
{
"w14:uncheckedState": {
_attr: {
"w14:font": "Segoe UI Symbol",
"w14:val": "2705",
},
},
},
],
});
});
});
});

View File

@ -0,0 +1,45 @@
// <xsd:complexType name="CT_SdtCheckbox">
// <xsd:sequence>
// <xsd:element name="checked" type="CT_OnOff" minOccurs="0"/>
// <xsd:element name="checkedState" type="CT_SdtCheckboxSymbol" minOccurs="0"/>
// <xsd:element name="uncheckedState" type="CT_SdtCheckboxSymbol" minOccurs="0"/>
// </xsd:sequence>
// </xsd:complexType>
// <xsd:element name="checkbox" type="CT_SdtCheckbox"/>
import { XmlComponent } from "@file/xml-components";
import { CheckBoxSymbolElement } from "@file/checkbox/checkbox-symbol";
export interface ICheckboxSymbolProperties {
readonly value?: string;
readonly font?: string;
}
export interface ICheckboxSymbolOptions {
readonly alias?: string;
readonly checked?: boolean;
readonly checkedState?: ICheckboxSymbolProperties;
readonly uncheckedState?: ICheckboxSymbolProperties;
}
export class CheckBoxUtil extends XmlComponent {
private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610";
private readonly DEFAULT_CHECKED_SYMBOL: string = "2612";
private readonly DEFAULT_FONT: string = "MS Gothic";
public constructor(options?: ICheckboxSymbolOptions) {
super("w14:checkbox");
const value = options?.checked ? "1" : "0";
let symbol: string;
let font: string;
this.root.push(new CheckBoxSymbolElement("w14:checked", value));
symbol = options?.checkedState?.value ? options?.checkedState?.value : this.DEFAULT_CHECKED_SYMBOL;
font = options?.checkedState?.font ? options?.checkedState?.font : this.DEFAULT_FONT;
this.root.push(new CheckBoxSymbolElement("w14:checkedState", symbol, font));
symbol = options?.uncheckedState?.value ? options?.uncheckedState?.value : this.DEFAULT_UNCHECKED_SYMBOL;
font = options?.uncheckedState?.font ? options?.uncheckedState?.font : this.DEFAULT_FONT;
this.root.push(new CheckBoxSymbolElement("w14:uncheckedState", symbol, font));
}
}

View File

@ -0,0 +1,213 @@
import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter";
import { CheckBox } from "./checkbox";
describe("CheckBox", () => {
describe("#constructor()", () => {
it("should create a CheckBox with proper root and default values (no alias, no custom state)", () => {
const checkBox = new CheckBox();
const tree = new Formatter().format(checkBox);
expect(tree).to.deep.equal({
"w:sdt": [
{
"w:sdtPr": [
{
"w14:checkbox": [
{
"w14:checked": {
_attr: {
"w14:val": "0",
},
},
},
{
"w14:checkedState": {
_attr: {
"w14:font": "MS Gothic",
"w14:val": "2612",
},
},
},
{
"w14:uncheckedState": {
_attr: {
"w14:font": "MS Gothic",
"w14:val": "2610",
},
},
},
],
},
],
},
{
"w:sdtContent": [
{
"w:r": [
{
"w:sym": {
_attr: {
"w:char": "2610",
"w:font": "MS Gothic",
},
},
},
],
},
],
},
],
});
});
it.each([
["2713", "Segoe UI Symbol", "2713", "Segoe UI Symbol"],
[undefined, undefined, "2612", "MS Gothic"],
])("should create a CheckBox with proper root and custom values", (inputChar, inputFont, actualChar, actualFont) => {
const checkBox = new CheckBox({
alias: "Custom Checkbox",
checked: true,
checkedState: {
value: inputChar,
font: inputFont,
},
uncheckedState: {
value: "2705",
font: "Segoe UI Symbol",
},
});
const tree = new Formatter().format(checkBox);
expect(tree).to.deep.equal({
"w:sdt": [
{
"w:sdtPr": [
{
"w:alias": {
_attr: {
"w:val": "Custom Checkbox",
},
},
},
{
"w14:checkbox": [
{
"w14:checked": {
_attr: {
"w14:val": "1",
},
},
},
{
"w14:checkedState": {
_attr: {
"w14:font": actualFont,
"w14:val": actualChar,
},
},
},
{
"w14:uncheckedState": {
_attr: {
"w14:font": "Segoe UI Symbol",
"w14:val": "2705",
},
},
},
],
},
],
},
{
"w:sdtContent": [
{
"w:r": [
{
"w:sym": {
_attr: {
"w:char": actualChar,
"w:font": actualFont,
},
},
},
],
},
],
},
],
});
});
it("should create a CheckBox with proper root, custom state, and no alias", () => {
const checkBox = new CheckBox({
checked: false,
checkedState: {
value: "2713",
font: "Segoe UI Symbol",
},
uncheckedState: {
value: "2705",
font: "Segoe UI Symbol",
},
});
const tree = new Formatter().format(checkBox);
expect(tree).to.deep.equal({
"w:sdt": [
{
"w:sdtPr": [
{
"w14:checkbox": [
{
"w14:checked": {
_attr: {
"w14:val": "0",
},
},
},
{
"w14:checkedState": {
_attr: {
"w14:font": "Segoe UI Symbol",
"w14:val": "2713",
},
},
},
{
"w14:uncheckedState": {
_attr: {
"w14:font": "Segoe UI Symbol",
"w14:val": "2705",
},
},
},
],
},
],
},
{
"w:sdtContent": [
{
"w:r": [
{
"w:sym": {
_attr: {
"w:char": "2705",
"w:font": "Segoe UI Symbol",
},
},
},
],
},
],
},
],
});
});
});
});

View File

@ -0,0 +1,43 @@
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 { XmlComponent } from "@file/xml-components";
import { CheckBoxUtil, ICheckboxSymbolOptions } from "./checkbox-util";
export class CheckBox extends XmlComponent {
// default values per Microsoft
private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610";
private readonly DEFAULT_CHECKED_SYMBOL: string = "2612";
private readonly DEFAULT_FONT: string = "MS Gothic";
public constructor(options?: ICheckboxSymbolOptions) {
super("w:sdt");
const properties = new StructuredDocumentTagProperties(options?.alias);
properties.addChildElement(new CheckBoxUtil(options));
this.root.push(properties);
const content = new StructuredDocumentTagContent();
const checkedFont: string | undefined = options?.checkedState?.font;
const checkedText: string | undefined = options?.checkedState?.value;
const uncheckedFont: string | undefined = options?.uncheckedState?.font;
const uncheckedText: string | undefined = options?.uncheckedState?.value;
let symbolFont: string;
let char: string;
if (options?.checked) {
symbolFont = checkedFont ? checkedFont : this.DEFAULT_FONT;
char = checkedText ? checkedText : this.DEFAULT_CHECKED_SYMBOL;
} else {
symbolFont = uncheckedFont ? uncheckedFont : this.DEFAULT_FONT;
char = uncheckedText ? uncheckedText : this.DEFAULT_UNCHECKED_SYMBOL;
}
const initialRenderedChar = new SymbolRun({
char: char,
symbolfont: symbolFont,
});
content.addChildElement(initialRenderedChar);
this.root.push(content);
}
}

View File

@ -0,0 +1,3 @@
export * from "./checkbox-util";
export * from "./checkbox-symbol";
export * from "./checkbox";

View File

@ -17,3 +17,4 @@ export * from "./track-revision";
export * from "./shared";
export * from "./border";
export * from "./vertical-align";
export * from "./checkbox";

View File

@ -6,6 +6,7 @@ import { FileChild } from "@file/file-child";
import { TargetModeType } from "../relationships/relationship/relationship";
import { DeletedTextRun, InsertedTextRun } from "../track-revision";
import { CheckBox } from "../checkbox";
import { ColumnBreak, PageBreak } from "./formatting/break";
import { Bookmark, ConcreteHyperlink, ExternalHyperlink, InternalHyperlink } from "./links";
import { Math } from "./math";
@ -33,7 +34,8 @@ export type ParagraphChild =
| Comment
| CommentRangeStart
| CommentRangeEnd
| CommentReference;
| CommentReference
| CheckBox;
export interface IParagraphOptions extends IParagraphPropertiesOptions {
readonly text?: string;

View File

@ -318,4 +318,45 @@ describe("Default Styles", () => {
],
});
});
it("HyperlinkStyle#constructor", () => {
const style = new defaultStyles.HyperlinkStyle({
run: {
color: "FF0000",
underline: {
color: "0000FF",
},
},
});
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
{ _attr: { "w:type": "character", "w:styleId": "Hyperlink" } },
{ "w:name": { _attr: { "w:val": "Hyperlink" } } },
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
{
"w:uiPriority": {
_attr: {
"w:val": 99,
},
},
},
{
"w:unhideWhenUsed": EMPTY_OBJECT,
},
{
"w:rPr": [
{ "w:u": { _attr: { "w:color": "0000FF", "w:val": "single" } } },
{
"w:color": {
_attr: {
"w:val": "FF0000",
},
},
},
],
},
],
});
});
});

View File

@ -8,10 +8,10 @@ import { IBaseParagraphStyleOptions, IParagraphStyleOptions, StyleForParagraph }
export class HeadingStyle extends StyleForParagraph {
public constructor(options: IParagraphStyleOptions) {
super({
...options,
basedOn: "Normal",
next: "Normal",
quickFormat: true,
...options,
});
}
}
@ -19,9 +19,9 @@ export class HeadingStyle extends StyleForParagraph {
export class TitleStyle extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Title",
name: "Title",
...options,
});
}
}
@ -29,9 +29,9 @@ export class TitleStyle extends HeadingStyle {
export class Heading1Style extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Heading1",
name: "Heading 1",
...options,
});
}
}
@ -39,9 +39,9 @@ export class Heading1Style extends HeadingStyle {
export class Heading2Style extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Heading2",
name: "Heading 2",
...options,
});
}
}
@ -49,9 +49,9 @@ export class Heading2Style extends HeadingStyle {
export class Heading3Style extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Heading3",
name: "Heading 3",
...options,
});
}
}
@ -59,9 +59,9 @@ export class Heading3Style extends HeadingStyle {
export class Heading4Style extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Heading4",
name: "Heading 4",
...options,
});
}
}
@ -69,9 +69,9 @@ export class Heading4Style extends HeadingStyle {
export class Heading5Style extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Heading5",
name: "Heading 5",
...options,
});
}
}
@ -79,9 +79,9 @@ export class Heading5Style extends HeadingStyle {
export class Heading6Style extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Heading6",
name: "Heading 6",
...options,
});
}
}
@ -89,9 +89,9 @@ export class Heading6Style extends HeadingStyle {
export class StrongStyle extends HeadingStyle {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "Strong",
name: "Strong",
...options,
});
}
}
@ -99,11 +99,11 @@ export class StrongStyle extends HeadingStyle {
export class ListParagraph extends StyleForParagraph {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "ListParagraph",
name: "List Paragraph",
basedOn: "Normal",
quickFormat: true,
...options,
});
}
}
@ -111,7 +111,6 @@ export class ListParagraph extends StyleForParagraph {
export class FootnoteText extends StyleForParagraph {
public constructor(options: IBaseParagraphStyleOptions) {
super({
...options,
id: "FootnoteText",
name: "footnote text",
link: "FootnoteTextChar",
@ -129,6 +128,7 @@ export class FootnoteText extends StyleForParagraph {
run: {
size: 20,
},
...options,
});
}
}
@ -136,7 +136,6 @@ export class FootnoteText extends StyleForParagraph {
export class FootnoteReferenceStyle extends StyleForCharacter {
public constructor(options: IBaseCharacterStyleOptions) {
super({
...options,
id: "FootnoteReference",
name: "footnote reference",
basedOn: "DefaultParagraphFont",
@ -144,6 +143,7 @@ export class FootnoteReferenceStyle extends StyleForCharacter {
run: {
superScript: true,
},
...options,
});
}
}
@ -151,7 +151,6 @@ export class FootnoteReferenceStyle extends StyleForCharacter {
export class FootnoteTextChar extends StyleForCharacter {
public constructor(options: IBaseCharacterStyleOptions) {
super({
...options,
id: "FootnoteTextChar",
name: "Footnote Text Char",
basedOn: "DefaultParagraphFont",
@ -160,6 +159,7 @@ export class FootnoteTextChar extends StyleForCharacter {
run: {
size: 20,
},
...options,
});
}
}
@ -167,7 +167,6 @@ export class FootnoteTextChar extends StyleForCharacter {
export class HyperlinkStyle extends StyleForCharacter {
public constructor(options: IBaseCharacterStyleOptions) {
super({
...options,
id: "Hyperlink",
name: "Hyperlink",
basedOn: "DefaultParagraphFont",
@ -177,6 +176,7 @@ export class HyperlinkStyle extends StyleForCharacter {
type: UnderlineType.SINGLE,
},
},
...options,
});
}
}

View File

@ -2,8 +2,11 @@
import { StringValueElement, XmlComponent } from "@file/xml-components";
export class StructuredDocumentTagProperties extends XmlComponent {
public constructor(alias: string) {
public constructor(alias?: string) {
super("w:sdtPr");
this.root.push(new StringValueElement("w:alias", alias));
if (alias) {
this.root.push(new StringValueElement("w:alias", alias));
}
}
}

View File

@ -47,5 +47,31 @@ describe("content-types-manager", () => {
type: "element",
});
});
it("should not append duplicate content type", () => {
const element = {
type: "element",
name: "xml",
elements: [
{
type: "element",
name: "Types",
elements: [
{
type: "element",
name: "Default",
attributes: {
ContentType: "image/png",
Extension: "png",
},
},
],
},
],
};
appendContentType(element, "image/png", "png");
expect(element.elements.length).toBe(1);
});
});
});

View File

@ -4,6 +4,18 @@ import { getFirstLevelElements } from "./util";
export const appendContentType = (element: Element, contentType: string, extension: string): void => {
const relationshipElements = getFirstLevelElements(element, "Types");
const exist = relationshipElements.some(
(el) =>
el.type === "element" &&
el.name === "Default" &&
el?.attributes?.ContentType === contentType &&
el?.attributes?.Extension === extension,
);
if (exist) {
return;
}
// eslint-disable-next-line functional/immutable-data
relationshipElements.push({
attributes: {

View File

@ -53,7 +53,7 @@ export interface PatchDocumentOptions {
const imageReplacer = new ImageReplacer();
export const patchDocument = async (data: InputDataType, options: PatchDocumentOptions): Promise<Buffer> => {
export const patchDocument = async (data: InputDataType, options: PatchDocumentOptions): Promise<Uint8Array> => {
const zipContent = await JSZip.loadAsync(data);
const contexts = new Map<string, IContext>();
const file = {
@ -68,11 +68,11 @@ export const patchDocument = async (data: InputDataType, options: PatchDocumentO
const hyperlinkRelationshipAdditions: IHyperlinkRelationshipAddition[] = [];
let hasMedia = false;
const binaryContentMap = new Map<string, Buffer>();
const binaryContentMap = new Map<string, Uint8Array>();
for (const [key, value] of Object.entries(zipContent.files)) {
if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
binaryContentMap.set(key, await value.async("nodebuffer"));
binaryContentMap.set(key, await value.async("uint8array"));
continue;
}
@ -213,7 +213,7 @@ export const patchDocument = async (data: InputDataType, options: PatchDocumentO
}
return zip.generateAsync({
type: "nodebuffer",
type: "uint8array",
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
compression: "DEFLATE",
});

View File

@ -9,7 +9,10 @@ export default defineConfig({
tsconfigPaths(),
dts(),
nodePolyfills({
exclude: ["fs"],
exclude: [],
globals: {
Buffer: false,
},
protocolImports: true,
}),
],
@ -26,7 +29,25 @@ export default defineConfig({
lib: {
entry: [resolve(__dirname, "src/index.ts")],
name: "docx",
fileName: "index",
fileName: (d) => {
if (d === "umd") {
return "index.umd.js";
}
if (d === "cjs") {
return "index.cjs";
}
if (d === "es") {
return "index.js";
}
if (d === "iife") {
return "index.iife.js";
}
return "unknown";
},
formats: ["iife", "es", "cjs", "umd"],
},
outDir: resolve(__dirname, "build"),