Compare commits

...

61 Commits
8.0.4 ... 8.1.0

Author SHA1 Message Date
4976a75ab3 Version bump 2023-06-24 20:46:29 +01:00
a368ed7fd3 Add docsify-terminal-block to documentation 2023-06-15 21:29:10 +01:00
a9fa31ebac Upgrade testing libraries 2023-06-15 21:15:39 +01:00
6b4a78ed41 Merge pull request #2177 from dolanmiu/dependabot/npm_and_yarn/eslint-plugin-unicorn-47.0.0
build(deps-dev): bump eslint-plugin-unicorn from 46.0.0 to 47.0.0
2023-06-15 12:49:17 +01:00
9b93a15323 Merge pull request #2176 from dolanmiu/dependabot/npm_and_yarn/types/unzipper-0.10.6
build(deps-dev): bump @types/unzipper from 0.10.5 to 0.10.6
2023-06-15 12:49:08 +01:00
17774c50be build(deps-dev): bump eslint-plugin-unicorn from 46.0.0 to 47.0.0
Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 46.0.0 to 47.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v46.0.0...v47.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-14 11:57:06 +00:00
a63095a7b4 build(deps-dev): bump @types/unzipper from 0.10.5 to 0.10.6
Bumps [@types/unzipper](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/unzipper) from 0.10.5 to 0.10.6.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/unzipper)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-14 11:56:34 +00:00
9aba21e64c Add filtering and ordering to list of demos 2023-06-14 03:44:46 +01:00
6288bb0701 Bump sign off sheet 2023-06-14 02:48:56 +01:00
2061854778 Merge pull request #2119 from pulpgrinder/master
Added style support for noProof option.
2023-06-14 02:25:36 +01:00
e4eeb3f87f Fix spelling 2023-06-14 01:55:47 +01:00
a168dc1c15 Remove redundant code 2023-06-14 01:17:44 +01:00
99dee460ae Fix prettier 2023-06-13 20:55:20 +01:00
36e9ac1179 Adding tests for noProof option 2023-06-13 20:27:28 +01:00
df619ffe49 Added style support for noProof option.
Useful for blocks of source code, and
possibly other things that cause the grammar
and spelling checkers to go nuts.
Example usage:
 run: {
                            font:"Consolas",
                            color: "0000AA",
                            break:1,
                            noProof:true,
                        },

Also added section to .gitignore to exclude
Mac .DS_Store files. These are useless on
anything other than a Mac.
2023-06-13 20:26:45 +01:00
b1513d4ce9 Merge pull request #2160 from dolanmiu/dependabot/npm_and_yarn/eslint-plugin-jsdoc-46.2.6
build(deps-dev): bump eslint-plugin-jsdoc from 40.1.0 to 46.2.6
2023-06-13 20:25:29 +01:00
7d0a71acef build(deps-dev): bump eslint-plugin-jsdoc from 40.1.0 to 46.2.6
Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 40.1.0 to 46.2.6.
- [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/v40.1.0...v46.2.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 19:13:01 +00:00
307a651e6d Merge pull request #2166 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.59.11
build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.57.1 to 5.59.11
2023-06-13 20:12:17 +01:00
b7f6a7da6b Merge pull request #2165 from dolanmiu/dependabot/npm_and_yarn/typescript-eslint/parser-5.59.11
build(deps-dev): bump @typescript-eslint/parser from 5.57.1 to 5.59.11
2023-06-13 20:12:01 +01:00
1d9ff920e8 Merge pull request #2152 from dolanmiu/dependabot/npm_and_yarn/typescript-5.1.3
build(deps-dev): bump typescript from 5.0.3 to 5.1.3
2023-06-13 20:11:33 +01:00
810846c49a Fix linting 2023-06-13 20:11:04 +01:00
cb66d68980 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.57.1 to 5.59.11.
- [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.59.11/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-13 18:36:19 +00:00
1badd6a53f build(deps-dev): bump @typescript-eslint/parser from 5.57.1 to 5.59.11
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.57.1 to 5.59.11.
- [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.59.11/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-13 18:35:04 +00:00
7e37d8d27a build(deps-dev): bump typescript from 5.0.3 to 5.1.3
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.0.3 to 5.1.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.0.3...v5.1.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 18:33:45 +00:00
5c950e1a07 Merge pull request #2153 from dolanmiu/dependabot/npm_and_yarn/eslint-8.42.0
build(deps-dev): bump eslint from 8.37.0 to 8.42.0
2023-06-13 19:33:05 +01:00
adbb16f7eb Merge pull request #2154 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.24.8
build(deps-dev): bump typedoc from 0.23.28 to 0.24.8
2023-06-13 19:32:45 +01:00
dd088bf584 Merge pull request #2170 from dolanmiu/dependabot/npm_and_yarn/vite-plugin-node-polyfills-0.9.0
build(deps-dev): bump vite-plugin-node-polyfills from 0.8.2 to 0.9.0
2023-06-13 19:32:35 +01:00
a27cb7db47 Merge pull request #2171 from dolanmiu/dependabot/npm_and_yarn/unzipper-0.10.14
build(deps-dev): bump unzipper from 0.10.11 to 0.10.14
2023-06-13 19:32:26 +01:00
2e41387a50 Merge pull request #2172 from dolanmiu/dependabot/npm_and_yarn/types/node-20.3.1
build(deps): bump @types/node from 18.15.11 to 20.3.1
2023-06-13 19:32:16 +01:00
9bb4803ac5 Merge pull request #2173 from dolanmiu/dependabot/npm_and_yarn/vitest-0.32.0
build(deps-dev): bump vitest from 0.31.4 to 0.32.0
2023-06-13 19:32:01 +01:00
8bf2b6c9ce build(deps-dev): bump vitest from 0.31.4 to 0.32.0
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 0.31.4 to 0.32.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.32.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-06-13 11:57:22 +00:00
37f60c1766 build(deps): bump @types/node from 18.15.11 to 20.3.1
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.15.11 to 20.3.1.
- [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-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 11:57:03 +00:00
7bce84eba0 build(deps-dev): bump unzipper from 0.10.11 to 0.10.14
Bumps [unzipper](https://github.com/ZJONSSON/node-unzipper) from 0.10.11 to 0.10.14.
- [Release notes](https://github.com/ZJONSSON/node-unzipper/releases)
- [Commits](https://github.com/ZJONSSON/node-unzipper/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 11:56:48 +00:00
46bedaa241 build(deps-dev): bump vite-plugin-node-polyfills from 0.8.2 to 0.9.0
Bumps [vite-plugin-node-polyfills](https://github.com/davidmyersdev/vite-plugin-node-polyfills) from 0.8.2 to 0.9.0.
- [Release notes](https://github.com/davidmyersdev/vite-plugin-node-polyfills/releases)
- [Commits](https://github.com/davidmyersdev/vite-plugin-node-polyfills/compare/v0.8.2...v0.9.0)

---
updated-dependencies:
- dependency-name: vite-plugin-node-polyfills
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 11:56:36 +00:00
9a6d8c0e8b build(deps-dev): bump typedoc from 0.23.28 to 0.24.8
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.23.28 to 0.24.8.
- [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.28...v0.24.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-12 23:44:44 +00:00
1571b7a1a7 Merge pull request #2039 from dolanmiu/dependabot/npm_and_yarn/nanoid-4.0.2
build(deps): bump nanoid from 3.3.4 to 4.0.2
2023-06-13 00:43:07 +01:00
16f5e5bbbc build(deps-dev): bump eslint from 8.37.0 to 8.42.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.37.0 to 8.42.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.37.0...v8.42.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-12 23:40:58 +00:00
e3a8def43e Merge pull request #2164 from dolanmiu/dependabot/npm_and_yarn/vite-4.3.9
build(deps-dev): bump vite from 4.3.3 to 4.3.9
2023-06-13 00:40:19 +01:00
40c11bae22 Merge pull request #2167 from dolanmiu/dependabot/npm_and_yarn/prettier-2.8.8
build(deps-dev): bump prettier from 2.8.7 to 2.8.8
2023-06-13 00:40:03 +01:00
3a3415a3da Merge pull request #2159 from dolanmiu/dependabot/npm_and_yarn/glob-10.2.7
build(deps-dev): bump glob from 9.3.2 to 10.2.7
2023-06-13 00:39:47 +01:00
222024fdde build(deps): bump nanoid from 3.3.4 to 4.0.2
Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.4 to 4.0.2.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.3.4...4.0.2)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-12 23:31:29 +00:00
c5511bb3d9 build(deps-dev): bump prettier from 2.8.7 to 2.8.8
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.7 to 2.8.8.
- [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.7...2.8.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-12 19:17:59 +00:00
5c4696a660 build(deps-dev): bump glob from 9.3.2 to 10.2.7
Bumps [glob](https://github.com/isaacs/node-glob) from 9.3.2 to 10.2.7.
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v9.3.2...v10.2.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-12 19:08:53 +00:00
2812bef532 build(deps-dev): bump vite from 4.3.3 to 4.3.9
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.3 to 4.3.9.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.3.9/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-12 19:08:15 +00:00
91379070d3 Merge pull request #2148 from dolanmiu/feat/deprecate-shelljs
Upgrade project to use ESM and Vite
2023-06-12 20:07:03 +01:00
668f4f4e78 Remove unused imports 2023-06-12 19:45:03 +01:00
28ad740473 Fix linting 2023-06-12 19:21:22 +01:00
d08349f8eb Fix tests 2023-06-12 19:19:41 +01:00
b6e5b23f89 Fix linting 2023-06-12 19:09:37 +01:00
8dd8c079e7 Fix tests 2023-06-12 19:02:12 +01:00
eeee01a0e0 Use C8 for coverage 2023-06-12 18:43:29 +01:00
09ab91eeef Fix tests and build
Remove unused code and dependencies
2023-06-08 13:30:31 +01:00
a0a88412ff Fix tests 2023-06-07 15:11:47 +01:00
972fa77265 Fix tests 2023-06-07 03:19:54 +01:00
e69b063687 Porting tests over to vitest 2023-06-05 00:33:43 +01:00
a89919397d Merge branch 'master' into feat/deprecate-shelljs
# Conflicts:
#	src/file/numbering/numbering.ts
2023-06-01 02:08:08 +01:00
0cbb5fb0a3 Convert to vite and clean up build 2023-06-01 02:05:35 +01:00
352cde743f Fix TS issues 2023-05-31 22:56:58 +01:00
a26292a0fd Trying to upgrade docx to use Vite 2023-05-01 20:37:39 +01:00
18b2e91da2 Merge branch 'master' into feat/deprecate-shelljs 2023-05-01 16:36:43 +01:00
5e14bc6c2a Install execa 2023-03-30 20:13:35 +01:00
287 changed files with 22507 additions and 21642 deletions

View File

@ -4,13 +4,7 @@
"version": "0.2",
// language - current active spelling language
"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": [
"Abjad",
@ -21,13 +15,17 @@
"datas",
"docsify",
"dolan",
"execa",
"falsey",
"iife",
"Initializable",
"iroha",
"jsonify",
"jszip",
"NUMPAGES",
"odttf",
"ondata",
"onfile",
"ooxml",
"panose",
"rels",
@ -57,15 +55,10 @@
"/<element name=\"[a-z]+\"/gi",
"/<attribute name=\"[a-z]+\"/gi"
],
"ignorePaths": [
"package.json",
"docs/api"
],
"ignorePaths": ["package.json", "docs/api", "*.docx", "build"],
"allowCompoundWords": true,
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
// For example "hte" should be "the"
"flagWords": [
"hte"
]
"flagWords": ["hte"]
}

View File

@ -1,272 +0,0 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
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",
"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"],
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",
"jsdoc/newline-after-description": "error",
"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",
{
assumeTypes: true,
ignoreImmediateMutation: true,
ignoreAccessorPattern: ["**.root*", "**.numberingReferences*", "**.sections*", "**.properties*"],
},
],
"functional/prefer-property-signatures": "error",
"functional/no-mixed-types": "error",
// TODO: Deprecated. Use prefer-immutable-types and type-declaration-immutability instead
"functional/prefer-readonly-type": "error",
// "functional/prefer-immutable-types": "error",
// "functional/type-declaration-immutability": "error",
"no-unused-vars": ["error", { argsIgnorePattern: "^[_]+$" }],
},
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",
},
},
],
};

239
.eslintrc.yml Normal file
View File

@ -0,0 +1,239 @@
extends: eslint:recommended
env:
browser: true
es6: true
node: true
parser: "@typescript-eslint/parser"
parserOptions:
project:
- tsconfig.json
- demo/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
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
- assumeTypes: true
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"

View File

@ -5,36 +5,3 @@ updates:
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: "@types/node"
versions:
- 14.14.22
- 14.14.24
- 14.14.25
- 14.14.26
- 14.14.28
- 14.14.29
- 14.14.30
- 15.0.0
- dependency-name: webpack
versions:
- 5.31.2
- 5.35.0
- dependency-name: ts-loader
versions:
- 9.1.0
- dependency-name: awesome-typescript-loader
versions:
- 5.2.1
- dependency-name: chai
versions:
- 4.2.0
- 4.3.0
- 4.3.1
- 4.3.3
- dependency-name: replace-in-file
versions:
- 6.1.0
- dependency-name: "@types/chai"
versions:
- 4.2.14

View File

@ -32,7 +32,7 @@ jobs:
- name: Install Dependencies
run: npm ci --force
- name: Test
run: npm run test.coverage
run: npm run test.ci
- name: Codecov
uses: codecov/codecov-action@v3
with:

4
.gitignore vendored
View File

@ -60,5 +60,5 @@ My Document.docx
# Temporary folder
tmp
# nyc
.nyc_output
# Exclude Mac .DS_Store files
.DS_Store

View File

@ -1,13 +0,0 @@
{
"diff": true,
"spec": "src/**/*.ts",
"extension": ["ts"],
"package": "./package.json",
"reporter": "spec",
"slow": "75",
"timeout": "2000",
"ui": "bdd",
"watch-files": ["src/**/*.ts"],
"watch-ignore": ["build", "demo"],
"require": ["mocha.env", "ts-node/register", "tsconfig-paths/register"]
}

25
.nycrc
View File

@ -1,25 +0,0 @@
{
"check-coverage": true,
"statements": 99.87,
"branches": 98.21,
"functions": 100,
"lines": 99.86,
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.spec.ts",
"src/import-dotx/import-dotx.ts"
],
"reporter": [
"lcov",
"text",
"json"
],
"extension": [
".ts"
],
"cache": true,
"all": true,
"sourceMap": true
}

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Generate a CV
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "../build";
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "docx";
// tslint:disable:no-shadowed-variable

View File

@ -1,5 +1,5 @@
// Setting styles with JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
AlignmentType,
@ -16,7 +16,7 @@ import {
TabStopPosition,
UnderlineType,
LevelFormat,
} from "../build";
} from "docx";
const table = new Table({
rows: [

View File

@ -1,7 +1,7 @@
// Scaling images
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph } from "../build";
import { Document, ImageRun, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// This example shows 3 styles using XML styles
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
import { Document, HeadingLevel, Packer, Paragraph } from "docx";
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
const doc = new Document({

View File

@ -1,7 +1,7 @@
// Page numbers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Page break before example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
import { Document, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Multiple sections and headers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Footnotes
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build";
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
footnotes: {

View File

@ -1,7 +1,7 @@
// Insert image from a buffer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph } from "../build";
import { Document, ImageRun, Packer, Paragraph } from "docx";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFx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Rf5vi8rLQxtUhAAAAAElFTkSuQmCC`;

View File

@ -1,7 +1,7 @@
// Export to base64 string - Useful in a browser environment.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,17 +1,7 @@
// Example on how to customize the look at feel using Styles
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
AlignmentType,
convertInchesToTwip,
Document,
HeadingLevel,
LevelFormat,
Packer,
Paragraph,
TextRun,
UnderlineType,
} from "../build";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph, TextRun, UnderlineType } from "docx";
const doc = new Document({
creator: "Clippy",

View File

@ -1,7 +1,7 @@
// Add custom borders to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const doc = new Document({
sections: [

View File

@ -1,18 +1,7 @@
// This demo shows how to create bookmarks then link to them with internal hyperlinks
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Bookmark,
Document,
Footer,
HeadingLevel,
InternalHyperlink,
Packer,
PageBreak,
Paragraph,
TextRun,
PageReference,
} from "../build";
import { Bookmark, Document, Footer, HeadingLevel, InternalHyperlink, Packer, PageBreak, Paragraph, TextRun, PageReference } from "docx";
const LOREM_IPSUM =
/* cspell:disable-next-line */

View File

@ -1,7 +1,7 @@
// This demo shows right to left for special languages
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "../build";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// This demo adds an image to the Media cache, and then insert to the document afterwards
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph, TextRun } from "../build";
import { Document, ImageRun, Packer, Paragraph, TextRun } from "docx";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyAiHyAjHSAjHR4jHR4hHh4hHx8hHyAiHyAjHyAjHSAjHR4jHR4hHh4hHx8hHyAjHyAjHyAjHSA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9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;

View File

@ -1,7 +1,7 @@
// Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");

View File

@ -1,7 +1,7 @@
// Creates two paragraphs, one with a border and one without
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "../build";
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Custom styles using JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "../build";
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "docx";
const doc = new Document({
styles: {

View File

@ -1,7 +1,7 @@
// Table of contents
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "../build";
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "docx";
// WordprocessingML docs for TableOfContents can be found here:
// http://officeopenxml.com/WPtableOfContents.php

View File

@ -1,8 +1,8 @@
// Numbered lists
// The lists can also be restarted by specifying the instance number
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
const doc = new Document({
numbering: {

View File

@ -1,7 +1,7 @@
// Numbering and bullet points example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
const doc = new Document({
numbering: {

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "../build";
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "docx";
const doc = new Document({
sections: [

View File

@ -1,6 +1,6 @@
// Example of how you would merge cells together (Rows and Columns) and apply shading
// Also includes an example on how to center tables
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
AlignmentType,
@ -15,7 +15,7 @@ import {
TableCell,
TableRow,
WidthType,
} from "../build";
} from "docx";
const table = new Table({
rows: [

View File

@ -1,7 +1,7 @@
// Sequential Captions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "../build";
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,5 +1,5 @@
// Example of how you would create a table with float positions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
@ -14,7 +14,7 @@ import {
TableLayoutType,
TableRow,
WidthType,
} from "../build";
} from "docx";
const table = new Table({
rows: [

View File

@ -1,7 +1,7 @@
// Example on how to add hyperlinks to websites
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "../build";
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
footnotes: {

View File

@ -1,7 +1,7 @@
// Add image to table cell in a header and body
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const table = new Table({
rows: [

View File

@ -1,7 +1,7 @@
// Add images to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Header, ImageRun, Packer, Paragraph } from "../build";
import { Document, Header, ImageRun, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,8 +1,8 @@
// Example of how to "wrap" text around an image
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
// import { Document, Packer, Paragraph } from "../build";
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build";
// import { Document, Packer, Paragraph } from "docx";
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example how to display page numbers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
const table = new Table({
columnWidths: [3505, 5505],

View File

@ -1,7 +1,7 @@
// Example demonstrating line numbers.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Multiple cells merging in the same table - Rows and Columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const table = new Table({
rows: [

View File

@ -1,7 +1,7 @@
// Page numbers - Start from 0 on a new section
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0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FiTwyC72KK7+DNg1SsRvCNp3gZXq2k4iEEXSHFJHgVXUlxejCCbTvFAHiXdIJiXxyCK7KJ5FHoMZGK9xBcwyg2QpdlVMxEUM2iyIMuXXZQNF+HswxMsSAAJRQjoE//eoqDCXBSTO6f1xd+O0iyNRY6jaWi1ALNYCocZROj4JdEikroVkjFk9DcStXxpdfCD2MoXodu4RUU9ptxxmXssOfxnvDVcxRTod9FxyhqLoAqis5aPhwTDp9spRgEH2Q6KLbYoKqlaKTm6Isp0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;

View File

@ -1,7 +1,7 @@
// Sections with multiple columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
import { Document, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Highlighting text
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Shading text
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Multiple sections with total number of pages in each section
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
const header = new Header({
children: [

View File

@ -1,7 +1,7 @@
// Example of making content of section vertically aligned
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "../build";
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "docx";
const doc = new Document({
sections: [

View File

@ -1,5 +1,5 @@
// Add custom borders and no-borders to the table itself
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
BorderStyle,
@ -13,7 +13,7 @@ import {
TableRow,
TextDirection,
VerticalAlign,
} from "../build";
} from "docx";
const table = new Table({
rows: [

View File

@ -1,5 +1,5 @@
// Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
@ -10,7 +10,7 @@ import {
Paragraph,
VerticalPositionAlign,
VerticalPositionRelativeFrom,
} from "../build";
} from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// The demo on the README.md
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build";
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "docx";
const table = new Table({
rows: [

View File

@ -1,7 +1,7 @@
// Custom character styles using JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
styles: {

View File

@ -1,7 +1,7 @@
// Japanese text - Need to use a Japanese font
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
import { Document, HeadingLevel, Packer, Paragraph } from "docx";
const doc = new Document({
styles: {

View File

@ -5,9 +5,8 @@
// Note that if the OS have not install `KaiTi` font, this demo doesn't work.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
styles: {

View File

@ -3,9 +3,8 @@
// to the document in Word after the document has been generated. Standard properties (such as creator, title
// and subject) cover typical use cases, but sometimes custom properties are required.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer } from "../build";
import { Document, Packer } from "docx";
const doc = new Document(
// Standard properties

View File

@ -1,5 +1,5 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
@ -21,7 +21,7 @@ import {
Packer,
Paragraph,
TextRun,
} from "../build";
} from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Change background colour of whole document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({
background: {

View File

@ -1,7 +1,7 @@
// Numbered lists - Add parent number in sub number
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
const doc = new Document({
numbering: {

View File

@ -1,7 +1,7 @@
// Usage of different Section Types
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, SectionType } from "../build";
import { Document, Packer, Paragraph, TextRun, SectionType } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Move + offset header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph } from "../build";
import { Document, Footer, Header, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example of how to change page borders
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "../build";
import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,5 +1,5 @@
// Track Revisions aka. "Track Changes"
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
AlignmentType,
@ -14,7 +14,7 @@ import {
ShadingType,
Tab,
TextRun,
} from "../build";
} from "docx";
/*
For reference, see

View File

@ -1,5 +1,5 @@
// Text Frame (Text Box) example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
BorderStyle,
@ -11,7 +11,7 @@ import {
Tab,
TextRun,
VerticalPositionAlign,
} from "../build";
} from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "../build";
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Move + offset header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "../build";
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "docx";
const doc = new Document({
evenAndOddHeaderAndFooters: true,

View File

@ -1,7 +1,7 @@
// Numbered lists - With complex number text
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, LevelFormat } from "../build";
import { Document, Packer, Paragraph, LevelFormat } from "docx";
const doc = new Document({
numbering: {

View File

@ -1,8 +1,8 @@
// Example of how to set the document page sizes
// Reference from https://papersizes.io/a/a3
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "../build";
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Use fields to include dynamic text
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "../build";
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "docx";
const doc = new Document({
creator: "Me",

View File

@ -1,7 +1,7 @@
// Section with 2 columns including a column break
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "../build";
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,5 +1,5 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, LevelFormat } from "../build";
import { Document, Packer, Paragraph, LevelFormat } from "docx";
const doc = new Document({
numbering: {

View File

@ -1,7 +1,7 @@
// Sections with multiple columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Column, Document, Packer, Paragraph } from "../build";
import { Column, Document, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example of how to set the document to landscape
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, PageOrientation, Paragraph } from "../build";
import { Document, Packer, PageOrientation, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example demonstrating line numbers with suppression.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example demonstrating page borders with style, colors and size
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "../build";
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example on how to preserve word wrap text. Works with all languages.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, SpaceType } from "../build";
import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Simple example to add comments to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "../build";
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "docx";
const doc = new Document({
comments: {

View File

@ -1,7 +1,7 @@
// Exporting the document as a stream
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Example of using tab stops
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "docx";
const columnWidth = TabStopPosition.MAX / 4;
const receiptTabStops = [
@ -14,8 +14,8 @@ const receiptTabStops = [
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
],
twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
];
const twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Add compatibility options
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
compatibility: {

View File

@ -1,7 +1,7 @@
// Exporting the document as a stream
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "../build";
import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "docx";
const table1 = new Table({
columnWidths: [3505, 5505],

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,5 +1,5 @@
// Example of how you would create a table and add data to it from a data source
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
@ -13,7 +13,7 @@ import {
TextDirection,
TextRun,
WidthType,
} from "../build";
} from "docx";
interface StockPrice {
readonly date: Date;

View File

@ -1,7 +1,7 @@
// Add text to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph } from "../build";
import { Document, Footer, Header, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, convertMillimetersToTwip, Document, Packer, Paragraph, TextRun } from "../build";
import { AlignmentType, convertMillimetersToTwip, Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
styles: {

View File

@ -1,7 +1,7 @@
// Example of a continuous header
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "../build";
import { Document, Footer, Header, Packer, Paragraph, SectionType, TextRun } from "docx";
const doc = new Document({
creator: "Creator",

View File

@ -1,7 +1,7 @@
// Example of using headers and footers in a new section
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "../build";
import { Document, Footer, Header, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
creator: "Creator",

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
import { Document, Packer, Paragraph } from "docx";
const doc = new Document({
styles: {

View File

@ -1,17 +1,16 @@
// Simple example apply positional tabs to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
Packer,
Paragraph,
PositionalTab,
Tab,
TextRun,
PositionalTabAlignment,
PositionalTabRelativeTo,
PositionalTabLeader,
} from "../build";
} from "docx";
const doc = new Document({
sections: [

View File

@ -1,5 +1,5 @@
// Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
ExternalHyperlink,
@ -14,7 +14,7 @@ import {
TextDirection,
TextRun,
VerticalAlign,
} from "../build";
} from "docx";
patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
patches: {

View File

@ -1,7 +1,7 @@
// Generate a template document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [

View File

@ -1,7 +1,7 @@
// 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";
import { patchDocument, PatchType, TextRun } from "docx";
patchDocument(fs.readFileSync("demo/assets/simple-template-2.docx"), {
patches: {

View File

@ -1,7 +1,7 @@
// 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";
import { IPatch, patchDocument, PatchType, TextRun } from "docx";
export const font = "Trebuchet MS";
export const getPatches = (fields: { [key: string]: string }) => {

View File

@ -1,7 +1,7 @@
// 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";
import { IPatch, patchDocument, PatchType, TextRun } from "docx";
export const font = "Trebuchet MS";
export const getPatches = (fields: { [key: string]: string }) => {

View File

@ -1,7 +1,7 @@
// Add images to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, ImageRun, Packer, Paragraph } from "../build";
import { Document, Footer, Header, ImageRun, Packer, Paragraph } from "docx";
const doc = new Document({
sections: [

View File

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

View File

@ -1,37 +1,61 @@
// tslint:disable:no-console
/* eslint-disable no-console */
import fs from "fs";
import prompt from "prompt";
import shelljs from "shelljs";
import path from "path";
import inquirer from "inquirer";
import { $ } from "execa";
console.log("What demo do you wish to run? (Enter a number)");
const schema = {
properties: {
number: {
pattern: /^[0-9]+$/,
message: "Please enter a number.",
required: true,
},
},
export type Answers = {
type: "list" | "number";
demoNumber?: number;
demoFile?: number;
};
prompt.start();
const dir = "./demo";
const fileNames = fs.readdirSync(dir);
prompt.get(schema as any, (_, result) => {
const demoNumber = result.number as string;
const files = fs.readdirSync("./demo").filter((fn) => fn.startsWith(demoNumber));
const keys = fileNames.map((f) => path.parse(f).name);
const getFileNumber = (file: string): number => {
const nameParts = file.split("-");
const firstPart = nameParts[0];
if (files.length === 0) {
return Number(firstPart);
};
const demoFiles = keys.filter((file) => !isNaN(getFileNumber(file))).sort((a, b) => getFileNumber(a) - getFileNumber(b));
const answers = await inquirer.prompt<Answers>([
{
type: "list",
name: "type",
message: "Select demo from a list or via number",
choices: ["list", "number"],
},
{
type: "list",
name: "demoFile",
message: "What demo do you wish to run?",
choices: demoFiles,
filter: (input) => parseInt(input.split("-")[0]),
when: (answers) => answers.type === "list",
},
{
type: "number",
name: "demoNumber",
message: "What demo do you wish to run? (Enter a number)",
default: 1,
when: (answers) => answers.type === "number",
},
]);
const demoNumber = answers.demoNumber ?? answers.demoFile ?? 1;
const files = fs.readdirSync(dir).filter((fn) => fn.startsWith(demoNumber.toString()));
if (files.length === 0) {
console.error(`demo number ${demoNumber} does not exist`);
return;
}
const filePath = `./demo/${files[0]}`;
} else {
const filePath = path.join(dir, files[0]);
console.log(`Running demo ${demoNumber}: ${files[0]}`);
if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
console.log("Document created successfully");
} else {
console.error("Something went wrong with the demo");
}
});
await $`ts-node --project demo/tsconfig.json ${filePath}`;
console.log("Successfully created document!");
}

10
demo/tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "./",
"paths": {
"docx": ["../build"]
}
},
"include": ["../demo"]
}

View File

@ -2,7 +2,7 @@
## Installation
```sh
```terminal
npm install --save docx
```

Some files were not shown because too many files have changed in this diff Show More