Compare commits

..

68 Commits
8.0.0 ... 8.0.2

Author SHA1 Message Date
accb1d44d0 Version bump 2023-04-05 02:03:30 +01:00
b61f798cd9 Merge pull request #2059 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/parser-5.57.1
build(deps-dev): bump @typescript-eslint/parser from 5.56.0 to 5.57.1
2023-04-04 22:43:40 +01:00
be2ec9d4cf Merge pull request #2058 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.57.1
build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.56.0 to 5.57.1
2023-04-04 22:43:34 +01:00
514fbb1c09 Merge pull request #2054 from dolanmiu/dependabot/npm_and_yarn/typescript-5.0.3
build(deps-dev): bump typescript from 5.0.2 to 5.0.3
2023-04-04 22:43:25 +01:00
8ce397f61e Merge pull request #2052 from dolanmiu/dependabot/npm_and_yarn/tsconfig-paths-4.2.0
build(deps-dev): bump tsconfig-paths from 4.1.2 to 4.2.0
2023-04-04 22:43:19 +01:00
3b0dfb8489 Merge pull request #2049 from dolanmiu/dependabot/npm_and_yarn/types/node-18.15.11
build(deps): bump @types/node from 18.15.7 to 18.15.11
2023-04-04 22:43:09 +01:00
f4933deaf2 Merge pull request #2048 from dolanmiu/dependabot/npm_and_yarn/eslint-8.37.0
build(deps-dev): bump eslint from 8.36.0 to 8.37.0
2023-04-04 22:42:59 +01:00
add2273551 Merge pull request #2045 from dolanmiu/dependabot/npm_and_yarn/types/webpack-5.28.1
build(deps-dev): bump @types/webpack from 5.28.0 to 5.28.1
2023-04-04 22:42:52 +01:00
91b00466a0 Merge pull request #2040 from dolanmiu/dependabot/npm_and_yarn/sinon-15.0.3
build(deps-dev): bump sinon from 15.0.2 to 15.0.3
2023-04-04 22:42:45 +01:00
d0612e115e Merge pull request #2038 from dolanmiu/dependabot/npm_and_yarn/cspell-6.31.1
build(deps-dev): bump cspell from 6.30.2 to 6.31.1
2023-04-04 22:42:37 +01:00
e4a6cbe887 Merge pull request #2053 from dolanmiu/feat/fix-templating
#2028 - Null check
2023-04-04 22:38:16 +01:00
0386810714 Write tests and simplify logic 2023-04-04 22:21:01 +01:00
d4585f60b3 build(deps-dev): bump @typescript-eslint/parser from 5.56.0 to 5.57.1
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.56.0 to 5.57.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.57.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-04-04 11:57:39 +00:00
18f015a959 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.56.0 to 5.57.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.57.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-04-04 11:56:55 +00:00
10c866bdea Add tests 2023-03-31 17:16:05 +01:00
680c938dcf build(deps-dev): bump typescript from 5.0.2 to 5.0.3
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.0.2 to 5.0.3.
- [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-03-31 11:57:07 +00:00
c3a617fefd #2028 - Null check 2023-03-31 00:13:36 +01:00
6362b498a6 Add docsify sign off sheet 2023-03-30 20:14:08 +01:00
2e30ab29be Update cspell json 2023-03-30 19:59:23 +01:00
44568023cd Add documentation to basedOn 2023-03-30 19:54:33 +01:00
c57aaa856d Update comments demo 2023-03-30 19:43:09 +01:00
0f4f24c3f3 build(deps-dev): bump tsconfig-paths from 4.1.2 to 4.2.0
Bumps [tsconfig-paths](https://github.com/dividab/tsconfig-paths) from 4.1.2 to 4.2.0.
- [Release notes](https://github.com/dividab/tsconfig-paths/releases)
- [Changelog](https://github.com/dividab/tsconfig-paths/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dividab/tsconfig-paths/compare/v4.1.2...v4.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-30 11:56:49 +00:00
2fe7a2e3d3 build(deps): bump @types/node from 18.15.7 to 18.15.11
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.15.7 to 18.15.11.
- [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-03-29 11:57:27 +00:00
20b62f5768 build(deps-dev): bump eslint from 8.36.0 to 8.37.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.36.0 to 8.37.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.36.0...v8.37.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-03-29 11:56:56 +00:00
ab063eee08 Add helper function patchDocument example 2023-03-28 20:16:34 +01:00
66c7624b40 build(deps-dev): bump @types/webpack from 5.28.0 to 5.28.1
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 5.28.0 to 5.28.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-28 11:58:06 +00:00
bfc302023f build(deps-dev): bump sinon from 15.0.2 to 15.0.3
Bumps [sinon](https://github.com/sinonjs/sinon) from 15.0.2 to 15.0.3.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/main/docs/changelog.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v15.0.2...v15.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-27 11:57:32 +00:00
3505912f74 build(deps-dev): bump cspell from 6.30.2 to 6.31.1
Bumps [cspell](https://github.com/streetsidesoftware/cspell) from 6.30.2 to 6.31.1.
- [Release notes](https://github.com/streetsidesoftware/cspell/releases)
- [Changelog](https://github.com/streetsidesoftware/cspell/blob/main/CHANGELOG.md)
- [Commits](https://github.com/streetsidesoftware/cspell/compare/v6.30.2...v6.31.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-27 11:57:03 +00:00
ec379f2e4d Update documentation 2023-03-26 04:05:41 +01:00
2d17954104 Merge pull request #2034 from dolanmiu/dependabot/npm_and_yarn/types/node-18.15.7
build(deps): bump @types/node from 18.15.5 to 18.15.7
2023-03-24 15:11:58 +00:00
01c834b16b Merge pull request #2035 from dolanmiu/dependabot/npm_and_yarn/prettier-2.8.7
build(deps-dev): bump prettier from 2.8.6 to 2.8.7
2023-03-24 15:11:52 +00:00
2aeb2c2e88 Merge pull request #2036 from dolanmiu/dependabot/npm_and_yarn/webpack-5.76.3
build(deps-dev): bump webpack from 5.76.2 to 5.76.3
2023-03-24 15:11:45 +00:00
be88086434 build(deps-dev): bump webpack from 5.76.2 to 5.76.3
Bumps [webpack](https://github.com/webpack/webpack) from 5.76.2 to 5.76.3.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.76.2...v5.76.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 11:57:59 +00:00
28f0cc681d build(deps-dev): bump prettier from 2.8.6 to 2.8.7
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.6 to 2.8.7.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.6...2.8.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 11:57:30 +00:00
def29c535b build(deps): bump @types/node from 18.15.5 to 18.15.7
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.15.5 to 18.15.7.
- [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-03-24 11:57:04 +00:00
168e5e6e11 Version bump 2023-03-23 23:20:14 +00:00
ce71f19826 Merge pull request #2030 from dolanmiu/dependabot/npm_and_yarn/rimraf-4.4.1
build(deps-dev): bump rimraf from 4.4.0 to 4.4.1
2023-03-23 23:17:58 +00:00
4fd3f3a6b8 Merge pull request #2019 from dolanmiu/dependabot/npm_and_yarn/cspell-6.30.2
build(deps-dev): bump cspell from 6.30.0 to 6.30.2
2023-03-23 23:17:46 +00:00
39763d3869 Merge pull request #2023 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/parser-5.56.0
build(deps-dev): bump @typescript-eslint/parser from 5.55.0 to 5.56.0
2023-03-23 23:17:35 +00:00
36f90edc67 Merge pull request #2021 from dolanmiu/dependabot/npm_and_yarn/types/node-18.15.5
build(deps): bump @types/node from 18.15.3 to 18.15.5
2023-03-23 23:17:27 +00:00
b0cbd6f609 Merge pull request #2017 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.23.28
build(deps-dev): bump typedoc from 0.23.27 to 0.23.28
2023-03-23 23:17:18 +00:00
d23d4a4557 Merge pull request #2020 from dolanmiu/dependabot/npm_and_yarn/prettier-2.8.6
build(deps-dev): bump prettier from 2.8.4 to 2.8.6
2023-03-23 23:16:58 +00:00
07c58ee43c Merge pull request #2022 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.56.0
build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.55.0 to 5.56.0
2023-03-23 23:16:46 +00:00
1037e8f1b9 Merge pull request #2025 from dolanmiu/dependabot/npm_and_yarn/eslint-plugin-functional-5.0.7
build(deps-dev): bump eslint-plugin-functional from 5.0.6 to 5.0.7
2023-03-23 23:16:39 +00:00
f0ae8396f7 Merge pull request #2031 from dolanmiu/dependabot/npm_and_yarn/glob-9.3.2
build(deps-dev): bump glob from 9.3.0 to 9.3.2
2023-03-23 23:16:31 +00:00
1ae5995f9c Merge pull request #2033 from dolanmiu/feat/remove-redundant-keys
Remove unused type keys
2023-03-23 23:14:59 +00:00
751ad9d304 Remove unused type keys 2023-03-23 22:59:34 +00:00
0bd1514826 Merge pull request #2032 from dolanmiu/feat/fix-patcher-issue
#2028 Fix patcher offset indexes
2023-03-23 22:52:34 +00:00
16bfc78d8d #2028 Fix patcher offset indexes 2023-03-23 21:01:24 +00:00
528008406a Merge pull request #2016 from ewoutkleinsmann/master
Images in templates
2023-03-23 19:08:54 +00:00
9e3010ac6a Reduce coverage temporarily 2023-03-23 19:02:22 +00:00
7c1fa6f4bf build(deps-dev): bump glob from 9.3.0 to 9.3.2
Bumps [glob](https://github.com/isaacs/node-glob) from 9.3.0 to 9.3.2.
- [Release notes](https://github.com/isaacs/node-glob/releases)
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v9.3.0...v9.3.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-23 11:57:04 +00:00
f58d31cc3d build(deps-dev): bump rimraf from 4.4.0 to 4.4.1
Bumps [rimraf](https://github.com/isaacs/rimraf) from 4.4.0 to 4.4.1.
- [Release notes](https://github.com/isaacs/rimraf/releases)
- [Changelog](https://github.com/isaacs/rimraf/blob/main/CHANGELOG.md)
- [Commits](https://github.com/isaacs/rimraf/compare/v4.4.0...v4.4.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-23 11:56:45 +00:00
286c742ece build(deps-dev): bump eslint-plugin-functional from 5.0.6 to 5.0.7
Bumps [eslint-plugin-functional](https://github.com/eslint-functional/eslint-plugin-functional) from 5.0.6 to 5.0.7.
- [Release notes](https://github.com/eslint-functional/eslint-plugin-functional/releases)
- [Changelog](https://github.com/eslint-functional/eslint-plugin-functional/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint-functional/eslint-plugin-functional/compare/v5.0.6...v5.0.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-21 11:58:57 +00:00
3edc51d5a0 build(deps-dev): bump @typescript-eslint/parser from 5.55.0 to 5.56.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.55.0 to 5.56.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.56.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-03-21 11:58:10 +00:00
05d4c9688e 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.55.0 to 5.56.0.
- [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.56.0/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-03-21 11:57:39 +00:00
d4401d1597 build(deps): bump @types/node from 18.15.3 to 18.15.5
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.15.3 to 18.15.5.
- [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-03-21 11:57:03 +00:00
90358e73f6 build(deps-dev): bump prettier from 2.8.4 to 2.8.6
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.4 to 2.8.6.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.4...2.8.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-21 11:56:43 +00:00
a77ca02ea9 Set homepage to docx.js.org 2023-03-21 04:31:21 +00:00
7785f0df02 Add some tests to boost coverage 2023-03-21 04:30:20 +00:00
0e6ed6e5ea build(deps-dev): bump cspell from 6.30.0 to 6.30.2
Bumps [cspell](https://github.com/streetsidesoftware/cspell) from 6.30.0 to 6.30.2.
- [Release notes](https://github.com/streetsidesoftware/cspell/releases)
- [Changelog](https://github.com/streetsidesoftware/cspell/blob/main/CHANGELOG.md)
- [Commits](https://github.com/streetsidesoftware/cspell/compare/v6.30.0...v6.30.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 11:57:45 +00:00
70e84c8d38 build(deps-dev): bump typedoc from 0.23.27 to 0.23.28
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.23.27 to 0.23.28.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Changelog](https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.23.27...v0.23.28)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 11:56:49 +00:00
11c3886659 Merge branch 'dolanmiu:master' into master 2023-03-20 12:08:28 +01:00
6104e5bc35 Update shelljs definitions 2023-03-19 19:46:06 +00:00
c748b9a7fc Remove src and template from files 2023-03-19 19:42:40 +00:00
714dbc0179 Add horizontal rule to border example 2023-03-19 15:47:45 +00:00
7f16cfc359 Remove unessesary glob types and fix typedocs 2023-03-19 04:22:52 +00:00
71953cf45a Fixes patchDocument for files with binary content 2023-03-17 16:30:35 +01:00
25 changed files with 975 additions and 517 deletions

View File

@ -4,34 +4,40 @@
"version": "0.2", "version": "0.2",
// language - current active spelling language // language - current active spelling language
"language": "en_US", "language": "en_US",
"dictionaries": ["en_US", "typescript", "softwareTerms", "fonts", "npm"], "dictionaries": [
"en_US",
"typescript",
"softwareTerms",
"fonts",
"npm"
],
// words - list of words to be always considered correct // words - list of words to be always considered correct
"words": [ "words": [
"Xmlable", "Abjad",
"aiueo",
"ATLEAST",
"chosung",
"clippy",
"datas",
"docsify",
"dolan",
"falsey",
"Initializable",
"iroha",
"jsonify",
"jszip",
"NUMPAGES",
"odttf",
"ooxml",
"panose",
"rels",
"rsid",
"twip", "twip",
"twips", "twips",
"jsonify", "Xmlable",
"falsey",
"aiueo",
"iroha",
"aiueo",
"iroha",
"chosung",
"Abjad",
"Initializable",
"rels",
"dolan",
"xmlify",
"Xmlifyed",
"xmlified", "xmlified",
"datas", "xmlify",
"jszip", "Xmlifyed"
"rsid",
"NUMPAGES",
"ATLEAST",
"ooxml",
"clippy",
"docsify"
], ],
"ignoreRegExpList": [ "ignoreRegExpList": [
"/\"w:.+\"/", "/\"w:.+\"/",
@ -51,10 +57,15 @@
"/<element name=\"[a-z]+\"/gi", "/<element name=\"[a-z]+\"/gi",
"/<attribute name=\"[a-z]+\"/gi" "/<attribute name=\"[a-z]+\"/gi"
], ],
"ignorePaths": ["package.json", "docs/api"], "ignorePaths": [
"package.json",
"docs/api"
],
"allowCompoundWords": true, "allowCompoundWords": true,
// flagWords - list of words to be always considered incorrect // flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors. // This is useful for offensive words and common spelling errors.
// For example "hte" should be "the" // For example "hte" should be "the"
"flagWords": ["hte"] "flagWords": [
"hte"
]
} }

2
.nycrc
View File

@ -1,7 +1,7 @@
{ {
"check-coverage": true, "check-coverage": true,
"statements": 99.87, "statements": 99.87,
"branches": 98.29, "branches": 98.21,
"functions": 100, "functions": 100,
"lines": 99.86, "lines": 99.86,
"include": [ "include": [

View File

@ -25,6 +25,17 @@ const doc = new Document({
}, },
}, },
}), }),
new Paragraph({
text: "",
border: {
top: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
},
}),
new Paragraph({ new Paragraph({
children: [ children: [
new TextRun({ new TextRun({

View File

@ -32,6 +32,55 @@ const doc = new Document({
}), }),
], ],
}, },
{
id: 1,
author: "Bob Ross",
date: new Date(),
children: [
new Paragraph({
children: [
new TextRun({
text: "Some initial text content",
}),
],
}),
new Paragraph({
children: [
new TextRun({
text: "comment text content",
}),
],
}),
],
},
{
id: 2,
author: "John Doe",
date: new Date(),
children: [
new Paragraph({
children: [
new TextRun({
text: "Hello World",
}),
],
}),
],
},
{
id: 3,
author: "Beatriz",
date: new Date(),
children: [
new Paragraph({
children: [
new TextRun({
text: "Another reply",
}),
],
}),
],
},
], ],
}, },
sections: [ sections: [
@ -53,6 +102,32 @@ const doc = new Document({
}), }),
], ],
}), }),
new Paragraph({
children: [
new CommentRangeStart(1),
new CommentRangeStart(2),
new CommentRangeStart(3),
new TextRun({
text: "Some text which need commenting",
bold: true,
}),
new CommentRangeEnd(1),
new TextRun({
children: [new CommentReference(1)],
bold: true,
}),
new CommentRangeEnd(2),
new TextRun({
children: [new CommentReference(2)],
bold: true,
}),
new CommentRangeEnd(3),
new TextRun({
children: [new CommentReference(3)],
bold: true,
}),
],
}),
], ],
}, },
], ],

View File

@ -0,0 +1,15 @@
// Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { patchDocument, PatchType, TextRun } from "../build";
patchDocument(fs.readFileSync("demo/assets/simple-template-2.docx"), {
patches: {
name: {
type: PatchType.PARAGRAPH,
children: [new TextRun("Max")],
},
},
}).then((doc) => {
fs.writeFileSync("My Document.docx", doc);
});

View File

@ -0,0 +1,31 @@
// Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { IPatch, patchDocument, PatchType, TextRun } from "../build";
export const font = "Trebuchet MS";
export const getPatches = (fields: { [key: string]: string }) => {
const patches: { [key: string]: IPatch } = {};
for (const field in fields) {
patches[field] = {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: fields[field], font })],
};
}
return patches;
};
const patches = getPatches({
name: "Mr",
table_heading_1: "John",
item_1: "Doe",
paragraph_replace: "Lorem ipsum paragraph",
});
patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
patches,
}).then((doc) => {
fs.writeFileSync("My Document.docx", doc);
});

View File

@ -0,0 +1,29 @@
// Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { IPatch, patchDocument, PatchType, TextRun } from "../build";
export const font = "Trebuchet MS";
export const getPatches = (fields: { [key: string]: string }) => {
const patches: { [key: string]: IPatch } = {};
for (const field in fields) {
patches[field] = {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: fields[field], font })],
};
}
return patches;
};
const patches = getPatches({
salutation: "Mr.",
"first-name": "John",
});
patchDocument(fs.readFileSync("demo/assets/simple-template-3.docx"), {
patches,
}).then((doc) => {
fs.writeFileSync("My Document.docx", doc);
});

Binary file not shown.

Binary file not shown.

View File

@ -38,6 +38,7 @@
<script src="https://unpkg.com/docsify-copy-code@2"></script> <script src="https://unpkg.com/docsify-copy-code@2"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script> <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-typescript.min.js"></script> <script src="//unpkg.com/prismjs/components/prism-typescript.min.js"></script>
<script src="https://unpkg.com/docsify-sign-off-sheet@1.0.0/dist/index.iife.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js" type="text/javascript"></script> <script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js" type="text/javascript"></script>
</body> </body>
</html> </html>

View File

@ -305,4 +305,12 @@ Example: https://github.com/dolanmiu/docx/blob/master/demo/15-page-break-before.
## Page break control ## Page break control
Paragraphs have `.keepLines()` and `.keepNext()` methods that allow restricting page breaks within and between paragraphs. See [this Microsoft article](https://support.office.com/en-us/article/Keep-lines-and-paragraphs-together-d72af534-926f-4c4b-830a-abfc2daa3bfa) for more details) Paragraphs have `keepLines` and `keepNext` properties that allow restricting page breaks within and between paragraphs. See [this Microsoft article](https://support.office.com/en-us/article/Keep-lines-and-paragraphs-together-d72af534-926f-4c4b-830a-abfc2daa3bfa) for more details.
```ts
const paragraph = new Paragraph({
text: "Stay on the same page",
keepLines: true,
keepNext: true,
});
```

935
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "docx", "name": "docx",
"version": "8.0.0", "version": "8.0.2",
"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.",
"main": "build/index.js", "main": "build/index.js",
"scripts": { "scripts": {
@ -28,9 +28,7 @@
"lint" "lint"
], ],
"files": [ "files": [
"src", "build"
"build",
"template"
], ],
"repository": { "repository": {
"type": "git", "type": "git",
@ -61,15 +59,14 @@
"bugs": { "bugs": {
"url": "https://github.com/dolanmiu/docx/issues" "url": "https://github.com/dolanmiu/docx/issues"
}, },
"homepage": "https://github.com/dolanmiu/docx#readme", "homepage": "https://docx.js.org",
"devDependencies": { "devDependencies": {
"@types/chai": "^4.2.15", "@types/chai": "^4.2.15",
"@types/chai-as-promised": "^7.1.5", "@types/chai-as-promised": "^7.1.5",
"@types/glob": "^8.0.0",
"@types/mocha": "^10.0.0", "@types/mocha": "^10.0.0",
"@types/prompt": "^1.1.1", "@types/prompt": "^1.1.1",
"@types/request-promise": "^4.1.42", "@types/request-promise": "^4.1.42",
"@types/shelljs": "^0.8.9", "@types/shelljs": "^0.8.11",
"@types/sinon": "^10.0.0", "@types/sinon": "^10.0.0",
"@types/unzipper": "^0.10.4", "@types/unzipper": "^0.10.4",
"@types/webpack": "^5.0.0", "@types/webpack": "^5.0.0",
@ -107,7 +104,7 @@
"tsconfig-paths": "^4.0.0", "tsconfig-paths": "^4.0.0",
"tsconfig-paths-webpack-plugin": "^4.0.0", "tsconfig-paths-webpack-plugin": "^4.0.0",
"typedoc": "^0.23.2", "typedoc": "^0.23.2",
"typescript": "5.0.2", "typescript": "5.0.3",
"unzipper": "^0.10.11", "unzipper": "^0.10.11",
"webpack": "^5.28.0", "webpack": "^5.28.0",
"webpack-cli": "^5.0.0" "webpack-cli": "^5.0.0"

View File

@ -23,7 +23,13 @@ export interface ILevelParagraphStylePropertiesOptions {
readonly leftTabStop?: number; readonly leftTabStop?: number;
readonly indent?: IIndentAttributesProperties; readonly indent?: IIndentAttributesProperties;
readonly spacing?: ISpacingProperties; readonly spacing?: ISpacingProperties;
/**
* Specifies that the paragraph (or at least part of it) should be rendered on the same page as the next paragraph when possible. If multiple paragraphs are to be kept together but they exceed a page, then the set of paragraphs begin on a new page and page breaks are used thereafter as needed.
*/
readonly keepNext?: boolean; readonly keepNext?: boolean;
/**
* Specifies that all lines of the paragraph are to be kept on a single page when possible.
*/
readonly keepLines?: boolean; readonly keepLines?: boolean;
readonly outlineLevel?: number; readonly outlineLevel?: number;
} }

View File

@ -8,7 +8,6 @@ export interface IBaseCharacterStyleOptions extends IStyleOptions {
export interface ICharacterStyleOptions extends IBaseCharacterStyleOptions { export interface ICharacterStyleOptions extends IBaseCharacterStyleOptions {
readonly id: string; readonly id: string;
readonly name?: string;
} }
export class StyleForCharacter extends Style { export class StyleForCharacter extends Style {

View File

@ -9,7 +9,6 @@ export interface IBaseParagraphStyleOptions extends IStyleOptions {
export interface IParagraphStyleOptions extends IBaseParagraphStyleOptions { export interface IParagraphStyleOptions extends IBaseParagraphStyleOptions {
readonly id: string; readonly id: string;
readonly name?: string;
} }
export class StyleForParagraph extends Style { export class StyleForParagraph extends Style {

View File

@ -41,6 +41,13 @@ export interface IStyleAttributes {
export interface IStyleOptions { export interface IStyleOptions {
readonly name?: string; readonly name?: string;
/**
* Specifies the style upon which the current style is based-that is, the style from which the current style inherits. It is the mechanism for implementing style inheritance.
* Note that if the type of the current style must match the type of the style upon which it is based or the basedOn element will be ignored.
* However, if the current style is a numbering style, then the `basedOn` element is ignored.
*
* **WARNING**: You cannot set `basedOn` to be the same as `name`. This is akin to inheriting from itself. This creates a cyclic dependency and cause undesirable behavior.
*/
readonly basedOn?: string; readonly basedOn?: string;
readonly next?: string; readonly next?: string;
readonly link?: string; readonly link?: string;

View File

@ -206,8 +206,7 @@ const MOCK_XML = `
describe("from-docx", () => { describe("from-docx", () => {
describe("patchDocument", () => { describe("patchDocument", () => {
describe("document.xml and [Content_Types].xml", () => { describe("document.xml and [Content_Types].xml", () => {
before(() => { beforeEach(() => {
sinon.createStubInstance(JSZip, {});
sinon.stub(JSZip, "loadAsync").callsFake( sinon.stub(JSZip, "loadAsync").callsFake(
() => () =>
new Promise<JSZip>((resolve) => { new Promise<JSZip>((resolve) => {
@ -220,7 +219,7 @@ describe("from-docx", () => {
); );
}); });
after(() => { afterEach(() => {
(JSZip.loadAsync as unknown as sinon.SinonStub).restore(); (JSZip.loadAsync as unknown as sinon.SinonStub).restore();
}); });
@ -292,8 +291,7 @@ describe("from-docx", () => {
}); });
describe("document.xml and [Content_Types].xml with relationships", () => { describe("document.xml and [Content_Types].xml with relationships", () => {
before(() => { beforeEach(() => {
sinon.createStubInstance(JSZip, {});
sinon.stub(JSZip, "loadAsync").callsFake( sinon.stub(JSZip, "loadAsync").callsFake(
() => () =>
new Promise<JSZip>((resolve) => { new Promise<JSZip>((resolve) => {
@ -307,7 +305,7 @@ describe("from-docx", () => {
); );
}); });
after(() => { afterEach(() => {
(JSZip.loadAsync as unknown as sinon.SinonStub).restore(); (JSZip.loadAsync as unknown as sinon.SinonStub).restore();
}); });
@ -322,6 +320,14 @@ describe("from-docx", () => {
data: Buffer.from(""), data: Buffer.from(""),
transformation: { width: 100, height: 100 }, transformation: { width: 100, height: 100 },
}), }),
new ExternalHyperlink({
children: [
new TextRun({
text: "Google Link",
}),
],
link: "https://www.google.co.uk",
}),
], ],
}, },
}, },
@ -331,8 +337,7 @@ describe("from-docx", () => {
}); });
describe("document.xml", () => { describe("document.xml", () => {
before(() => { beforeEach(() => {
sinon.createStubInstance(JSZip, {});
sinon.stub(JSZip, "loadAsync").callsFake( sinon.stub(JSZip, "loadAsync").callsFake(
() => () =>
new Promise<JSZip>((resolve) => { new Promise<JSZip>((resolve) => {
@ -344,7 +349,45 @@ describe("from-docx", () => {
); );
}); });
after(() => { afterEach(() => {
(JSZip.loadAsync as unknown as sinon.SinonStub).restore();
});
it("should throw an error if the content types is not found", () =>
expect(
patchDocument(Buffer.from(""), {
patches: {
// eslint-disable-next-line @typescript-eslint/naming-convention
image_test: {
type: PatchType.PARAGRAPH,
children: [
new ImageRun({
data: Buffer.from(""),
transformation: { width: 100, height: 100 },
}),
],
},
},
}),
).to.eventually.be.rejected);
});
describe("Images", () => {
beforeEach(() => {
sinon.stub(JSZip, "loadAsync").callsFake(
() =>
new Promise<JSZip>((resolve) => {
const zip = new JSZip();
zip.file("word/document.xml", MOCK_XML);
zip.file("word/document.bmp", "");
resolve(zip);
}),
);
});
afterEach(() => {
(JSZip.loadAsync as unknown as sinon.SinonStub).restore(); (JSZip.loadAsync as unknown as sinon.SinonStub).restore();
}); });

View File

@ -68,7 +68,14 @@ export const patchDocument = async (data: InputDataType, options: PatchDocumentO
const hyperlinkRelationshipAdditions: IHyperlinkRelationshipAddition[] = []; const hyperlinkRelationshipAdditions: IHyperlinkRelationshipAddition[] = [];
let hasMedia = false; let hasMedia = false;
const binaryContentMap = new Map<string, Buffer>();
for (const [key, value] of Object.entries(zipContent.files)) { for (const [key, value] of Object.entries(zipContent.files)) {
if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
binaryContentMap.set(key, await value.async("nodebuffer"));
continue;
}
const json = toJson(await value.async("text")); const json = toJson(await value.async("text"));
if (key.startsWith("word/") && !key.endsWith(".xml.rels")) { if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
const context: IContext = { const context: IContext = {
@ -196,6 +203,10 @@ export const patchDocument = async (data: InputDataType, options: PatchDocumentO
zip.file(key, output); zip.file(key, output);
} }
for (const [key, value] of binaryContentMap) {
zip.file(key, value);
}
for (const { stream, fileName } of file.Media.Array) { for (const { stream, fileName } of file.Media.Array) {
zip.file(`word/media/${fileName}`, stream); zip.file(`word/media/${fileName}`, stream);
} }

View File

@ -86,6 +86,59 @@ describe("paragraph-split-inject", () => {
), ),
).to.throw(); ).to.throw();
}); });
it("should continue if text run doesn't have text", () => {
expect(() =>
findRunElementIndexWithToken(
{
name: "w:p",
type: "element",
elements: [
{
name: "w:r",
type: "element",
elements: [
{
name: "w:t",
type: "element",
},
],
},
],
},
"hello",
),
).to.throw();
});
it("should continue if text run doesn't have text", () => {
expect(() =>
findRunElementIndexWithToken(
{
name: "w:p",
type: "element",
elements: [
{
name: "w:r",
type: "element",
elements: [
{
name: "w:t",
type: "element",
elements: [
{
type: "text",
},
],
},
],
},
],
},
"hello",
),
).to.throw();
});
}); });
describe("splitRunElement", () => { describe("splitRunElement", () => {

View File

@ -8,7 +8,11 @@ export const findRunElementIndexWithToken = (paragraphElement: Element, token: s
const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === "w:t"); const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === "w:t");
for (const text of textElement) { for (const text of textElement) {
if ((text.elements?.[0].text as string)?.includes(token)) { if (!text.elements?.[0]) {
continue;
}
if ((text.elements[0].text as string)?.includes(token)) {
return i; return i;
} }
} }

View File

@ -71,6 +71,156 @@ describe("paragraph-token-replacer", () => {
}); });
}); });
it("should handle case where it cannot find any text to replace", () => {
const output = replaceTokenInParagraphElement({
paragraphElement: {
name: "w:p",
attributes: {
"w14:paraId": "2499FE9F",
"w14:textId": "27B4FBC2",
"w:rsidR": "00B51233",
"w:rsidRDefault": "007B52ED",
"w:rsidP": "007B52ED",
},
elements: [
{
type: "element",
name: "w:pPr",
elements: [{ type: "element", name: "w:pStyle", attributes: { "w:val": "Title" } }],
},
{
type: "element",
name: "w:r",
elements: [
{
type: "element",
name: "w:t",
attributes: { "xml:space": "preserve" },
elements: [{ type: "text", text: "Hello " }],
},
],
},
{
type: "element",
name: "w:r",
attributes: { "w:rsidR": "007F116B" },
elements: [
{
type: "element",
name: "w:t",
attributes: { "xml:space": "preserve" },
elements: [{ type: "text", text: "{{name}} " }],
},
],
},
{
type: "element",
name: "w:r",
elements: [{ type: "element", name: "w:t", elements: [{ type: "text", text: "World" }] }],
},
],
},
renderedParagraph: {
text: "Hello {{name}} World",
runs: [
{ text: "Hello ", parts: [{ text: "Hello ", index: 0, start: 0, end: 5 }], index: 1, start: 0, end: 5 },
{ text: "{{name}} ", parts: [{ text: "{{name}} ", index: 0, start: 6, end: 14 }], index: 2, start: 6, end: 14 },
{ text: "World", parts: [{ text: "World", index: 0, start: 15, end: 19 }], index: 3, start: 15, end: 19 },
],
index: 0,
path: [0, 1, 0, 0],
},
originalText: "{{name}}",
replacementText: "John",
});
expect(output).to.deep.equal({
attributes: {
"w14:paraId": "2499FE9F",
"w14:textId": "27B4FBC2",
"w:rsidP": "007B52ED",
"w:rsidR": "00B51233",
"w:rsidRDefault": "007B52ED",
},
elements: [
{
elements: [
{
attributes: {
"w:val": "Title",
},
name: "w:pStyle",
type: "element",
},
],
name: "w:pPr",
type: "element",
},
{
elements: [
{
attributes: {
"xml:space": "preserve",
},
elements: [
{
text: "Hello ",
type: "text",
},
],
name: "w:t",
type: "element",
},
],
name: "w:r",
type: "element",
},
{
attributes: {
"w:rsidR": "007F116B",
},
elements: [
{
attributes: {
"xml:space": "preserve",
},
elements: [
{
text: "John ",
type: "text",
},
],
name: "w:t",
type: "element",
},
],
name: "w:r",
type: "element",
},
{
elements: [
{
attributes: {
"xml:space": "preserve",
},
elements: [
{
text: "World",
type: "text",
},
],
name: "w:t",
type: "element",
},
],
name: "w:r",
type: "element",
},
],
name: "w:p",
});
});
// Try to fill rest of test coverage // Try to fill rest of test coverage
// it("should replace token in paragraph", () => { // it("should replace token in paragraph", () => {
// const output = replaceTokenInParagraphElement({ // const output = replaceTokenInParagraphElement({

View File

@ -30,9 +30,15 @@ export const replaceTokenInParagraphElement = ({
switch (replaceMode) { switch (replaceMode) {
case ReplaceMode.START: case ReplaceMode.START:
if (startIndex >= start) { if (startIndex >= start) {
const partToReplace = run.text.substring(Math.max(startIndex, start), Math.min(endIndex, end) + 1); const offsetStartIndex = startIndex - start;
const offsetEndIndex = Math.min(endIndex, end) - start;
const partToReplace = run.text.substring(offsetStartIndex, offsetEndIndex + 1);
// We use a token to split the text if the replacement is within the same run // We use a token to split the text if the replacement is within the same run
// If not, we just add text to the middle of the run later // If not, we just add text to the middle of the run later
if (partToReplace === "") {
continue;
}
const firstPart = text.replace(partToReplace, replacementText); const firstPart = text.replace(partToReplace, replacementText);
patchTextElement(paragraphElement.elements![run.index].elements![index], firstPart); patchTextElement(paragraphElement.elements![run.index].elements![index], firstPart);
replaceMode = ReplaceMode.MIDDLE; replaceMode = ReplaceMode.MIDDLE;

View File

@ -7,7 +7,7 @@ import { Text } from "@file/paragraph/run/run-components/text";
const formatter = new Formatter(); const formatter = new Formatter();
export const toJson = (xmlData: string): Element => { export const toJson = (xmlData: string): Element => {
const xmlObj = xml2js(xmlData, { compact: false }) as Element; const xmlObj = xml2js(xmlData, { compact: false, captureSpacesBetweenElements: true }) as Element;
return xmlObj; return xmlObj;
}; };

View File

@ -1,5 +1,8 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true
},
"typedocOptions": { "typedocOptions": {
"out": "docs/api", "out": "docs/api",
"exclude": "test", "exclude": "test",