Use new eslint-plugin-functional instead of tslint-immutable
This commit is contained in:
31
.eslintrc.js
31
.eslintrc.js
@ -29,7 +29,7 @@ module.exports = {
|
|||||||
"eslint-plugin-jsdoc",
|
"eslint-plugin-jsdoc",
|
||||||
"eslint-plugin-prefer-arrow",
|
"eslint-plugin-prefer-arrow",
|
||||||
"@typescript-eslint",
|
"@typescript-eslint",
|
||||||
"@typescript-eslint/tslint",
|
"functional",
|
||||||
],
|
],
|
||||||
root: true,
|
root: true,
|
||||||
rules: {
|
rules: {
|
||||||
@ -162,6 +162,7 @@ module.exports = {
|
|||||||
"@typescript-eslint/unified-signatures": "error",
|
"@typescript-eslint/unified-signatures": "error",
|
||||||
"arrow-body-style": "error",
|
"arrow-body-style": "error",
|
||||||
complexity: "off",
|
complexity: "off",
|
||||||
|
"consistent-return": "error",
|
||||||
"constructor-super": "error",
|
"constructor-super": "error",
|
||||||
curly: "error",
|
curly: "error",
|
||||||
"dot-notation": "off",
|
"dot-notation": "off",
|
||||||
@ -232,30 +233,18 @@ module.exports = {
|
|||||||
"unicorn/prefer-ternary": "error",
|
"unicorn/prefer-ternary": "error",
|
||||||
"use-isnan": "error",
|
"use-isnan": "error",
|
||||||
"valid-typeof": "off",
|
"valid-typeof": "off",
|
||||||
"@typescript-eslint/tslint/config": [
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
|
"functional/immutable-data": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
rules: {
|
assumeTypes: true,
|
||||||
"no-delete": true,
|
ignoreImmediateMutation: true,
|
||||||
"no-method-signature": true,
|
ignoreAccessorPattern: ["**.root*", "**.numberingReferences*", "**.sections*", "**.properties*"],
|
||||||
"no-mixed-interface": true,
|
|
||||||
"readonly-keyword": true,
|
|
||||||
"return-undefined": true,
|
|
||||||
whitespace: [
|
|
||||||
true,
|
|
||||||
"check-branch",
|
|
||||||
"check-decl",
|
|
||||||
"check-operator",
|
|
||||||
"check-separator",
|
|
||||||
"check-type",
|
|
||||||
"check-typecast",
|
|
||||||
"check-type-operator",
|
|
||||||
"check-rest-spread",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"@typescript-eslint/explicit-function-return-type": "off",
|
"functional/no-method-signature": "error",
|
||||||
|
"functional/no-mixed-type": "error",
|
||||||
|
"functional/prefer-readonly-type": "error",
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
- Follow Prettier standards, and consider using the [Prettier VSCode](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugin.
|
- Follow Prettier standards, and consider using the [Prettier VSCode](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugin.
|
||||||
|
|
||||||
- Follow the `TSLint` rules
|
- Follow the `ESLint` rules
|
||||||
|
|
||||||
## Always think about the user
|
## Always think about the user
|
||||||
|
|
||||||
Put yourself in their position, and imagine how they would feel about your feature you wrote.
|
Put yourself in their position, and imagine how they would feel about the feature you wrote.
|
||||||
|
|
||||||
1. Is it easy to use?
|
1. Is it easy to use?
|
||||||
2. Has it been documented well?
|
2. Has it been documented well?
|
||||||
|
392
package-lock.json
generated
392
package-lock.json
generated
@ -26,13 +26,13 @@
|
|||||||
"@types/unzipper": "^0.10.4",
|
"@types/unzipper": "^0.10.4",
|
||||||
"@types/webpack": "^5.0.0",
|
"@types/webpack": "^5.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||||
"@typescript-eslint/eslint-plugin-tslint": "^5.36.1",
|
|
||||||
"@typescript-eslint/parser": "^5.36.1",
|
"@typescript-eslint/parser": "^5.36.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"cspell": "^6.2.2",
|
"cspell": "^6.2.2",
|
||||||
"docsify-cli": "^4.3.0",
|
"docsify-cli": "^4.3.0",
|
||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
|
"eslint-plugin-functional": "^4.3.1",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-jsdoc": "^39.3.6",
|
"eslint-plugin-jsdoc": "^39.3.6",
|
||||||
"eslint-plugin-no-null": "^1.0.2",
|
"eslint-plugin-no-null": "^1.0.2",
|
||||||
@ -1507,24 +1507,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin-tslint": {
|
|
||||||
"version": "5.36.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin-tslint/-/eslint-plugin-tslint-5.36.1.tgz",
|
|
||||||
"integrity": "sha512-cOpdXK60QxSxMMr71Rn0AMLaEK2K6zyqK/Dfb9GxruJ+sHYrPsJFW2cy+XkeY1fL6As4Q8yO13Gkjget45I5aw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@typescript-eslint/utils": "5.36.1",
|
|
||||||
"lodash": "^4.17.21"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
||||||
"tslint": "^5.0.0 || ^6.0.0",
|
|
||||||
"typescript": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": {
|
"node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": {
|
||||||
"version": "4.3.4",
|
"version": "4.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||||
@ -1575,21 +1557,6 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/tsutils": {
|
|
||||||
"version": "3.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
|
||||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"tslib": "^1.8.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": {
|
"node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
@ -1713,21 +1680,6 @@
|
|||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/type-utils/node_modules/tsutils": {
|
|
||||||
"version": "3.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
|
||||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"tslib": "^1.8.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@typescript-eslint/types": {
|
"node_modules/@typescript-eslint/types": {
|
||||||
"version": "5.36.1",
|
"version": "5.36.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.36.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.36.1.tgz",
|
||||||
@ -1818,21 +1770,6 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/tsutils": {
|
|
||||||
"version": "3.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
|
||||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"tslib": "^1.8.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/yallist": {
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/yallist": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
@ -2614,16 +2551,6 @@
|
|||||||
"node": ">=0.2.0"
|
"node": ">=0.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/builtin-modules": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
|
||||||
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/cacheable-request": {
|
"node_modules/cacheable-request": {
|
||||||
"version": "6.1.0",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz",
|
||||||
@ -3003,13 +2930,6 @@
|
|||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
|
||||||
"version": "2.15.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
|
||||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true
|
|
||||||
},
|
|
||||||
"node_modules/comment-json": {
|
"node_modules/comment-json": {
|
||||||
"version": "4.2.3",
|
"version": "4.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.3.tgz",
|
||||||
@ -3641,6 +3561,15 @@
|
|||||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/deepmerge-ts": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-xzJLiUo4z1dD2nggSfaMvHo5qWLoy/JVa9rKuktC6FrQQEBI8Qnj7KwuCYZhqBoGOOpGqs6+3MR2ZhSMcTr4BA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/default-require-extensions": {
|
"node_modules/default-require-extensions": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz",
|
||||||
@ -4307,6 +4236,79 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-functional": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-functional/-/eslint-plugin-functional-4.3.1.tgz",
|
||||||
|
"integrity": "sha512-Mlm0A4gtQya2jLg6BvL8FoyHtedMj3gGJNMe9SWIyRhFmIibGFjOldzZ86LxOQYnwLMV9AD5aeLBRfxPFTkkaQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@typescript-eslint/utils": "^5.10.2",
|
||||||
|
"deepmerge-ts": "^4.0.3",
|
||||||
|
"escape-string-regexp": "^4.0.0",
|
||||||
|
"semver": "^7.3.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": "^8.0.0",
|
||||||
|
"tsutils": "^3.0.0",
|
||||||
|
"typescript": "^3.4.1 || ^4.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"tsutils": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"typescript": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-functional/node_modules/escape-string-regexp": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-functional/node_modules/lru-cache": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"yallist": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-functional/node_modules/semver": {
|
||||||
|
"version": "7.3.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
|
||||||
|
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^6.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-functional/node_modules/yallist": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-import": {
|
"node_modules/eslint-plugin-import": {
|
||||||
"version": "2.26.0",
|
"version": "2.26.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
|
||||||
@ -10339,79 +10341,19 @@
|
|||||||
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
|
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/tslint": {
|
|
||||||
"version": "5.20.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz",
|
|
||||||
"integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@babel/code-frame": "^7.0.0",
|
|
||||||
"builtin-modules": "^1.1.1",
|
|
||||||
"chalk": "^2.3.0",
|
|
||||||
"commander": "^2.12.1",
|
|
||||||
"diff": "^4.0.1",
|
|
||||||
"glob": "^7.1.1",
|
|
||||||
"js-yaml": "^3.13.1",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"resolve": "^1.3.2",
|
|
||||||
"semver": "^5.3.0",
|
|
||||||
"tslib": "^1.8.0",
|
|
||||||
"tsutils": "^2.29.0"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"tslint": "bin/tslint"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.8.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tslint/node_modules/diff": {
|
|
||||||
"version": "4.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
|
||||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.3.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tslint/node_modules/glob": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
|
||||||
"fs.realpath": "^1.0.0",
|
|
||||||
"inflight": "^1.0.4",
|
|
||||||
"inherits": "2",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tsutils": {
|
"node_modules/tsutils": {
|
||||||
"version": "2.29.0",
|
"version": "3.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
||||||
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^1.8.1"
|
"tslib": "^1.8.1"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev"
|
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tunnel-agent": {
|
"node_modules/tunnel-agent": {
|
||||||
@ -12773,15 +12715,6 @@
|
|||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsutils": {
|
|
||||||
"version": "3.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
|
||||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"tslib": "^1.8.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
@ -12790,16 +12723,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/eslint-plugin-tslint": {
|
|
||||||
"version": "5.36.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin-tslint/-/eslint-plugin-tslint-5.36.1.tgz",
|
|
||||||
"integrity": "sha512-cOpdXK60QxSxMMr71Rn0AMLaEK2K6zyqK/Dfb9GxruJ+sHYrPsJFW2cy+XkeY1fL6As4Q8yO13Gkjget45I5aw==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@typescript-eslint/utils": "5.36.1",
|
|
||||||
"lodash": "^4.17.21"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@typescript-eslint/parser": {
|
"@typescript-eslint/parser": {
|
||||||
"version": "5.36.1",
|
"version": "5.36.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.36.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.36.1.tgz",
|
||||||
@ -12865,15 +12788,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
|
||||||
"tsutils": {
|
|
||||||
"version": "3.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
|
||||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"tslib": "^1.8.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -12931,15 +12845,6 @@
|
|||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsutils": {
|
|
||||||
"version": "3.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
|
||||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"tslib": "^1.8.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
@ -13548,13 +13453,6 @@
|
|||||||
"integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=",
|
"integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"builtin-modules": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
|
||||||
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true
|
|
||||||
},
|
|
||||||
"cacheable-request": {
|
"cacheable-request": {
|
||||||
"version": "6.1.0",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz",
|
||||||
@ -13844,13 +13742,6 @@
|
|||||||
"delayed-stream": "~1.0.0"
|
"delayed-stream": "~1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"commander": {
|
|
||||||
"version": "2.15.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
|
||||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true
|
|
||||||
},
|
|
||||||
"comment-json": {
|
"comment-json": {
|
||||||
"version": "4.2.3",
|
"version": "4.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.3.tgz",
|
||||||
@ -14345,6 +14236,12 @@
|
|||||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"deepmerge-ts": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-xzJLiUo4z1dD2nggSfaMvHo5qWLoy/JVa9rKuktC6FrQQEBI8Qnj7KwuCYZhqBoGOOpGqs6+3MR2ZhSMcTr4BA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"default-require-extensions": {
|
"default-require-extensions": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz",
|
||||||
@ -15062,6 +14959,50 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"eslint-plugin-functional": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-functional/-/eslint-plugin-functional-4.3.1.tgz",
|
||||||
|
"integrity": "sha512-Mlm0A4gtQya2jLg6BvL8FoyHtedMj3gGJNMe9SWIyRhFmIibGFjOldzZ86LxOQYnwLMV9AD5aeLBRfxPFTkkaQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@typescript-eslint/utils": "^5.10.2",
|
||||||
|
"deepmerge-ts": "^4.0.3",
|
||||||
|
"escape-string-regexp": "^4.0.0",
|
||||||
|
"semver": "^7.3.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"escape-string-regexp": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"lru-cache": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"yallist": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"semver": {
|
||||||
|
"version": "7.3.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
|
||||||
|
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lru-cache": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"yallist": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"eslint-plugin-import": {
|
"eslint-plugin-import": {
|
||||||
"version": "2.26.0",
|
"version": "2.26.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
|
||||||
@ -19392,58 +19333,11 @@
|
|||||||
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
|
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"tslint": {
|
|
||||||
"version": "5.20.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz",
|
|
||||||
"integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true,
|
|
||||||
"requires": {
|
|
||||||
"@babel/code-frame": "^7.0.0",
|
|
||||||
"builtin-modules": "^1.1.1",
|
|
||||||
"chalk": "^2.3.0",
|
|
||||||
"commander": "^2.12.1",
|
|
||||||
"diff": "^4.0.1",
|
|
||||||
"glob": "^7.1.1",
|
|
||||||
"js-yaml": "^3.13.1",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"resolve": "^1.3.2",
|
|
||||||
"semver": "^5.3.0",
|
|
||||||
"tslib": "^1.8.0",
|
|
||||||
"tsutils": "^2.29.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"diff": {
|
|
||||||
"version": "4.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
|
||||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true
|
|
||||||
},
|
|
||||||
"glob": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
|
||||||
"dev": true,
|
|
||||||
"peer": true,
|
|
||||||
"requires": {
|
|
||||||
"fs.realpath": "^1.0.0",
|
|
||||||
"inflight": "^1.0.4",
|
|
||||||
"inherits": "2",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
"version": "2.29.0",
|
"version": "3.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
||||||
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "^1.8.1"
|
"tslib": "^1.8.1"
|
||||||
}
|
}
|
||||||
|
@ -73,13 +73,13 @@
|
|||||||
"@types/unzipper": "^0.10.4",
|
"@types/unzipper": "^0.10.4",
|
||||||
"@types/webpack": "^5.0.0",
|
"@types/webpack": "^5.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||||
"@typescript-eslint/eslint-plugin-tslint": "^5.36.1",
|
|
||||||
"@typescript-eslint/parser": "^5.36.1",
|
"@typescript-eslint/parser": "^5.36.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"cspell": "^6.2.2",
|
"cspell": "^6.2.2",
|
||||||
"docsify-cli": "^4.3.0",
|
"docsify-cli": "^4.3.0",
|
||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
|
"eslint-plugin-functional": "^4.3.1",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-jsdoc": "^39.3.6",
|
"eslint-plugin-jsdoc": "^39.3.6",
|
||||||
"eslint-plugin-no-null": "^1.0.2",
|
"eslint-plugin-no-null": "^1.0.2",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { IMediaData, Media } from "@file/media";
|
import { IMediaData, Media } from "@file/media";
|
||||||
|
|
||||||
export class ImageReplacer {
|
export class ImageReplacer {
|
||||||
public replace(xmlData: string, mediaData: IMediaData[], offset: number): string {
|
public replace(xmlData: string, mediaData: readonly IMediaData[], offset: number): string {
|
||||||
let currentXmlData = xmlData;
|
let currentXmlData = xmlData;
|
||||||
|
|
||||||
mediaData.forEach((image, i) => {
|
mediaData.forEach((image, i) => {
|
||||||
@ -11,7 +11,7 @@ export class ImageReplacer {
|
|||||||
return currentXmlData;
|
return currentXmlData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMediaData(xmlData: string, media: Media): IMediaData[] {
|
public getMediaData(xmlData: string, media: Media): readonly IMediaData[] {
|
||||||
return media.Array.filter((image) => xmlData.search(`{${image.fileName}}`) > 0);
|
return media.Array.filter((image) => xmlData.search(`{${image.fileName}}`) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ interface IXmlifyedFileMapping {
|
|||||||
readonly Numbering: IXmlifyedFile;
|
readonly Numbering: IXmlifyedFile;
|
||||||
readonly Relationships: IXmlifyedFile;
|
readonly Relationships: IXmlifyedFile;
|
||||||
readonly FileRelationships: IXmlifyedFile;
|
readonly FileRelationships: IXmlifyedFile;
|
||||||
readonly Headers: IXmlifyedFile[];
|
readonly Headers: readonly IXmlifyedFile[];
|
||||||
readonly Footers: IXmlifyedFile[];
|
readonly Footers: readonly IXmlifyedFile[];
|
||||||
readonly HeaderRelationships: IXmlifyedFile[];
|
readonly HeaderRelationships: readonly IXmlifyedFile[];
|
||||||
readonly FooterRelationships: IXmlifyedFile[];
|
readonly FooterRelationships: readonly IXmlifyedFile[];
|
||||||
readonly ContentTypes: IXmlifyedFile;
|
readonly ContentTypes: IXmlifyedFile;
|
||||||
readonly CustomProperties: IXmlifyedFile;
|
readonly CustomProperties: IXmlifyedFile;
|
||||||
readonly AppProperties: IXmlifyedFile;
|
readonly AppProperties: IXmlifyedFile;
|
||||||
@ -47,15 +47,15 @@ export class Compiler {
|
|||||||
public compile(file: File, prettifyXml?: boolean | PrettifyType): JSZip {
|
public compile(file: File, prettifyXml?: boolean | PrettifyType): JSZip {
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml);
|
const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml);
|
||||||
const map = new Map<string, IXmlifyedFile | IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
const map = new Map<string, IXmlifyedFile | readonly IXmlifyedFile[]>(Object.entries(xmlifiedFileMapping));
|
||||||
|
|
||||||
for (const [, obj] of map) {
|
for (const [, obj] of map) {
|
||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
for (const subFile of obj) {
|
for (const subFile of obj as readonly IXmlifyedFile[]) {
|
||||||
zip.file(subFile.path, subFile.data);
|
zip.file(subFile.path, subFile.data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
zip.file(obj.path, obj.data);
|
zip.file((obj as IXmlifyedFile).path, (obj as IXmlifyedFile).data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ConcreteNumbering } from "@file/numbering";
|
import { ConcreteNumbering } from "@file/numbering";
|
||||||
|
|
||||||
export class NumberingReplacer {
|
export class NumberingReplacer {
|
||||||
public replace(xmlData: string, concreteNumberings: ConcreteNumbering[]): string {
|
public replace(xmlData: string, concreteNumberings: readonly ConcreteNumbering[]): string {
|
||||||
let currentXmlData = xmlData;
|
let currentXmlData = xmlData;
|
||||||
|
|
||||||
for (const concreteNumbering of concreteNumberings) {
|
for (const concreteNumbering of concreteNumberings) {
|
||||||
|
@ -54,8 +54,8 @@ describe("Packer", () => {
|
|||||||
assert.isTrue(buffer.byteLength > 0);
|
assert.isTrue(buffer.byteLength > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle exception if it throws any", () => {
|
it("should handle exception if it throws any", async () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const compiler = stub((Packer as any).compiler, "compile");
|
const compiler = stub((Packer as any).compiler, "compile");
|
||||||
|
|
||||||
compiler.throwsException();
|
compiler.throwsException();
|
||||||
@ -65,7 +65,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(Packer as any).compiler.compile.restore();
|
(Packer as any).compiler.compile.restore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -80,7 +80,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should handle exception if it throws any", () => {
|
it("should handle exception if it throws any", () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const compiler = stub((Packer as any).compiler, "compile");
|
const compiler = stub((Packer as any).compiler, "compile");
|
||||||
|
|
||||||
compiler.throwsException();
|
compiler.throwsException();
|
||||||
@ -90,14 +90,14 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(Packer as any).compiler.compile.restore();
|
(Packer as any).compiler.compile.restore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#toBlob()", () => {
|
describe("#toBlob()", () => {
|
||||||
it("should create a standard docx file", async () => {
|
it("should create a standard docx file", async () => {
|
||||||
// tslint:disable-next-line: no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
stub((Packer as any).compiler, "compile").callsFake(() => ({
|
stub((Packer as any).compiler, "compile").callsFake(() => ({
|
||||||
// tslint:disable-next-line: no-empty
|
// tslint:disable-next-line: no-empty
|
||||||
generateAsync: () => mock({}),
|
generateAsync: () => mock({}),
|
||||||
@ -108,7 +108,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should handle exception if it throws any", () => {
|
it("should handle exception if it throws any", () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const compiler = stub((Packer as any).compiler, "compile");
|
const compiler = stub((Packer as any).compiler, "compile");
|
||||||
|
|
||||||
compiler.throwsException();
|
compiler.throwsException();
|
||||||
@ -118,14 +118,14 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(Packer as any).compiler.compile.restore();
|
(Packer as any).compiler.compile.restore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#toStream()", () => {
|
describe("#toStream()", () => {
|
||||||
it("should create a standard docx file", async () => {
|
it("should create a standard docx file", async () => {
|
||||||
// tslint:disable-next-line: no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
stub((Packer as any).compiler, "compile").callsFake(() => ({
|
stub((Packer as any).compiler, "compile").callsFake(() => ({
|
||||||
// tslint:disable-next-line: no-empty
|
// tslint:disable-next-line: no-empty
|
||||||
generateNodeStream: () => ({
|
generateNodeStream: () => ({
|
||||||
@ -149,7 +149,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should handle exception if it throws any", async () => {
|
it("should handle exception if it throws any", async () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const compiler = stub((Packer as any).compiler, "compile").callsFake(() => ({
|
const compiler = stub((Packer as any).compiler, "compile").callsFake(() => ({
|
||||||
// tslint:disable-next-line: no-empty
|
// tslint:disable-next-line: no-empty
|
||||||
on: (event: string, cb: () => void) => {
|
on: (event: string, cb: () => void) => {
|
||||||
@ -166,7 +166,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(Packer as any).compiler.compile.restore();
|
(Packer as any).compiler.compile.restore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { File } from "@file/file";
|
|
||||||
import { Stream } from "stream";
|
import { Stream } from "stream";
|
||||||
|
import { File } from "@file/file";
|
||||||
|
|
||||||
import { Compiler } from "./next-compiler";
|
import { Compiler } from "./next-compiler";
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import { Paragraph } from "../paragraph";
|
|||||||
import { IStylesOptions } from "../styles";
|
import { IStylesOptions } from "../styles";
|
||||||
|
|
||||||
export interface IPropertiesOptions {
|
export interface IPropertiesOptions {
|
||||||
readonly sections: ISectionOptions[];
|
readonly sections: readonly ISectionOptions[];
|
||||||
readonly title?: string;
|
readonly title?: string;
|
||||||
readonly subject?: string;
|
readonly subject?: string;
|
||||||
readonly creator?: string;
|
readonly creator?: string;
|
||||||
@ -26,7 +26,7 @@ export interface IPropertiesOptions {
|
|||||||
readonly comments?: ICommentsOptions;
|
readonly comments?: ICommentsOptions;
|
||||||
readonly footnotes?: {
|
readonly footnotes?: {
|
||||||
readonly [key: string]: {
|
readonly [key: string]: {
|
||||||
readonly children: Paragraph[];
|
readonly children: readonly Paragraph[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
readonly background?: IDocumentBackgroundOptions;
|
readonly background?: IDocumentBackgroundOptions;
|
||||||
@ -35,7 +35,7 @@ export interface IPropertiesOptions {
|
|||||||
readonly updateFields?: boolean;
|
readonly updateFields?: boolean;
|
||||||
};
|
};
|
||||||
readonly compatabilityModeVersion?: number;
|
readonly compatabilityModeVersion?: number;
|
||||||
readonly customProperties?: ICustomPropertyOptions[];
|
readonly customProperties?: readonly ICustomPropertyOptions[];
|
||||||
readonly evenAndOddHeaderAndFooters?: boolean;
|
readonly evenAndOddHeaderAndFooters?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,12 @@ import { CustomPropertiesAttributes } from "./custom-properties-attributes";
|
|||||||
import { CustomProperty, ICustomPropertyOptions } from "./custom-property";
|
import { CustomProperty, ICustomPropertyOptions } from "./custom-property";
|
||||||
|
|
||||||
export class CustomProperties extends XmlComponent {
|
export class CustomProperties extends XmlComponent {
|
||||||
// tslint:disable-next-line:readonly-keyword
|
// eslint-disable-next-line functional/prefer-readonly-type
|
||||||
private nextId: number;
|
private nextId: number;
|
||||||
|
// eslint-disable-next-line functional/prefer-readonly-type
|
||||||
private readonly properties: CustomProperty[] = [];
|
private readonly properties: CustomProperty[] = [];
|
||||||
|
|
||||||
public constructor(properties: ICustomPropertyOptions[]) {
|
public constructor(properties: readonly ICustomPropertyOptions[]) {
|
||||||
super("Properties");
|
super("Properties");
|
||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
|
@ -4,6 +4,7 @@ import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
|
|||||||
import { ISectionPropertiesOptions, SectionProperties } from "./section-properties/section-properties";
|
import { ISectionPropertiesOptions, SectionProperties } from "./section-properties/section-properties";
|
||||||
|
|
||||||
export class Body extends XmlComponent {
|
export class Body extends XmlComponent {
|
||||||
|
// eslint-disable-next-line functional/prefer-readonly-type
|
||||||
private readonly sections: SectionProperties[] = [];
|
private readonly sections: SectionProperties[] = [];
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
@ -16,6 +17,7 @@ export class Body extends XmlComponent {
|
|||||||
* The spec says:
|
* The spec says:
|
||||||
* - section element should be in the last paragraph of the section
|
* - section element should be in the last paragraph of the section
|
||||||
* - last section should be direct child of body
|
* - last section should be direct child of body
|
||||||
|
*
|
||||||
* @param options new section options
|
* @param options new section options
|
||||||
*/
|
*/
|
||||||
public addSection(options: ISectionPropertiesOptions): void {
|
public addSection(options: ISectionPropertiesOptions): void {
|
||||||
|
@ -17,7 +17,7 @@ export interface IColumnsAttributes {
|
|||||||
readonly count?: number;
|
readonly count?: number;
|
||||||
readonly separate?: boolean;
|
readonly separate?: boolean;
|
||||||
readonly equalWidth?: boolean;
|
readonly equalWidth?: boolean;
|
||||||
readonly children?: Column[];
|
readonly children?: readonly Column[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ColumnsAttributes extends XmlAttributeComponent<IColumnsAttributes> {
|
export class ColumnsAttributes extends XmlAttributeComponent<IColumnsAttributes> {
|
||||||
|
@ -6,8 +6,8 @@ import { IDrawingOptions } from "../drawing";
|
|||||||
import { TextWrappingType } from "../text-wrap";
|
import { TextWrappingType } from "../text-wrap";
|
||||||
import { Anchor } from "./anchor";
|
import { Anchor } from "./anchor";
|
||||||
|
|
||||||
const createAnchor = (drawingOptions: IDrawingOptions): Anchor => {
|
const createAnchor = (drawingOptions: IDrawingOptions): Anchor =>
|
||||||
return new Anchor(
|
new Anchor(
|
||||||
{
|
{
|
||||||
fileName: "test.png",
|
fileName: "test.png",
|
||||||
stream: new Buffer(""),
|
stream: new Buffer(""),
|
||||||
@ -34,7 +34,6 @@ const createAnchor = (drawingOptions: IDrawingOptions): Anchor => {
|
|||||||
},
|
},
|
||||||
drawingOptions,
|
drawingOptions,
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
describe("Anchor", () => {
|
describe("Anchor", () => {
|
||||||
let anchor: Anchor;
|
let anchor: Anchor;
|
||||||
|
@ -6,8 +6,8 @@ import { Drawing, IDrawingOptions } from "./drawing";
|
|||||||
|
|
||||||
const imageBase64Data = `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`;
|
const imageBase64Data = `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`;
|
||||||
|
|
||||||
const createDrawing = (drawingOptions?: IDrawingOptions): Drawing => {
|
const createDrawing = (drawingOptions?: IDrawingOptions): Drawing =>
|
||||||
return new Drawing(
|
new Drawing(
|
||||||
{
|
{
|
||||||
fileName: "test.jpg",
|
fileName: "test.jpg",
|
||||||
stream: Buffer.from(imageBase64Data, "base64"),
|
stream: Buffer.from(imageBase64Data, "base64"),
|
||||||
@ -24,7 +24,6 @@ const createDrawing = (drawingOptions?: IDrawingOptions): Drawing => {
|
|||||||
},
|
},
|
||||||
drawingOptions,
|
drawingOptions,
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
describe("Drawing", () => {
|
describe("Drawing", () => {
|
||||||
let currentBreak: Drawing;
|
let currentBreak: Drawing;
|
||||||
|
@ -33,15 +33,17 @@ export interface ISectionOptions {
|
|||||||
readonly even?: Footer;
|
readonly even?: Footer;
|
||||||
};
|
};
|
||||||
readonly properties?: ISectionPropertiesOptions;
|
readonly properties?: ISectionPropertiesOptions;
|
||||||
readonly children: (Paragraph | Table | TableOfContents)[];
|
readonly children: readonly (Paragraph | Table | TableOfContents)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class File {
|
export class File {
|
||||||
// tslint:disable-next-line:readonly-keyword
|
// eslint-disable-next-line functional/immutable-data
|
||||||
private currentRelationshipId: number = 1;
|
private currentRelationshipId: number = 1;
|
||||||
|
|
||||||
private readonly documentWrapper: DocumentWrapper;
|
private readonly documentWrapper: DocumentWrapper;
|
||||||
|
// eslint-disable-next-line functional/immutable-data
|
||||||
private readonly headers: IDocumentHeader[] = [];
|
private readonly headers: IDocumentHeader[] = [];
|
||||||
|
// eslint-disable-next-line functional/immutable-data
|
||||||
private readonly footers: IDocumentFooter[] = [];
|
private readonly footers: IDocumentFooter[] = [];
|
||||||
private readonly coreProperties: CoreProperties;
|
private readonly coreProperties: CoreProperties;
|
||||||
private readonly numbering: Numbering;
|
private readonly numbering: Numbering;
|
||||||
@ -268,11 +270,11 @@ export class File {
|
|||||||
return this.fileRelationships;
|
return this.fileRelationships;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get Headers(): HeaderWrapper[] {
|
public get Headers(): readonly HeaderWrapper[] {
|
||||||
return this.headers.map((item) => item.header);
|
return this.headers.map((item) => item.header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get Footers(): FooterWrapper[] {
|
public get Footers(): readonly FooterWrapper[] {
|
||||||
return this.footers.map((item) => item.footer);
|
return this.footers.map((item) => item.footer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ describe("FooterWrapper", () => {
|
|||||||
it("should call the underlying footer's addChildElement", () => {
|
it("should call the underlying footer's addChildElement", () => {
|
||||||
const file = new FooterWrapper(new Media(), 1);
|
const file = new FooterWrapper(new Media(), 1);
|
||||||
const spy = sinon.spy(file.View, "addChildElement");
|
const spy = sinon.spy(file.View, "addChildElement");
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
file.addChildElement({} as any);
|
file.addChildElement({} as any);
|
||||||
|
|
||||||
expect(spy.called).to.equal(true);
|
expect(spy.called).to.equal(true);
|
||||||
|
@ -12,7 +12,7 @@ export enum FootnoteType {
|
|||||||
export interface IFootnoteOptions {
|
export interface IFootnoteOptions {
|
||||||
readonly id: number;
|
readonly id: number;
|
||||||
readonly type?: FootnoteType;
|
readonly type?: FootnoteType;
|
||||||
readonly children: Paragraph[];
|
readonly children: readonly Paragraph[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Footnote extends XmlComponent {
|
export class Footnote extends XmlComponent {
|
||||||
|
@ -67,7 +67,7 @@ export class FootNotes extends XmlComponent {
|
|||||||
this.root.push(spacing);
|
this.root.push(spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createFootNote(id: number, paragraph: Paragraph[]): void {
|
public createFootNote(id: number, paragraph: readonly Paragraph[]): void {
|
||||||
const footnote = new Footnote({
|
const footnote = new Footnote({
|
||||||
id: id,
|
id: id,
|
||||||
children: paragraph,
|
children: paragraph,
|
||||||
|
@ -41,7 +41,7 @@ describe("HeaderWrapper", () => {
|
|||||||
it("should call the underlying header's addChildElement", () => {
|
it("should call the underlying header's addChildElement", () => {
|
||||||
const file = new HeaderWrapper(new Media(), 1);
|
const file = new HeaderWrapper(new Media(), 1);
|
||||||
const spy = sinon.spy(file.View, "addChildElement");
|
const spy = sinon.spy(file.View, "addChildElement");
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
file.addChildElement({} as any);
|
file.addChildElement({} as any);
|
||||||
|
|
||||||
expect(spy.called).to.equal(true);
|
expect(spy.called).to.equal(true);
|
||||||
|
@ -2,13 +2,17 @@ import { Paragraph } from "./paragraph";
|
|||||||
import { Table } from "./table";
|
import { Table } from "./table";
|
||||||
|
|
||||||
export interface IHeaderOptions {
|
export interface IHeaderOptions {
|
||||||
readonly children: (Paragraph | Table)[];
|
readonly children: readonly (Paragraph | Table)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Header {
|
export class Header {
|
||||||
public constructor(public readonly options: IHeaderOptions = { children: [] }) {}
|
public constructor(public readonly options: IHeaderOptions = { children: [] }) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Footer {
|
export class Footer {
|
||||||
public constructor(public readonly options: IHeaderOptions = { children: [] }) {}
|
public constructor(public readonly options: IHeaderOptions = { children: [] }) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ export interface IMediaTransformation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Media {
|
export class Media {
|
||||||
|
// eslint-disable-next-line functional/prefer-readonly-type
|
||||||
private readonly map: Map<string, IMediaData>;
|
private readonly map: Map<string, IMediaData>;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
@ -68,9 +69,8 @@ export class Media {
|
|||||||
.map((c) => c.charCodeAt(0)),
|
.map((c) => c.charCodeAt(0)),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
/* eslint @typescript-eslint/no-require-imports: 0 */
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||||
const b = require("buf" + "fer");
|
const b = require("buf" + "fer");
|
||||||
/* eslint @typescript-eslint/no-require-imports: 2 */
|
|
||||||
return new b.Buffer(dataURI, "base64");
|
return new b.Buffer(dataURI, "base64");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class AbstractNumberingAttributes extends XmlAttributeComponent<{
|
|||||||
export class AbstractNumbering extends XmlComponent {
|
export class AbstractNumbering extends XmlComponent {
|
||||||
public readonly id: number;
|
public readonly id: number;
|
||||||
|
|
||||||
public constructor(id: number, levelOptions: ILevelsOptions[]) {
|
public constructor(id: number, levelOptions: readonly ILevelsOptions[]) {
|
||||||
super("w:abstractNum");
|
super("w:abstractNum");
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new AbstractNumberingAttributes({
|
new AbstractNumberingAttributes({
|
||||||
|
@ -2,8 +2,8 @@ import { expect } from "chai";
|
|||||||
|
|
||||||
import { Formatter } from "@export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
|
|
||||||
import { Level, LevelFormat, LevelSuffix } from "./level";
|
|
||||||
import { AlignmentType } from "..";
|
import { AlignmentType } from "..";
|
||||||
|
import { Level, LevelFormat, LevelSuffix } from "./level";
|
||||||
|
|
||||||
describe("Level", () => {
|
describe("Level", () => {
|
||||||
describe("#constructor", () => {
|
describe("#constructor", () => {
|
||||||
|
@ -118,7 +118,7 @@ class Suffix extends XmlComponent {
|
|||||||
// http://officeopenxml.com/WPnumbering-isLgl.php
|
// http://officeopenxml.com/WPnumbering-isLgl.php
|
||||||
// https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.islegalnumberingstyle?view=openxml-2.8.1
|
// https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.islegalnumberingstyle?view=openxml-2.8.1
|
||||||
class IsLegalNumberingStyle extends XmlComponent {
|
class IsLegalNumberingStyle extends XmlComponent {
|
||||||
constructor() {
|
public constructor() {
|
||||||
super("w:isLgl");
|
super("w:isLgl");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import { ILevelsOptions, LevelFormat } from "./level";
|
|||||||
import { ConcreteNumbering } from "./num";
|
import { ConcreteNumbering } from "./num";
|
||||||
|
|
||||||
export interface INumberingOptions {
|
export interface INumberingOptions {
|
||||||
readonly config: {
|
readonly config: readonly {
|
||||||
readonly levels: ILevelsOptions[];
|
readonly levels: readonly ILevelsOptions[];
|
||||||
readonly reference: string;
|
readonly reference: string;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
@ -203,33 +203,33 @@ export class Numbering extends XmlComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const referenceConfigLevels = this.referenceConfigMap.get(reference);
|
||||||
|
const firstLevelStartNumber = referenceConfigLevels && referenceConfigLevels[0].start;
|
||||||
|
|
||||||
const concreteNumberingSettings = {
|
const concreteNumberingSettings = {
|
||||||
numId: uniqueNumericId(),
|
numId: uniqueNumericId(),
|
||||||
abstractNumId: abstractNumbering.id,
|
abstractNumId: abstractNumbering.id,
|
||||||
reference,
|
reference,
|
||||||
instance,
|
instance,
|
||||||
overrideLevel: {
|
overrideLevel:
|
||||||
num: 0,
|
firstLevelStartNumber && Number.isInteger(firstLevelStartNumber)
|
||||||
start: 1,
|
? {
|
||||||
},
|
num: 0,
|
||||||
|
start: firstLevelStartNumber,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
num: 0,
|
||||||
|
start: 1,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const referenceConfigLevels = this.referenceConfigMap.get(reference);
|
|
||||||
const firstLevelStartNumber = referenceConfigLevels && referenceConfigLevels[0].start;
|
|
||||||
if (firstLevelStartNumber && Number.isInteger(firstLevelStartNumber)) {
|
|
||||||
concreteNumberingSettings.overrideLevel = {
|
|
||||||
num: 0,
|
|
||||||
start: firstLevelStartNumber,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.concreteNumberingMap.set(fullReference, new ConcreteNumbering(concreteNumberingSettings));
|
this.concreteNumberingMap.set(fullReference, new ConcreteNumbering(concreteNumberingSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
public get ConcreteNumbering(): ConcreteNumbering[] {
|
public get ConcreteNumbering(): readonly ConcreteNumbering[] {
|
||||||
return Array.from(this.concreteNumberingMap.values());
|
return Array.from(this.concreteNumberingMap.values());
|
||||||
}
|
}
|
||||||
public get ReferenceConfig(): object[] {
|
public get ReferenceConfig(): readonly object[] {
|
||||||
return Array.from(this.referenceConfigMap.values());
|
return Array.from(this.referenceConfigMap.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ import { BookmarkEndAttributes, BookmarkStartAttributes } from "./bookmark-attri
|
|||||||
|
|
||||||
export class Bookmark {
|
export class Bookmark {
|
||||||
public readonly start: BookmarkStart;
|
public readonly start: BookmarkStart;
|
||||||
public readonly children: ParagraphChild[];
|
public readonly children: readonly ParagraphChild[];
|
||||||
public readonly end: BookmarkEnd;
|
public readonly end: BookmarkEnd;
|
||||||
|
|
||||||
public constructor(options: { readonly id: string; readonly children: ParagraphChild[] }) {
|
public constructor(options: { readonly id: string; readonly children: readonly ParagraphChild[] }) {
|
||||||
const linkId = uniqueNumericId();
|
const linkId = uniqueNumericId();
|
||||||
|
|
||||||
this.start = new BookmarkStart(options.id, linkId);
|
this.start = new BookmarkStart(options.id, linkId);
|
||||||
|
@ -13,7 +13,7 @@ export enum HyperlinkType {
|
|||||||
export class ConcreteHyperlink extends XmlComponent {
|
export class ConcreteHyperlink extends XmlComponent {
|
||||||
public readonly linkId: string;
|
public readonly linkId: string;
|
||||||
|
|
||||||
public constructor(children: ParagraphChild[], relationshipId: string, anchor?: string) {
|
public constructor(children: readonly ParagraphChild[], relationshipId: string, anchor?: string) {
|
||||||
super("w:hyperlink");
|
super("w:hyperlink");
|
||||||
|
|
||||||
this.linkId = relationshipId;
|
this.linkId = relationshipId;
|
||||||
@ -33,13 +33,13 @@ export class ConcreteHyperlink extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class InternalHyperlink extends ConcreteHyperlink {
|
export class InternalHyperlink extends ConcreteHyperlink {
|
||||||
public constructor(options: { readonly children: ParagraphChild[]; readonly anchor: string }) {
|
public constructor(options: { readonly children: readonly ParagraphChild[]; readonly anchor: string }) {
|
||||||
super(options.children, uniqueId(), options.anchor);
|
super(options.children, uniqueId(), options.anchor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExternalHyperlink extends XmlComponent {
|
export class ExternalHyperlink extends XmlComponent {
|
||||||
public constructor(public readonly options: { readonly children: ParagraphChild[]; readonly link: string }) {
|
public constructor(public readonly options: { readonly children: readonly ParagraphChild[]; readonly link: string }) {
|
||||||
super("w:externalHyperlink");
|
super("w:externalHyperlink");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
|
|||||||
import { MathBracketProperties } from "./math-bracket-properties";
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
export class MathAngledBrackets extends XmlComponent {
|
export class MathAngledBrackets extends XmlComponent {
|
||||||
public constructor(options: { readonly children: MathComponent[] }) {
|
public constructor(options: { readonly children: readonly MathComponent[] }) {
|
||||||
super("m:d");
|
super("m:d");
|
||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
|
@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
|
|||||||
import { MathBracketProperties } from "./math-bracket-properties";
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
export class MathCurlyBrackets extends XmlComponent {
|
export class MathCurlyBrackets extends XmlComponent {
|
||||||
public constructor(options: { readonly children: MathComponent[] }) {
|
public constructor(options: { readonly children: readonly MathComponent[] }) {
|
||||||
super("m:d");
|
super("m:d");
|
||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
|
@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
|
|||||||
import { MathBracketProperties } from "./math-bracket-properties";
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
export class MathRoundBrackets extends XmlComponent {
|
export class MathRoundBrackets extends XmlComponent {
|
||||||
public constructor(options: { readonly children: MathComponent[] }) {
|
public constructor(options: { readonly children: readonly MathComponent[] }) {
|
||||||
super("m:d");
|
super("m:d");
|
||||||
|
|
||||||
this.root.push(new MathBracketProperties());
|
this.root.push(new MathBracketProperties());
|
||||||
|
@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
|
|||||||
import { MathBracketProperties } from "./math-bracket-properties";
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
export class MathSquareBrackets extends XmlComponent {
|
export class MathSquareBrackets extends XmlComponent {
|
||||||
public constructor(options: { readonly children: MathComponent[] }) {
|
public constructor(options: { readonly children: readonly MathComponent[] }) {
|
||||||
super("m:d");
|
super("m:d");
|
||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
|
@ -3,7 +3,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathDenominator extends XmlComponent {
|
export class MathDenominator extends XmlComponent {
|
||||||
public constructor(children: MathComponent[]) {
|
public constructor(children: readonly MathComponent[]) {
|
||||||
super("m:den");
|
super("m:den");
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -5,8 +5,8 @@ import { MathDenominator } from "./math-denominator";
|
|||||||
import { MathNumerator } from "./math-numerator";
|
import { MathNumerator } from "./math-numerator";
|
||||||
|
|
||||||
export interface IMathFractionOptions {
|
export interface IMathFractionOptions {
|
||||||
readonly numerator: MathComponent[];
|
readonly numerator: readonly MathComponent[];
|
||||||
readonly denominator: MathComponent[];
|
readonly denominator: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathFraction extends XmlComponent {
|
export class MathFraction extends XmlComponent {
|
||||||
|
@ -3,7 +3,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathNumerator extends XmlComponent {
|
export class MathNumerator extends XmlComponent {
|
||||||
public constructor(children: MathComponent[]) {
|
public constructor(children: readonly MathComponent[]) {
|
||||||
super("m:num");
|
super("m:num");
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -3,7 +3,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathFunctionName extends XmlComponent {
|
export class MathFunctionName extends XmlComponent {
|
||||||
public constructor(children: MathComponent[]) {
|
public constructor(children: readonly MathComponent[]) {
|
||||||
super("m:fName");
|
super("m:fName");
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -7,8 +7,8 @@ import { MathFunctionName } from "./math-function-name";
|
|||||||
import { MathFunctionProperties } from "./math-function-properties";
|
import { MathFunctionProperties } from "./math-function-properties";
|
||||||
|
|
||||||
export interface IMathFunctionOptions {
|
export interface IMathFunctionOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly name: MathComponent[];
|
readonly name: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathFunction extends XmlComponent {
|
export class MathFunction extends XmlComponent {
|
||||||
|
@ -4,7 +4,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "./math-component";
|
import { MathComponent } from "./math-component";
|
||||||
|
|
||||||
export interface IMathOptions {
|
export interface IMathOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Math extends XmlComponent {
|
export class Math extends XmlComponent {
|
||||||
|
@ -4,7 +4,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathBase extends XmlComponent {
|
export class MathBase extends XmlComponent {
|
||||||
public constructor(children: MathComponent[]) {
|
public constructor(children: readonly MathComponent[]) {
|
||||||
super("m:e");
|
super("m:e");
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -4,7 +4,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathSubScriptElement extends XmlComponent {
|
export class MathSubScriptElement extends XmlComponent {
|
||||||
public constructor(children: MathComponent[]) {
|
public constructor(children: readonly MathComponent[]) {
|
||||||
super("m:sub");
|
super("m:sub");
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -8,9 +8,9 @@ import { MathSubScriptElement } from "./math-sub-script";
|
|||||||
import { MathSuperScriptElement } from "./math-super-script";
|
import { MathSuperScriptElement } from "./math-super-script";
|
||||||
|
|
||||||
export interface IMathSumOptions {
|
export interface IMathSumOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly subScript?: MathComponent[];
|
readonly subScript?: readonly MathComponent[];
|
||||||
readonly superScript?: MathComponent[];
|
readonly superScript?: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathSum extends XmlComponent {
|
export class MathSum extends XmlComponent {
|
||||||
|
@ -4,7 +4,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathSuperScriptElement extends XmlComponent {
|
export class MathSuperScriptElement extends XmlComponent {
|
||||||
public constructor(children: MathComponent[]) {
|
public constructor(children: readonly MathComponent[]) {
|
||||||
super("m:sup");
|
super("m:sup");
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -3,7 +3,7 @@ import { XmlComponent } from "@file/xml-components";
|
|||||||
import { MathComponent } from "../math-component";
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
export class MathDegree extends XmlComponent {
|
export class MathDegree extends XmlComponent {
|
||||||
public constructor(children?: MathComponent[]) {
|
public constructor(children?: readonly MathComponent[]) {
|
||||||
super("m:deg");
|
super("m:deg");
|
||||||
|
|
||||||
if (!!children) {
|
if (!!children) {
|
||||||
|
@ -7,8 +7,8 @@ import { MathDegree } from "./math-degree";
|
|||||||
import { MathRadicalProperties } from "./math-radical-properties";
|
import { MathRadicalProperties } from "./math-radical-properties";
|
||||||
|
|
||||||
export interface IMathRadicalOptions {
|
export interface IMathRadicalOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly degree?: MathComponent[];
|
readonly degree?: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathRadical extends XmlComponent {
|
export class MathRadical extends XmlComponent {
|
||||||
|
@ -6,9 +6,9 @@ import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-
|
|||||||
import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties";
|
import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties";
|
||||||
|
|
||||||
export interface IMathPreSubSuperScriptOptions {
|
export interface IMathPreSubSuperScriptOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly subScript: MathComponent[];
|
readonly subScript: readonly MathComponent[];
|
||||||
readonly superScript: MathComponent[];
|
readonly superScript: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathPreSubSuperScript extends XmlComponent {
|
export class MathPreSubSuperScript extends XmlComponent {
|
||||||
|
@ -6,8 +6,8 @@ import { MathBase, MathSubScriptElement } from "../../n-ary";
|
|||||||
import { MathSubScriptProperties } from "./math-sub-script-function-properties";
|
import { MathSubScriptProperties } from "./math-sub-script-function-properties";
|
||||||
|
|
||||||
export interface IMathSubScriptOptions {
|
export interface IMathSubScriptOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly subScript: MathComponent[];
|
readonly subScript: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathSubScript extends XmlComponent {
|
export class MathSubScript extends XmlComponent {
|
||||||
|
@ -6,9 +6,9 @@ import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-
|
|||||||
import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties";
|
import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties";
|
||||||
|
|
||||||
export interface IMathSubSuperScriptOptions {
|
export interface IMathSubSuperScriptOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly subScript: MathComponent[];
|
readonly subScript: readonly MathComponent[];
|
||||||
readonly superScript: MathComponent[];
|
readonly superScript: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathSubSuperScript extends XmlComponent {
|
export class MathSubSuperScript extends XmlComponent {
|
||||||
|
@ -6,8 +6,8 @@ import { MathBase, MathSuperScriptElement } from "../../n-ary";
|
|||||||
import { MathSuperScriptProperties } from "./math-super-script-function-properties";
|
import { MathSuperScriptProperties } from "./math-super-script-function-properties";
|
||||||
|
|
||||||
export interface IMathSuperScriptOptions {
|
export interface IMathSuperScriptOptions {
|
||||||
readonly children: MathComponent[];
|
readonly children: readonly MathComponent[];
|
||||||
readonly superScript: MathComponent[];
|
readonly superScript: readonly MathComponent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MathSuperScript extends XmlComponent {
|
export class MathSuperScript extends XmlComponent {
|
||||||
|
@ -36,7 +36,7 @@ export type ParagraphChild =
|
|||||||
|
|
||||||
export interface IParagraphOptions extends IParagraphPropertiesOptions {
|
export interface IParagraphOptions extends IParagraphPropertiesOptions {
|
||||||
readonly text?: string;
|
readonly text?: string;
|
||||||
readonly children?: ParagraphChild[];
|
readonly children?: readonly ParagraphChild[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Paragraph extends XmlComponent {
|
export class Paragraph extends XmlComponent {
|
||||||
|
@ -26,9 +26,7 @@ describe("ParagraphProperties", () => {
|
|||||||
// tslint:disable-next-line: no-object-literal-type-assertion
|
// tslint:disable-next-line: no-object-literal-type-assertion
|
||||||
file: {
|
file: {
|
||||||
Numbering: {
|
Numbering: {
|
||||||
createConcreteNumberingInstance: (_: string, __: number) => {
|
createConcreteNumberingInstance: (_: string, __: number) => undefined,
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
} as File,
|
} as File,
|
||||||
// tslint:disable-next-line: no-object-literal-type-assertion
|
// tslint:disable-next-line: no-object-literal-type-assertion
|
||||||
|
@ -41,7 +41,7 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
|
|||||||
readonly heading?: HeadingLevel;
|
readonly heading?: HeadingLevel;
|
||||||
readonly bidirectional?: boolean;
|
readonly bidirectional?: boolean;
|
||||||
readonly pageBreakBefore?: boolean;
|
readonly pageBreakBefore?: boolean;
|
||||||
readonly tabStops?: {
|
readonly tabStops?: readonly {
|
||||||
readonly position: number | TabStopPosition;
|
readonly position: number | TabStopPosition;
|
||||||
readonly type: TabStopType;
|
readonly type: TabStopType;
|
||||||
readonly leader?: LeaderType;
|
readonly leader?: LeaderType;
|
||||||
@ -57,6 +57,7 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
|
export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
|
||||||
|
// eslint-disable-next-line functional/prefer-readonly-type
|
||||||
private readonly numberingReferences: { readonly reference: string; readonly instance: number }[] = [];
|
private readonly numberingReferences: { readonly reference: string; readonly instance: number }[] = [];
|
||||||
|
|
||||||
public constructor(options?: IParagraphPropertiesOptions) {
|
public constructor(options?: IParagraphPropertiesOptions) {
|
||||||
|
@ -12,7 +12,7 @@ export interface ICommentOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ICommentsOptions {
|
export interface ICommentsOptions {
|
||||||
readonly children: ICommentOptions[];
|
readonly children: readonly ICommentOptions[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommentAttributes extends XmlAttributeComponent<{
|
class CommentAttributes extends XmlAttributeComponent<{
|
||||||
|
@ -40,7 +40,7 @@ describe("ImageRun", () => {
|
|||||||
const tree = new Formatter().format(currentImageRun, {
|
const tree = new Formatter().format(currentImageRun, {
|
||||||
file: {
|
file: {
|
||||||
Media: {
|
Media: {
|
||||||
// tslint:disable-next-line: no-empty
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
addImage: () => {},
|
addImage: () => {},
|
||||||
},
|
},
|
||||||
} as unknown as File,
|
} as unknown as File,
|
||||||
@ -290,7 +290,7 @@ describe("ImageRun", () => {
|
|||||||
const tree = new Formatter().format(currentImageRun, {
|
const tree = new Formatter().format(currentImageRun, {
|
||||||
file: {
|
file: {
|
||||||
Media: {
|
Media: {
|
||||||
// tslint:disable-next-line: no-empty
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
addImage: () => {},
|
addImage: () => {},
|
||||||
},
|
},
|
||||||
} as unknown as File,
|
} as unknown as File,
|
||||||
@ -519,6 +519,7 @@ describe("ImageRun", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return UInt8Array if atob is present", () => {
|
it("should return UInt8Array if atob is present", () => {
|
||||||
|
// eslint-disable-next-line functional/immutable-data
|
||||||
global.atob = () => "atob result";
|
global.atob = () => "atob result";
|
||||||
|
|
||||||
const currentImageRun = new ImageRun({
|
const currentImageRun = new ImageRun({
|
||||||
@ -542,7 +543,7 @@ describe("ImageRun", () => {
|
|||||||
const tree = new Formatter().format(currentImageRun, {
|
const tree = new Formatter().format(currentImageRun, {
|
||||||
file: {
|
file: {
|
||||||
Media: {
|
Media: {
|
||||||
// tslint:disable-next-line: no-empty
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
addImage: () => {},
|
addImage: () => {},
|
||||||
},
|
},
|
||||||
} as unknown as File,
|
} as unknown as File,
|
||||||
@ -775,6 +776,7 @@ describe("ImageRun", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should use data as is if its not a string", () => {
|
it("should use data as is if its not a string", () => {
|
||||||
|
// eslint-disable-next-line functional/immutable-data
|
||||||
global.atob = () => "atob result";
|
global.atob = () => "atob result";
|
||||||
|
|
||||||
const currentImageRun = new ImageRun({
|
const currentImageRun = new ImageRun({
|
||||||
@ -798,7 +800,7 @@ describe("ImageRun", () => {
|
|||||||
const tree = new Formatter().format(currentImageRun, {
|
const tree = new Formatter().format(currentImageRun, {
|
||||||
file: {
|
file: {
|
||||||
Media: {
|
Media: {
|
||||||
// tslint:disable-next-line: no-empty
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
addImage: () => {},
|
addImage: () => {},
|
||||||
},
|
},
|
||||||
} as unknown as File,
|
} as unknown as File,
|
||||||
|
@ -62,6 +62,7 @@ export class ImageRun extends Run {
|
|||||||
.map((c) => c.charCodeAt(0)),
|
.map((c) => c.charCodeAt(0)),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||||
const b = require("buf" + "fer");
|
const b = require("buf" + "fer");
|
||||||
return new b.Buffer(dataURI, "base64");
|
return new b.Buffer(dataURI, "base64");
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import { Text } from "./run-components/text";
|
|||||||
import { TextAttributes } from "./text-attributes";
|
import { TextAttributes } from "./text-attributes";
|
||||||
|
|
||||||
export interface IRunOptions extends IRunPropertiesOptions {
|
export interface IRunOptions extends IRunPropertiesOptions {
|
||||||
readonly children?: (Begin | FieldInstruction | Separate | End | PageNumber | FootnoteReferenceRun | string)[];
|
readonly children?: readonly (Begin | FieldInstruction | Separate | End | PageNumber | FootnoteReferenceRun | string)[];
|
||||||
readonly break?: number;
|
readonly break?: number;
|
||||||
readonly text?: string;
|
readonly text?: string;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ describe("External styles factory", () => {
|
|||||||
|
|
||||||
describe("#parse", () => {
|
describe("#parse", () => {
|
||||||
it("should parse w:styles attributes", () => {
|
it("should parse w:styles attributes", () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
|
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
|
||||||
|
|
||||||
expect(importedStyle.rootKey).to.equal("w:styles");
|
expect(importedStyle.rootKey).to.equal("w:styles");
|
||||||
@ -59,7 +59,7 @@ describe("External styles factory", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should parse other child elements of w:styles", () => {
|
it("should parse other child elements of w:styles", () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
|
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
|
||||||
expect(importedStyle.root[1]).to.deep.equal({
|
expect(importedStyle.root[1]).to.deep.equal({
|
||||||
root: [
|
root: [
|
||||||
@ -147,7 +147,7 @@ describe("External styles factory", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should parse styles elements", () => {
|
it("should parse styles elements", () => {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
|
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
|
||||||
|
|
||||||
expect(importedStyle.root.length).to.equal(5);
|
expect(importedStyle.root.length).to.equal(5);
|
||||||
|
@ -23,6 +23,7 @@ export class ExternalStylesFactory {
|
|||||||
* <w:docDefaults>Or any other element will be parsed to</w:docDefaults>
|
* <w:docDefaults>Or any other element will be parsed to</w:docDefaults>
|
||||||
*
|
*
|
||||||
* </w:styles>
|
* </w:styles>
|
||||||
|
*
|
||||||
* @param externalStyles context from styles.xml
|
* @param externalStyles context from styles.xml
|
||||||
*/
|
*/
|
||||||
public newInstance(xmlData: string): Styles {
|
public newInstance(xmlData: string): Styles {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const createLsdException = (name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) => {
|
const createLsdException = (name: string, uiPriority?: number, qFormat?: number, semiHidden?: number, unhideWhenUsed?: number) => {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -14,8 +14,9 @@ const createLsdException = (name, uiPriority, qFormat?, semiHidden?, unhideWhenU
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DefaultStyle = () => {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
var style = {
|
export const DefaultStyle = (): Record<string, any> => {
|
||||||
|
const style = {
|
||||||
"w:styles": [
|
"w:styles": [
|
||||||
{
|
{
|
||||||
_attr: {
|
_attr: {
|
||||||
|
@ -7,9 +7,9 @@ import { IParagraphStyleOptions } from "./style/paragraph-style";
|
|||||||
export interface IStylesOptions {
|
export interface IStylesOptions {
|
||||||
readonly default?: IDefaultStylesOptions;
|
readonly default?: IDefaultStylesOptions;
|
||||||
readonly initialStyles?: BaseXmlComponent;
|
readonly initialStyles?: BaseXmlComponent;
|
||||||
readonly paragraphStyles?: IParagraphStyleOptions[];
|
readonly paragraphStyles?: readonly IParagraphStyleOptions[];
|
||||||
readonly characterStyles?: ICharacterStyleOptions[];
|
readonly characterStyles?: readonly ICharacterStyleOptions[];
|
||||||
readonly importedStyles?: (XmlComponent | StyleForParagraph | StyleForCharacter | ImportedXmlComponent)[];
|
readonly importedStyles?: readonly (XmlComponent | StyleForParagraph | StyleForCharacter | ImportedXmlComponent)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// <xsd:complexType name="CT_Styles">
|
// <xsd:complexType name="CT_Styles">
|
||||||
|
@ -98,7 +98,7 @@ export interface ITableOfContentsOptions {
|
|||||||
* with each doublet being a comma-separated set of style name and table of content level.
|
* with each doublet being a comma-separated set of style name and table of content level.
|
||||||
* \t can be combined with \o.
|
* \t can be combined with \o.
|
||||||
*/
|
*/
|
||||||
readonly stylesWithLevels?: StyleLevel[];
|
readonly stylesWithLevels?: readonly StyleLevel[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \u Uses the applied paragraph outline level.
|
* \u Uses the applied paragraph outline level.
|
||||||
|
@ -14,9 +14,7 @@ describe("Table of Contents", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should construct a TOC with all the options and alias", () => {
|
it("should construct a TOC with all the options and alias", () => {
|
||||||
const styles = new Array<StyleLevel>();
|
const styles = [new StyleLevel("SL", 1), new StyleLevel("SL", 2)];
|
||||||
styles.push(new StyleLevel("SL", 1));
|
|
||||||
styles.push(new StyleLevel("SL", 2));
|
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
captionLabel: "A",
|
captionLabel: "A",
|
||||||
|
@ -13,7 +13,7 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|||||||
import { twipsMeasureValue } from "@util/values";
|
import { twipsMeasureValue } from "@util/values";
|
||||||
|
|
||||||
export class TableGrid extends XmlComponent {
|
export class TableGrid extends XmlComponent {
|
||||||
public constructor(widths: number[] | string[]) {
|
public constructor(widths: readonly number[] | readonly string[]) {
|
||||||
super("w:tblGrid");
|
super("w:tblGrid");
|
||||||
for (const width of widths) {
|
for (const width of widths) {
|
||||||
this.root.push(new GridCol(width));
|
this.root.push(new GridCol(width));
|
||||||
|
@ -6,7 +6,7 @@ import { Table } from "../table";
|
|||||||
import { ITableCellPropertiesOptions, TableCellProperties } from "./table-cell-properties";
|
import { ITableCellPropertiesOptions, TableCellProperties } from "./table-cell-properties";
|
||||||
|
|
||||||
export interface ITableCellOptions extends ITableCellPropertiesOptions {
|
export interface ITableCellOptions extends ITableCellPropertiesOptions {
|
||||||
readonly children: (Paragraph | Table)[];
|
readonly children: readonly (Paragraph | Table)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TableCell extends XmlComponent {
|
export class TableCell extends XmlComponent {
|
||||||
|
@ -3,7 +3,7 @@ import { TableCell } from "../table-cell";
|
|||||||
import { ITableRowPropertiesOptions, TableRowProperties } from "./table-row-properties";
|
import { ITableRowPropertiesOptions, TableRowProperties } from "./table-row-properties";
|
||||||
|
|
||||||
export interface ITableRowOptions extends ITableRowPropertiesOptions {
|
export interface ITableRowOptions extends ITableRowPropertiesOptions {
|
||||||
readonly children: TableCell[];
|
readonly children: readonly TableCell[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TableRow extends XmlComponent {
|
export class TableRow extends XmlComponent {
|
||||||
@ -20,7 +20,7 @@ export class TableRow extends XmlComponent {
|
|||||||
return this.options.children.length;
|
return this.options.children.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get cells(): TableCell[] {
|
public get cells(): readonly TableCell[] {
|
||||||
return this.root.filter((xmlComponent) => xmlComponent instanceof TableCell);
|
return this.root.filter((xmlComponent) => xmlComponent instanceof TableCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import { ITableWidthProperties } from "./table-width";
|
|||||||
algorithm will expand columns to fit its content
|
algorithm will expand columns to fit its content
|
||||||
*/
|
*/
|
||||||
export interface ITableOptions {
|
export interface ITableOptions {
|
||||||
readonly rows: TableRow[];
|
readonly rows: readonly TableRow[];
|
||||||
readonly width?: ITableWidthProperties;
|
readonly width?: ITableWidthProperties;
|
||||||
readonly columnWidths?: number[];
|
readonly columnWidths?: readonly number[];
|
||||||
readonly margins?: ITableCellMarginOptions;
|
readonly margins?: ITableCellMarginOptions;
|
||||||
readonly indent?: ITableWidthProperties;
|
readonly indent?: ITableWidthProperties;
|
||||||
readonly float?: ITableFloatOptions;
|
readonly float?: ITableFloatOptions;
|
||||||
@ -38,6 +38,7 @@ export class Table extends XmlComponent {
|
|||||||
public constructor({
|
public constructor({
|
||||||
rows,
|
rows,
|
||||||
width,
|
width,
|
||||||
|
// eslint-disable-next-line functional/immutable-data
|
||||||
columnWidths = Array<number>(Math.max(...rows.map((row) => row.CellCount))).fill(100),
|
columnWidths = Array<number>(Math.max(...rows.map((row) => row.CellCount))).fill(100),
|
||||||
margins,
|
margins,
|
||||||
indent,
|
indent,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { BaseXmlComponent, IContext } from "./base";
|
import { BaseXmlComponent, IContext } from "./base";
|
||||||
import { IXmlableObject } from "./xmlable-object";
|
import { IXmlableObject } from "./xmlable-object";
|
||||||
|
|
||||||
export type AttributeMap<T> = { [P in keyof T]: string };
|
export type AttributeMap<T> = { readonly [P in keyof T]: string };
|
||||||
|
|
||||||
export abstract class XmlAttributeComponent<T> extends BaseXmlComponent {
|
export abstract class XmlAttributeComponent<T extends object> extends BaseXmlComponent {
|
||||||
// tslint:disable-next-line:readonly-keyword
|
// tslint:disable-next-line:readonly-keyword
|
||||||
protected root: T;
|
protected readonly root: T;
|
||||||
protected readonly xmlKeys?: AttributeMap<T>;
|
protected readonly xmlKeys?: AttributeMap<T>;
|
||||||
|
|
||||||
public constructor(properties: T) {
|
public constructor(properties: T) {
|
||||||
@ -19,6 +19,7 @@ export abstract class XmlAttributeComponent<T> extends BaseXmlComponent {
|
|||||||
const value = this.root[key];
|
const value = this.root[key];
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
const newKey = (this.xmlKeys && this.xmlKeys[key]) || key;
|
const newKey = (this.xmlKeys && this.xmlKeys[key]) || key;
|
||||||
|
// eslint-disable-next-line functional/immutable-data
|
||||||
attrs[newKey] = value;
|
attrs[newKey] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// tslint:disable:no-any
|
// eslint-disable @typescript-eslint/no-explicit-any
|
||||||
import { Element as XmlElement, xml2js } from "xml-js";
|
import { Element as XmlElement, xml2js } from "xml-js";
|
||||||
|
|
||||||
import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
@ -7,6 +7,7 @@ import { IContext } from "./base";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the given xml element (in json format) into XmlComponent.
|
* Converts the given xml element (in json format) into XmlComponent.
|
||||||
|
*
|
||||||
* @param element the xml element in json presentation
|
* @param element the xml element in json presentation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { IXmlableObject } from "./xmlable-object";
|
|||||||
export const EMPTY_OBJECT = Object.seal({});
|
export const EMPTY_OBJECT = Object.seal({});
|
||||||
|
|
||||||
export abstract class XmlComponent extends BaseXmlComponent {
|
export abstract class XmlComponent extends BaseXmlComponent {
|
||||||
// tslint:disable-next-line:readonly-keyword no-any
|
// eslint-disable-next-line functional/prefer-readonly-type, @typescript-eslint/no-explicit-any
|
||||||
protected root: (BaseXmlComponent | string | any)[];
|
protected root: (BaseXmlComponent | string | any)[];
|
||||||
|
|
||||||
public constructor(rootKey: string) {
|
public constructor(rootKey: string) {
|
||||||
@ -46,5 +46,7 @@ export abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {
|
|||||||
if (result && (typeof result[this.rootKey] !== "object" || Object.keys(result[this.rootKey]).length)) {
|
if (result && (typeof result[this.rootKey] !== "object" || Object.keys(result[this.rootKey]).length)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export class Utility {
|
export class Utility {
|
||||||
// tslint:disable-next-line:no-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
public static jsonify(obj: object): any {
|
public static jsonify(obj: object): any {
|
||||||
const stringifiedJson = JSON.stringify(obj);
|
const stringifiedJson = JSON.stringify(obj);
|
||||||
return JSON.parse(stringifiedJson);
|
return JSON.parse(stringifiedJson);
|
||||||
|
@ -43,27 +43,21 @@ const hexBinary = (val: string, length: number): string => {
|
|||||||
// <xsd:length value="4"/>
|
// <xsd:length value="4"/>
|
||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const longHexNumber = (val: string): string => {
|
export const longHexNumber = (val: string): string => hexBinary(val, 4);
|
||||||
return hexBinary(val, 4);
|
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_ShortHexNumber">
|
// <xsd:simpleType name="ST_ShortHexNumber">
|
||||||
// <xsd:restriction base="xsd:hexBinary">
|
// <xsd:restriction base="xsd:hexBinary">
|
||||||
// <xsd:length value="2"/>
|
// <xsd:length value="2"/>
|
||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const shortHexNumber = (val: string): string => {
|
export const shortHexNumber = (val: string): string => hexBinary(val, 2);
|
||||||
return hexBinary(val, 2);
|
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_UcharHexNumber">
|
// <xsd:simpleType name="ST_UcharHexNumber">
|
||||||
// <xsd:restriction base="xsd:hexBinary">
|
// <xsd:restriction base="xsd:hexBinary">
|
||||||
// <xsd:length value="1"/>
|
// <xsd:length value="1"/>
|
||||||
// </xsd:restriction>
|
// </xsd:restriction>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const uCharHexNumber = (val: string): string => {
|
export const uCharHexNumber = (val: string): string => hexBinary(val, 1);
|
||||||
return hexBinary(val, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_LongHexNumber">
|
// <xsd:simpleType name="ST_LongHexNumber">
|
||||||
// <xsd:restriction base="xsd:hexBinary">
|
// <xsd:restriction base="xsd:hexBinary">
|
||||||
@ -129,30 +123,26 @@ export const hexColorValue = (val: string): string => {
|
|||||||
// <xsd:simpleType name="ST_SignedTwipsMeasure">
|
// <xsd:simpleType name="ST_SignedTwipsMeasure">
|
||||||
// <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/>
|
// <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const signedTwipsMeasureValue = (val: string | number): string | number => {
|
export const signedTwipsMeasureValue = (val: string | number): string | number =>
|
||||||
return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
|
typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_HpsMeasure">
|
// <xsd:simpleType name="ST_HpsMeasure">
|
||||||
// <xsd:union memberTypes="s:ST_UnsignedDecimalNumber s:ST_PositiveUniversalMeasure"/>
|
// <xsd:union memberTypes="s:ST_UnsignedDecimalNumber s:ST_PositiveUniversalMeasure"/>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const hpsMeasureValue = (val: string | number): string | number => {
|
export const hpsMeasureValue = (val: string | number): string | number =>
|
||||||
return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
|
typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_SignedHpsMeasure">
|
// <xsd:simpleType name="ST_SignedHpsMeasure">
|
||||||
// <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/>
|
// <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const signedHpsMeasureValue = (val: string | number): string | number => {
|
export const signedHpsMeasureValue = (val: string | number): string | number =>
|
||||||
return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
|
typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_TwipsMeasure">
|
// <xsd:simpleType name="ST_TwipsMeasure">
|
||||||
// <xsd:union memberTypes="ST_UnsignedDecimalNumber ST_PositiveUniversalMeasure"/>
|
// <xsd:union memberTypes="ST_UnsignedDecimalNumber ST_PositiveUniversalMeasure"/>
|
||||||
// </xsd:simpleType>
|
// </xsd:simpleType>
|
||||||
export const twipsMeasureValue = (val: string | number): string | number => {
|
export const twipsMeasureValue = (val: string | number): string | number =>
|
||||||
return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
|
typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
|
||||||
};
|
|
||||||
|
|
||||||
// <xsd:simpleType name="ST_Percentage">
|
// <xsd:simpleType name="ST_Percentage">
|
||||||
// <xsd:restriction base="xsd:string">
|
// <xsd:restriction base="xsd:string">
|
||||||
@ -222,6 +212,4 @@ export const pointMeasureValue = unsignedDecimalNumber;
|
|||||||
//
|
//
|
||||||
// Luckily, js has this format built in already. See:
|
// Luckily, js has this format built in already. See:
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
||||||
export const dateTimeValue = (val: Date): string => {
|
export const dateTimeValue = (val: Date): string => val.toISOString();
|
||||||
return val.toISOString();
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user