Compare commits
1 Commits
8.1.0
...
feature/pa
Author | SHA1 | Date | |
---|---|---|---|
c5a2c1c0cb |
50
.cspell.json
50
.cspell.json
@ -7,35 +7,31 @@
|
|||||||
"dictionaries": ["en_US", "typescript", "softwareTerms", "fonts", "npm"],
|
"dictionaries": ["en_US", "typescript", "softwareTerms", "fonts", "npm"],
|
||||||
// words - list of words to be always considered correct
|
// words - list of words to be always considered correct
|
||||||
"words": [
|
"words": [
|
||||||
"Abjad",
|
"Xmlable",
|
||||||
"aiueo",
|
|
||||||
"ATLEAST",
|
|
||||||
"chosung",
|
|
||||||
"clippy",
|
|
||||||
"datas",
|
|
||||||
"docsify",
|
|
||||||
"dolan",
|
|
||||||
"execa",
|
|
||||||
"falsey",
|
|
||||||
"iife",
|
|
||||||
"Initializable",
|
|
||||||
"iroha",
|
|
||||||
"jsonify",
|
|
||||||
"jszip",
|
|
||||||
"NUMPAGES",
|
|
||||||
"odttf",
|
|
||||||
"ondata",
|
|
||||||
"onfile",
|
|
||||||
"ooxml",
|
|
||||||
"panose",
|
|
||||||
"rels",
|
|
||||||
"rsid",
|
|
||||||
"twip",
|
"twip",
|
||||||
"twips",
|
"twips",
|
||||||
"Xmlable",
|
"jsonify",
|
||||||
"xmlified",
|
"falsey",
|
||||||
|
"aiueo",
|
||||||
|
"iroha",
|
||||||
|
"aiueo",
|
||||||
|
"iroha",
|
||||||
|
"chosung",
|
||||||
|
"Abjad",
|
||||||
|
"Initializable",
|
||||||
|
"rels",
|
||||||
|
"dolan",
|
||||||
"xmlify",
|
"xmlify",
|
||||||
"Xmlifyed"
|
"Xmlifyed",
|
||||||
|
"xmlified",
|
||||||
|
"datas",
|
||||||
|
"jszip",
|
||||||
|
"rsid",
|
||||||
|
"NUMPAGES",
|
||||||
|
"ATLEAST",
|
||||||
|
"ooxml",
|
||||||
|
"clippy",
|
||||||
|
"docsify"
|
||||||
],
|
],
|
||||||
"ignoreRegExpList": [
|
"ignoreRegExpList": [
|
||||||
"/\"w:.+\"/",
|
"/\"w:.+\"/",
|
||||||
@ -55,7 +51,7 @@
|
|||||||
"/<element name=\"[a-z]+\"/gi",
|
"/<element name=\"[a-z]+\"/gi",
|
||||||
"/<attribute name=\"[a-z]+\"/gi"
|
"/<attribute name=\"[a-z]+\"/gi"
|
||||||
],
|
],
|
||||||
"ignorePaths": ["package.json", "docs/api", "*.docx", "build"],
|
"ignorePaths": ["package.json", "docs/api"],
|
||||||
"allowCompoundWords": true,
|
"allowCompoundWords": true,
|
||||||
// flagWords - list of words to be always considered incorrect
|
// flagWords - list of words to be always considered incorrect
|
||||||
// This is useful for offensive words and common spelling errors.
|
// This is useful for offensive words and common spelling errors.
|
||||||
|
272
.eslintrc.js
Normal file
272
.eslintrc.js
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
/*
|
||||||
|
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
|
||||||
|
https://github.com/typescript-eslint/tslint-to-eslint-config
|
||||||
|
|
||||||
|
It represents the closest reasonable ESLint configuration to this
|
||||||
|
project's original TSLint configuration.
|
||||||
|
|
||||||
|
We recommend eventually switching this configuration to extend from
|
||||||
|
the recommended rulesets in typescript-eslint.
|
||||||
|
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
|
||||||
|
|
||||||
|
Happy linting! 💖
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
extends: "eslint:recommended",
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es6: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
parserOptions: {
|
||||||
|
project: "tsconfig.json",
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
"eslint-plugin-import",
|
||||||
|
"eslint-plugin-no-null",
|
||||||
|
"eslint-plugin-unicorn",
|
||||||
|
"eslint-plugin-jsdoc",
|
||||||
|
"eslint-plugin-prefer-arrow",
|
||||||
|
"@typescript-eslint",
|
||||||
|
"functional",
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
rules: {
|
||||||
|
"no-undef": "off",
|
||||||
|
"no-extra-boolean-cast": "off",
|
||||||
|
"no-alert": "error",
|
||||||
|
"no-self-compare": "error",
|
||||||
|
"no-unreachable-loop": "error",
|
||||||
|
"no-template-curly-in-string": "error",
|
||||||
|
"no-unused-private-class-members": "error",
|
||||||
|
"no-extend-native": "error",
|
||||||
|
"no-floating-decimal": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"no-iterator": "error",
|
||||||
|
"no-lone-blocks": "error",
|
||||||
|
"no-loop-func": "error",
|
||||||
|
"no-new-object": "error",
|
||||||
|
"no-proto": "error",
|
||||||
|
"no-useless-catch": "error",
|
||||||
|
"one-var-declaration-per-line": "error",
|
||||||
|
"prefer-arrow-callback": "error",
|
||||||
|
"prefer-destructuring": "error",
|
||||||
|
"prefer-exponentiation-operator": "error",
|
||||||
|
"prefer-promise-reject-errors": "error",
|
||||||
|
"prefer-regex-literals": "error",
|
||||||
|
"prefer-spread": "error",
|
||||||
|
"prefer-template": "error",
|
||||||
|
"require-await": "error",
|
||||||
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||||
|
"@typescript-eslint/array-type": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
default: "array",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/ban-types": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
types: {
|
||||||
|
Object: {
|
||||||
|
message: "Avoid using the `Object` type. Did you mean `object`?",
|
||||||
|
},
|
||||||
|
Function: {
|
||||||
|
message: "Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
|
||||||
|
},
|
||||||
|
Boolean: {
|
||||||
|
message: "Avoid using the `Boolean` type. Did you mean `boolean`?",
|
||||||
|
},
|
||||||
|
Number: {
|
||||||
|
message: "Avoid using the `Number` type. Did you mean `number`?",
|
||||||
|
},
|
||||||
|
String: {
|
||||||
|
message: "Avoid using the `String` type. Did you mean `string`?",
|
||||||
|
},
|
||||||
|
Symbol: {
|
||||||
|
message: "Avoid using the `Symbol` type. Did you mean `symbol`?",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/consistent-type-assertions": "error",
|
||||||
|
"@typescript-eslint/dot-notation": "error",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowExpressions: true,
|
||||||
|
allowTypedFunctionExpressions: true,
|
||||||
|
allowHigherOrderFunctions: false,
|
||||||
|
allowDirectConstAssertionInArrowFunctions: true,
|
||||||
|
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/explicit-member-accessibility": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
accessibility: "explicit",
|
||||||
|
overrides: {
|
||||||
|
accessors: "explicit",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/explicit-module-boundary-types": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowArgumentsExplicitlyTypedAsAny: true,
|
||||||
|
allowDirectConstAssertionInArrowFunctions: true,
|
||||||
|
allowHigherOrderFunctions: false,
|
||||||
|
allowTypedFunctionExpressions: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/naming-convention": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
selector: ["objectLiteralProperty"],
|
||||||
|
leadingUnderscore: "allow",
|
||||||
|
format: ["camelCase", "PascalCase"],
|
||||||
|
filter: {
|
||||||
|
regex: "(^[a-z]+:.+)|_attr|[0-9]",
|
||||||
|
match: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-empty-function": "error",
|
||||||
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"@typescript-eslint/no-misused-new": "error",
|
||||||
|
"@typescript-eslint/no-namespace": "error",
|
||||||
|
"@typescript-eslint/no-parameter-properties": "off",
|
||||||
|
"@typescript-eslint/no-require-imports": "error",
|
||||||
|
"@typescript-eslint/no-shadow": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
hoist: "all",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-this-alias": "error",
|
||||||
|
"@typescript-eslint/no-unused-expressions": "error",
|
||||||
|
"@typescript-eslint/no-use-before-define": "off",
|
||||||
|
"@typescript-eslint/no-var-requires": "error",
|
||||||
|
"@typescript-eslint/prefer-for-of": "error",
|
||||||
|
"@typescript-eslint/prefer-function-type": "error",
|
||||||
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||||
|
"@typescript-eslint/prefer-readonly": "error",
|
||||||
|
"@typescript-eslint/triple-slash-reference": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
path: "always",
|
||||||
|
types: "prefer-import",
|
||||||
|
lib: "always",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/typedef": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
parameter: true,
|
||||||
|
propertyDeclaration: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/unified-signatures": "error",
|
||||||
|
"arrow-body-style": "error",
|
||||||
|
complexity: "off",
|
||||||
|
"consistent-return": "error",
|
||||||
|
"constructor-super": "error",
|
||||||
|
curly: "error",
|
||||||
|
"dot-notation": "off",
|
||||||
|
eqeqeq: ["error", "smart"],
|
||||||
|
"guard-for-in": "error",
|
||||||
|
"id-denylist": ["error", "any", "Number", "number", "String", "string", "Boolean", "boolean", "Undefined", "undefined"],
|
||||||
|
"id-match": "error",
|
||||||
|
"import/no-default-export": "error",
|
||||||
|
"import/no-extraneous-dependencies": "off",
|
||||||
|
"import/no-internal-modules": "off",
|
||||||
|
"import/order": "error",
|
||||||
|
indent: "off",
|
||||||
|
"jsdoc/check-alignment": "error",
|
||||||
|
"jsdoc/check-indentation": "off",
|
||||||
|
"jsdoc/newline-after-description": "error",
|
||||||
|
"max-classes-per-file": "off",
|
||||||
|
"max-len": "off",
|
||||||
|
"new-parens": "error",
|
||||||
|
"no-bitwise": "error",
|
||||||
|
"no-caller": "error",
|
||||||
|
"no-cond-assign": "error",
|
||||||
|
"no-console": "error",
|
||||||
|
"no-debugger": "error",
|
||||||
|
"no-duplicate-case": "error",
|
||||||
|
"no-duplicate-imports": "error",
|
||||||
|
"no-empty": "error",
|
||||||
|
"no-empty-function": "off",
|
||||||
|
"no-eval": "error",
|
||||||
|
"no-extra-bind": "error",
|
||||||
|
"no-fallthrough": "off",
|
||||||
|
"no-invalid-this": "off",
|
||||||
|
"no-multiple-empty-lines": "error",
|
||||||
|
"no-new-func": "error",
|
||||||
|
"no-new-wrappers": "error",
|
||||||
|
"no-null/no-null": "error",
|
||||||
|
"no-param-reassign": "error",
|
||||||
|
"no-redeclare": "error",
|
||||||
|
"no-return-await": "error",
|
||||||
|
"no-sequences": "error",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"no-sparse-arrays": "error",
|
||||||
|
"no-throw-literal": "error",
|
||||||
|
"no-trailing-spaces": "error",
|
||||||
|
"no-undef-init": "error",
|
||||||
|
"no-underscore-dangle": ["error", { allow: ["_attr"] }],
|
||||||
|
"no-unsafe-finally": "error",
|
||||||
|
"no-unused-expressions": "off",
|
||||||
|
"no-unused-labels": "error",
|
||||||
|
"no-use-before-define": "off",
|
||||||
|
"no-useless-constructor": "error",
|
||||||
|
"no-var": "error",
|
||||||
|
"object-shorthand": "off",
|
||||||
|
"one-var": ["error", "never"],
|
||||||
|
"prefer-arrow/prefer-arrow-functions": "error",
|
||||||
|
"prefer-const": "error",
|
||||||
|
"prefer-object-spread": "error",
|
||||||
|
radix: "error",
|
||||||
|
"space-in-parens": ["error", "never"],
|
||||||
|
"spaced-comment": [
|
||||||
|
"error",
|
||||||
|
"always",
|
||||||
|
{
|
||||||
|
markers: ["/"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"unicorn/filename-case": "error",
|
||||||
|
"unicorn/prefer-ternary": "error",
|
||||||
|
"use-isnan": "error",
|
||||||
|
"valid-typeof": "off",
|
||||||
|
"functional/immutable-data": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
assumeTypes: true,
|
||||||
|
ignoreImmediateMutation: true,
|
||||||
|
ignoreAccessorPattern: ["**.root*", "**.numberingReferences*", "**.sections*", "**.properties*"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"functional/prefer-property-signatures": "error",
|
||||||
|
"functional/no-mixed-types": "error",
|
||||||
|
// TODO: Deprecated. Use prefer-immutable-types and type-declaration-immutability instead
|
||||||
|
"functional/prefer-readonly-type": "error",
|
||||||
|
// "functional/prefer-immutable-types": "error",
|
||||||
|
// "functional/type-declaration-immutability": "error",
|
||||||
|
"no-unused-vars": ["error", { argsIgnorePattern: "^[_]+$" }],
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ["*.spec.ts"],
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-unused-expressions": "off",
|
||||||
|
"@typescript-eslint/dot-notation": "off",
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
239
.eslintrc.yml
239
.eslintrc.yml
@ -1,239 +0,0 @@
|
|||||||
extends: eslint:recommended
|
|
||||||
env:
|
|
||||||
browser: true
|
|
||||||
es6: true
|
|
||||||
node: true
|
|
||||||
parser: "@typescript-eslint/parser"
|
|
||||||
parserOptions:
|
|
||||||
project:
|
|
||||||
- tsconfig.json
|
|
||||||
- demo/tsconfig.json
|
|
||||||
sourceType: module
|
|
||||||
plugins:
|
|
||||||
- eslint-plugin-import
|
|
||||||
- eslint-plugin-no-null
|
|
||||||
- eslint-plugin-unicorn
|
|
||||||
- eslint-plugin-jsdoc
|
|
||||||
- eslint-plugin-prefer-arrow
|
|
||||||
- "@typescript-eslint"
|
|
||||||
- eslint-plugin-functional
|
|
||||||
root: true
|
|
||||||
rules:
|
|
||||||
no-undef: "off"
|
|
||||||
no-extra-boolean-cast: "off"
|
|
||||||
no-alert: error
|
|
||||||
no-self-compare: error
|
|
||||||
no-unreachable-loop: error
|
|
||||||
no-template-curly-in-string: error
|
|
||||||
no-unused-private-class-members: error
|
|
||||||
no-extend-native: error
|
|
||||||
no-floating-decimal: error
|
|
||||||
no-implied-eval: error
|
|
||||||
no-iterator: error
|
|
||||||
no-lone-blocks: error
|
|
||||||
no-loop-func: error
|
|
||||||
no-new-object: error
|
|
||||||
no-proto: error
|
|
||||||
no-useless-catch: error
|
|
||||||
one-var-declaration-per-line: error
|
|
||||||
prefer-arrow-callback: error
|
|
||||||
prefer-destructuring: error
|
|
||||||
prefer-exponentiation-operator: error
|
|
||||||
prefer-promise-reject-errors: error
|
|
||||||
prefer-regex-literals: error
|
|
||||||
prefer-spread: error
|
|
||||||
prefer-template: error
|
|
||||||
require-await: error
|
|
||||||
"@typescript-eslint/adjacent-overload-signatures": error
|
|
||||||
"@typescript-eslint/array-type":
|
|
||||||
- error
|
|
||||||
- default: array
|
|
||||||
"@typescript-eslint/ban-types":
|
|
||||||
- error
|
|
||||||
- types:
|
|
||||||
Object:
|
|
||||||
message: Avoid using the `Object` type. Did you mean `object`?
|
|
||||||
Function:
|
|
||||||
message: >-
|
|
||||||
Avoid using the `Function` type. Prefer a specific function type,
|
|
||||||
like `() => void`.
|
|
||||||
Boolean:
|
|
||||||
message: Avoid using the `Boolean` type. Did you mean `boolean`?
|
|
||||||
Number:
|
|
||||||
message: Avoid using the `Number` type. Did you mean `number`?
|
|
||||||
String:
|
|
||||||
message: Avoid using the `String` type. Did you mean `string`?
|
|
||||||
Symbol:
|
|
||||||
message: Avoid using the `Symbol` type. Did you mean `symbol`?
|
|
||||||
"@typescript-eslint/consistent-type-assertions": error
|
|
||||||
"@typescript-eslint/dot-notation": error
|
|
||||||
"@typescript-eslint/explicit-function-return-type":
|
|
||||||
- error
|
|
||||||
- allowExpressions: true
|
|
||||||
allowTypedFunctionExpressions: true
|
|
||||||
allowHigherOrderFunctions: false
|
|
||||||
allowDirectConstAssertionInArrowFunctions: true
|
|
||||||
allowConciseArrowFunctionExpressionsStartingWithVoid: true
|
|
||||||
"@typescript-eslint/explicit-member-accessibility":
|
|
||||||
- error
|
|
||||||
- accessibility: explicit
|
|
||||||
overrides:
|
|
||||||
accessors: explicit
|
|
||||||
"@typescript-eslint/explicit-module-boundary-types":
|
|
||||||
- error
|
|
||||||
- allowArgumentsExplicitlyTypedAsAny: true
|
|
||||||
allowDirectConstAssertionInArrowFunctions: true
|
|
||||||
allowHigherOrderFunctions: false
|
|
||||||
allowTypedFunctionExpressions: false
|
|
||||||
"@typescript-eslint/naming-convention":
|
|
||||||
- error
|
|
||||||
- selector:
|
|
||||||
- objectLiteralProperty
|
|
||||||
leadingUnderscore: allow
|
|
||||||
format:
|
|
||||||
- camelCase
|
|
||||||
- PascalCase
|
|
||||||
filter:
|
|
||||||
regex: (^[a-z]+:.+)|_attr|[0-9]
|
|
||||||
match: false
|
|
||||||
"@typescript-eslint/no-empty-function": error
|
|
||||||
"@typescript-eslint/no-empty-interface": error
|
|
||||||
"@typescript-eslint/no-explicit-any": error
|
|
||||||
"@typescript-eslint/no-misused-new": error
|
|
||||||
"@typescript-eslint/no-namespace": error
|
|
||||||
"@typescript-eslint/no-parameter-properties": "off"
|
|
||||||
"@typescript-eslint/no-require-imports": error
|
|
||||||
"@typescript-eslint/no-shadow":
|
|
||||||
- error
|
|
||||||
- hoist: all
|
|
||||||
"@typescript-eslint/no-this-alias": error
|
|
||||||
"@typescript-eslint/no-unused-expressions": error
|
|
||||||
"@typescript-eslint/no-use-before-define": "off"
|
|
||||||
"@typescript-eslint/no-var-requires": error
|
|
||||||
"@typescript-eslint/prefer-for-of": error
|
|
||||||
"@typescript-eslint/prefer-function-type": error
|
|
||||||
"@typescript-eslint/prefer-namespace-keyword": error
|
|
||||||
"@typescript-eslint/prefer-readonly": error
|
|
||||||
"@typescript-eslint/triple-slash-reference":
|
|
||||||
- error
|
|
||||||
- path: always
|
|
||||||
types: prefer-import
|
|
||||||
lib: always
|
|
||||||
"@typescript-eslint/typedef":
|
|
||||||
- error
|
|
||||||
- parameter: true
|
|
||||||
propertyDeclaration: true
|
|
||||||
"@typescript-eslint/unified-signatures": error
|
|
||||||
arrow-body-style: error
|
|
||||||
complexity: "off"
|
|
||||||
consistent-return: error
|
|
||||||
constructor-super: error
|
|
||||||
curly: error
|
|
||||||
dot-notation: "off"
|
|
||||||
eqeqeq:
|
|
||||||
- error
|
|
||||||
- smart
|
|
||||||
guard-for-in: error
|
|
||||||
id-denylist:
|
|
||||||
- error
|
|
||||||
- any
|
|
||||||
- Number
|
|
||||||
- number
|
|
||||||
- String
|
|
||||||
- string
|
|
||||||
- Boolean
|
|
||||||
- boolean
|
|
||||||
- Undefined
|
|
||||||
- undefined
|
|
||||||
id-match: error
|
|
||||||
import/no-default-export: error
|
|
||||||
import/no-extraneous-dependencies: "off"
|
|
||||||
import/no-internal-modules: "off"
|
|
||||||
import/order: error
|
|
||||||
indent: "off"
|
|
||||||
jsdoc/check-alignment: error
|
|
||||||
jsdoc/check-indentation: "off"
|
|
||||||
max-classes-per-file: "off"
|
|
||||||
max-len: "off"
|
|
||||||
new-parens: error
|
|
||||||
no-bitwise: error
|
|
||||||
no-caller: error
|
|
||||||
no-cond-assign: error
|
|
||||||
no-console: error
|
|
||||||
no-debugger: error
|
|
||||||
no-duplicate-case: error
|
|
||||||
no-duplicate-imports: error
|
|
||||||
no-empty: error
|
|
||||||
no-empty-function: "off"
|
|
||||||
no-eval: error
|
|
||||||
no-extra-bind: error
|
|
||||||
no-fallthrough: "off"
|
|
||||||
no-invalid-this: "off"
|
|
||||||
no-multiple-empty-lines: error
|
|
||||||
no-new-func: error
|
|
||||||
no-new-wrappers: error
|
|
||||||
no-null/no-null: error
|
|
||||||
no-param-reassign: error
|
|
||||||
no-redeclare: error
|
|
||||||
no-return-await: error
|
|
||||||
no-sequences: error
|
|
||||||
no-shadow: "off"
|
|
||||||
no-sparse-arrays: error
|
|
||||||
no-throw-literal: error
|
|
||||||
no-trailing-spaces: error
|
|
||||||
no-undef-init: error
|
|
||||||
no-underscore-dangle:
|
|
||||||
- error
|
|
||||||
- allow:
|
|
||||||
- _attr
|
|
||||||
no-unsafe-finally: error
|
|
||||||
no-unused-expressions: "off"
|
|
||||||
no-unused-labels: error
|
|
||||||
no-use-before-define: "off"
|
|
||||||
no-useless-constructor: error
|
|
||||||
no-var: error
|
|
||||||
object-shorthand: "off"
|
|
||||||
one-var:
|
|
||||||
- error
|
|
||||||
- never
|
|
||||||
prefer-arrow/prefer-arrow-functions: error
|
|
||||||
prefer-const: error
|
|
||||||
prefer-object-spread: error
|
|
||||||
radix: error
|
|
||||||
space-in-parens:
|
|
||||||
- error
|
|
||||||
- never
|
|
||||||
spaced-comment:
|
|
||||||
- error
|
|
||||||
- always
|
|
||||||
- markers:
|
|
||||||
- /
|
|
||||||
unicorn/filename-case: error
|
|
||||||
unicorn/prefer-ternary: error
|
|
||||||
use-isnan: error
|
|
||||||
valid-typeof: "off"
|
|
||||||
functional/immutable-data:
|
|
||||||
- error
|
|
||||||
- assumeTypes: true
|
|
||||||
ignoreImmediateMutation: true
|
|
||||||
ignoreAccessorPattern:
|
|
||||||
- "**.root*"
|
|
||||||
- "**.numberingReferences*"
|
|
||||||
- "**.sections*"
|
|
||||||
- "**.properties*"
|
|
||||||
functional/prefer-property-signatures: error
|
|
||||||
functional/no-mixed-types: error
|
|
||||||
functional/prefer-readonly-type: error
|
|
||||||
no-unused-vars:
|
|
||||||
- error
|
|
||||||
- argsIgnorePattern: ^[_]+$
|
|
||||||
ignorePatterns:
|
|
||||||
- vite.config.ts
|
|
||||||
overrides:
|
|
||||||
- files:
|
|
||||||
- "*.spec.ts"
|
|
||||||
rules:
|
|
||||||
"@typescript-eslint/no-unused-expressions": "off"
|
|
||||||
"@typescript-eslint/dot-notation": "off"
|
|
||||||
prefer-destructuring: "off"
|
|
||||||
"@typescript-eslint/explicit-function-return-type": "off"
|
|
33
.github/dependabot.yml
vendored
33
.github/dependabot.yml
vendored
@ -5,3 +5,36 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
|
ignore:
|
||||||
|
- dependency-name: "@types/node"
|
||||||
|
versions:
|
||||||
|
- 14.14.22
|
||||||
|
- 14.14.24
|
||||||
|
- 14.14.25
|
||||||
|
- 14.14.26
|
||||||
|
- 14.14.28
|
||||||
|
- 14.14.29
|
||||||
|
- 14.14.30
|
||||||
|
- 15.0.0
|
||||||
|
- dependency-name: webpack
|
||||||
|
versions:
|
||||||
|
- 5.31.2
|
||||||
|
- 5.35.0
|
||||||
|
- dependency-name: ts-loader
|
||||||
|
versions:
|
||||||
|
- 9.1.0
|
||||||
|
- dependency-name: awesome-typescript-loader
|
||||||
|
versions:
|
||||||
|
- 5.2.1
|
||||||
|
- dependency-name: chai
|
||||||
|
versions:
|
||||||
|
- 4.2.0
|
||||||
|
- 4.3.0
|
||||||
|
- 4.3.1
|
||||||
|
- 4.3.3
|
||||||
|
- dependency-name: replace-in-file
|
||||||
|
versions:
|
||||||
|
- 6.1.0
|
||||||
|
- dependency-name: "@types/chai"
|
||||||
|
versions:
|
||||||
|
- 4.2.14
|
||||||
|
2
.github/workflows/default.yml
vendored
2
.github/workflows/default.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci --force
|
run: npm ci --force
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm run test.ci
|
run: npm run test.coverage
|
||||||
- name: Codecov
|
- name: Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
|
9
.github/workflows/demos.yml
vendored
9
.github/workflows/demos.yml
vendored
@ -301,6 +301,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
xml-file: build/extracted-doc/word/document.xml
|
xml-file: build/extracted-doc/word/document.xml
|
||||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||||
|
- name: Run Demo
|
||||||
|
run: npm run ts-node -- ./demo/30-template-document.ts
|
||||||
|
- name: Extract Word Document
|
||||||
|
run: npm run extract
|
||||||
|
- name: Validate XML
|
||||||
|
uses: ChristophWurst/xmllint-action@v1
|
||||||
|
with:
|
||||||
|
xml-file: build/extracted-doc/word/document.xml
|
||||||
|
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||||
- name: Run Demo
|
- name: Run Demo
|
||||||
run: npm run ts-node -- ./demo/31-tables.ts
|
run: npm run ts-node -- ./demo/31-tables.ts
|
||||||
- name: Extract Word Document
|
- name: Extract Word Document
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -60,5 +60,5 @@ My Document.docx
|
|||||||
# Temporary folder
|
# Temporary folder
|
||||||
tmp
|
tmp
|
||||||
|
|
||||||
# Exclude Mac .DS_Store files
|
# nyc
|
||||||
.DS_Store
|
.nyc_output
|
||||||
|
13
.mocharc.json
Normal file
13
.mocharc.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"diff": true,
|
||||||
|
"spec": "src/**/*.ts",
|
||||||
|
"extension": ["ts"],
|
||||||
|
"package": "./package.json",
|
||||||
|
"reporter": "spec",
|
||||||
|
"slow": "75",
|
||||||
|
"timeout": "2000",
|
||||||
|
"ui": "bdd",
|
||||||
|
"watch-files": ["src/**/*.ts"],
|
||||||
|
"watch-ignore": ["build", "demo"],
|
||||||
|
"require": ["mocha.env", "ts-node/register", "tsconfig-paths/register"]
|
||||||
|
}
|
@ -40,7 +40,4 @@ build-tests
|
|||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
docs
|
docs
|
||||||
|
|
||||||
# src
|
|
||||||
src
|
|
25
.nycrc
Normal file
25
.nycrc
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"check-coverage": true,
|
||||||
|
"statements": 99.79,
|
||||||
|
"branches": 98.41,
|
||||||
|
"functions": 100,
|
||||||
|
"lines": 99.73,
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"src/**/*.spec.ts",
|
||||||
|
"src/import-dotx/import-dotx.ts"
|
||||||
|
],
|
||||||
|
"reporter": [
|
||||||
|
"lcov",
|
||||||
|
"text",
|
||||||
|
"json"
|
||||||
|
],
|
||||||
|
"extension": [
|
||||||
|
".ts"
|
||||||
|
],
|
||||||
|
"cache": true,
|
||||||
|
"all": true,
|
||||||
|
"sourceMap": true
|
||||||
|
}
|
18
.vscode/launch.json
vendored
18
.vscode/launch.json
vendored
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Run Demo",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"-r",
|
|
||||||
"${workspaceFolder}/node_modules/ts-node/register",
|
|
||||||
"-r",
|
|
||||||
"${workspaceFolder}/node_modules/tsconfig-paths/register"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"program": "${workspaceFolder}/demo/85-template-document.ts"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -3,7 +3,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
Easily generate and modify .docx files with JS/TS. Works for Node and on the Browser.
|
Easily generate .docx files with JS/TS. Works for Node and on the Browser.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -88,7 +88,6 @@ Read the contribution guidelines [here](https://docx.js.org/#/contribution-guide
|
|||||||
[<img src="https://i.imgur.com/cmykN7c.png" alt="drawing"/>](https://www.arity.co/)
|
[<img src="https://i.imgur.com/cmykN7c.png" alt="drawing"/>](https://www.arity.co/)
|
||||||
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
|
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
|
||||||
[<img src="https://i.imgur.com/AKGhtlh.png" alt="drawing"/>](https://lexense.com/)
|
[<img src="https://i.imgur.com/AKGhtlh.png" alt="drawing"/>](https://lexense.com/)
|
||||||
[<img src="https://i.imgur.com/9tqJaHw.png" alt="drawing" height="50"/>](https://novelpad.co/)
|
|
||||||
|
|
||||||
...and many more!
|
...and many more!
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Simple example to add text to a document
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Generate a CV
|
// Generate a CV
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "docx";
|
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "../build";
|
||||||
|
|
||||||
// tslint:disable:no-shadowed-variable
|
// tslint:disable:no-shadowed-variable
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Setting styles with JavaScript configuration
|
// Setting styles with JavaScript configuration
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
AlignmentType,
|
AlignmentType,
|
||||||
@ -16,7 +16,7 @@ import {
|
|||||||
TabStopPosition,
|
TabStopPosition,
|
||||||
UnderlineType,
|
UnderlineType,
|
||||||
LevelFormat,
|
LevelFormat,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Scaling images
|
// Scaling images
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, ImageRun, Packer, Paragraph } from "docx";
|
import { Document, ImageRun, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// This example shows 3 styles using XML styles
|
// This example shows 3 styles using XML styles
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph } from "docx";
|
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Page numbers
|
// Page numbers
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "docx";
|
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Page break before example
|
// Page break before example
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph } from "docx";
|
import { Document, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Multiple sections and headers
|
// Multiple sections and headers
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "docx";
|
import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Footnotes
|
// Footnotes
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "docx";
|
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
footnotes: {
|
footnotes: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Insert image from a buffer
|
// Insert image from a buffer
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, ImageRun, Packer, Paragraph } from "docx";
|
import { Document, ImageRun, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const imageBase64Data = `iVBORw0KGgoAAAANSU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CC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Export to base64 string - Useful in a browser environment.
|
// Export to base64 string - Useful in a browser environment.
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
// Example on how to customize the look at feel using Styles
|
// Example on how to customize the look at feel using Styles
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph, TextRun, UnderlineType } from "docx";
|
import {
|
||||||
|
AlignmentType,
|
||||||
|
convertInchesToTwip,
|
||||||
|
Document,
|
||||||
|
HeadingLevel,
|
||||||
|
LevelFormat,
|
||||||
|
Packer,
|
||||||
|
Paragraph,
|
||||||
|
TextRun,
|
||||||
|
UnderlineType,
|
||||||
|
} from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
creator: "Clippy",
|
creator: "Clippy",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add custom borders to table cell
|
// Add custom borders to table cell
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
// This demo shows how to create bookmarks then link to them with internal hyperlinks
|
// This demo shows how to create bookmarks then link to them with internal hyperlinks
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Bookmark, Document, Footer, HeadingLevel, InternalHyperlink, Packer, PageBreak, Paragraph, TextRun, PageReference } from "docx";
|
import {
|
||||||
|
Bookmark,
|
||||||
|
Document,
|
||||||
|
Footer,
|
||||||
|
HeadingLevel,
|
||||||
|
InternalHyperlink,
|
||||||
|
Packer,
|
||||||
|
PageBreak,
|
||||||
|
Paragraph,
|
||||||
|
TextRun,
|
||||||
|
PageReference,
|
||||||
|
} from "../build";
|
||||||
|
|
||||||
const LOREM_IPSUM =
|
const LOREM_IPSUM =
|
||||||
/* cspell:disable-next-line */
|
/* cspell:disable-next-line */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// This demo shows right to left for special languages
|
// This demo shows right to left for special languages
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "docx";
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// This demo adds an image to the Media cache, and then insert to the document afterwards
|
// This demo adds an image to the Media cache, and then insert to the document afterwards
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, ImageRun, Packer, Paragraph, TextRun } from "docx";
|
import { Document, ImageRun, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyAiHyAjHSAjHR4jHR4hHh4hHx8hHyAiHyAjHyAjHSAjHR4jHR4hHh4hHx8hHyAjHyAjHyA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Dp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add image to table cell
|
// Add image to table cell
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of how you would create a table and add data to it
|
// Example of how you would create a table and add data to it
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
|
||||||
|
|
||||||
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Creates two paragraphs, one with a border and one without
|
// Creates two paragraphs, one with a border and one without
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "docx";
|
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
@ -25,17 +25,6 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
|
||||||
text: "",
|
|
||||||
border: {
|
|
||||||
top: {
|
|
||||||
color: "auto",
|
|
||||||
space: 1,
|
|
||||||
style: BorderStyle.SINGLE,
|
|
||||||
size: 6,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new TextRun({
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Custom styles using JavaScript configuration
|
// Custom styles using JavaScript configuration
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "docx";
|
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Table of contents
|
// Table of contents
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "docx";
|
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "../build";
|
||||||
|
|
||||||
// WordprocessingML docs for TableOfContents can be found here:
|
// WordprocessingML docs for TableOfContents can be found here:
|
||||||
// http://officeopenxml.com/WPtableOfContents.php
|
// http://officeopenxml.com/WPtableOfContents.php
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Numbered lists
|
// Numbered lists
|
||||||
// The lists can also be restarted by specifying the instance number
|
// The lists can also be restarted by specifying the instance number
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
|
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Numbering and bullet points example
|
// Numbering and bullet points example
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
|
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
|
35
demo/30-template-document.ts
Normal file
35
demo/30-template-document.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Example on how to use a template document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, ImportDotx, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
|
const importDotx = new ImportDotx();
|
||||||
|
const filePath = "./demo/dotx/template.dotx";
|
||||||
|
|
||||||
|
fs.readFile(filePath, (err, data) => {
|
||||||
|
if (err) {
|
||||||
|
throw new Error(`Failed to read file ${filePath}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
importDotx.extract(data).then((templateDocument) => {
|
||||||
|
const doc = new Document(
|
||||||
|
{
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {
|
||||||
|
titlePage: templateDocument.titlePageIsDefined,
|
||||||
|
},
|
||||||
|
children: [new Paragraph("Hello World")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
template: templateDocument,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,7 +1,7 @@
|
|||||||
// Example of how you would create a table and add data to it
|
// Example of how you would create a table and add data to it
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "docx";
|
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Example of how you would merge cells together (Rows and Columns) and apply shading
|
// Example of how you would merge cells together (Rows and Columns) and apply shading
|
||||||
// Also includes an example on how to center tables
|
// Also includes an example on how to center tables
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
AlignmentType,
|
AlignmentType,
|
||||||
@ -15,7 +15,7 @@ import {
|
|||||||
TableCell,
|
TableCell,
|
||||||
TableRow,
|
TableRow,
|
||||||
WidthType,
|
WidthType,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Sequential Captions
|
// Sequential Captions
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "docx";
|
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Example of how you would create a table with float positions
|
// Example of how you would create a table with float positions
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
@ -14,7 +14,7 @@ import {
|
|||||||
TableLayoutType,
|
TableLayoutType,
|
||||||
TableRow,
|
TableRow,
|
||||||
WidthType,
|
WidthType,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example on how to add hyperlinks to websites
|
// Example on how to add hyperlinks to websites
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "docx";
|
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
footnotes: {
|
footnotes: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add image to table cell in a header and body
|
// Add image to table cell in a header and body
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add images to header and footer
|
// Add images to header and footer
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Header, ImageRun, Packer, Paragraph } from "docx";
|
import { Document, Header, ImageRun, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Example of how to "wrap" text around an image
|
// Example of how to "wrap" text around an image
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
// import { Document, Packer, Paragraph } from "docx";
|
// import { Document, Packer, Paragraph } from "../build";
|
||||||
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "docx";
|
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example how to display page numbers
|
// Example how to display page numbers
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
|
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of how you would create a table and add data to it
|
// Example of how you would create a table and add data to it
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
columnWidths: [3505, 5505],
|
columnWidths: [3505, 5505],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example demonstrating line numbers.
|
// Example demonstrating line numbers.
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
|
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Multiple cells merging in the same table - Rows and Columns
|
// Multiple cells merging in the same table - Rows and Columns
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Page numbers - Start from 0 on a new section
|
// Page numbers - Start from 0 on a new section
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "docx";
|
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add image to table cell
|
// Add image to table cell
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
|
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
|
||||||
|
|
||||||
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyA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heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Sections with multiple columns
|
// Sections with multiple columns
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph } from "docx";
|
import { Document, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Highlighting text
|
// Highlighting text
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "docx";
|
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Shading text
|
// Shading text
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "docx";
|
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Multiple sections with total number of pages in each section
|
// Multiple sections with total number of pages in each section
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
|
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const header = new Header({
|
const header = new Header({
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of making content of section vertically aligned
|
// Example of making content of section vertically aligned
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "docx";
|
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Add custom borders and no-borders to the table itself
|
// Add custom borders and no-borders to the table itself
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
BorderStyle,
|
BorderStyle,
|
||||||
@ -13,7 +13,7 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
TextDirection,
|
TextDirection,
|
||||||
VerticalAlign,
|
VerticalAlign,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings
|
// Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
@ -10,7 +10,7 @@ import {
|
|||||||
Paragraph,
|
Paragraph,
|
||||||
VerticalPositionAlign,
|
VerticalPositionAlign,
|
||||||
VerticalPositionRelativeFrom,
|
VerticalPositionRelativeFrom,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// The demo on the README.md
|
// The demo on the README.md
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "docx";
|
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Custom character styles using JavaScript configuration
|
// Custom character styles using JavaScript configuration
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "docx";
|
import { Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Japanese text - Need to use a Japanese font
|
// Japanese text - Need to use a Japanese font
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph } from "docx";
|
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
// Note that if the OS have not install `KaiTi` font, this demo doesn't work.
|
// Note that if the OS have not install `KaiTi` font, this demo doesn't work.
|
||||||
|
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "docx";
|
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
// to the document in Word after the document has been generated. Standard properties (such as creator, title
|
// to the document in Word after the document has been generated. Standard properties (such as creator, title
|
||||||
// and subject) cover typical use cases, but sometimes custom properties are required.
|
// and subject) cover typical use cases, but sometimes custom properties are required.
|
||||||
|
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer } from "docx";
|
import { Document, Packer } from "../build";
|
||||||
|
|
||||||
const doc = new Document(
|
const doc = new Document(
|
||||||
// Standard properties
|
// Standard properties
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Simple example to add text to a document
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
@ -21,7 +21,7 @@ import {
|
|||||||
Packer,
|
Packer,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
TextRun,
|
TextRun,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Change background colour of whole document
|
// Change background colour of whole document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
background: {
|
background: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Numbered lists - Add parent number in sub number
|
// Numbered lists - Add parent number in sub number
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
|
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Usage of different Section Types
|
// Usage of different Section Types
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun, SectionType } from "docx";
|
import { Document, Packer, Paragraph, TextRun, SectionType } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Move + offset header and footer
|
// Move + offset header and footer
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, Paragraph } from "docx";
|
import { Document, Footer, Header, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of how to change page borders
|
// Example of how to change page borders
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "docx";
|
import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Track Revisions aka. "Track Changes"
|
// Track Revisions aka. "Track Changes"
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
AlignmentType,
|
AlignmentType,
|
||||||
@ -14,7 +14,7 @@ import {
|
|||||||
ShadingType,
|
ShadingType,
|
||||||
Tab,
|
Tab,
|
||||||
TextRun,
|
TextRun,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For reference, see
|
For reference, see
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Text Frame (Text Box) example
|
// Text Frame (Text Box) example
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
BorderStyle,
|
BorderStyle,
|
||||||
@ -11,7 +11,7 @@ import {
|
|||||||
Tab,
|
Tab,
|
||||||
TextRun,
|
TextRun,
|
||||||
VerticalPositionAlign,
|
VerticalPositionAlign,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Simple example to add text to a document
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "docx";
|
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Move + offset header and footer
|
// Move + offset header and footer
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "docx";
|
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
evenAndOddHeaderAndFooters: true,
|
evenAndOddHeaderAndFooters: true,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Numbered lists - With complex number text
|
// Numbered lists - With complex number text
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, LevelFormat } from "docx";
|
import { Document, Packer, Paragraph, LevelFormat } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Example of how to set the document page sizes
|
// Example of how to set the document page sizes
|
||||||
// Reference from https://papersizes.io/a/a3
|
// Reference from https://papersizes.io/a/a3
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "docx";
|
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Use fields to include dynamic text
|
// Use fields to include dynamic text
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "docx";
|
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
creator: "Me",
|
creator: "Me",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Section with 2 columns including a column break
|
// Section with 2 columns including a column break
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "docx";
|
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, LevelFormat } from "docx";
|
import { Document, Packer, Paragraph, LevelFormat } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Sections with multiple columns
|
// Sections with multiple columns
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Column, Document, Packer, Paragraph } from "docx";
|
import { Column, Document, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of how to set the document to landscape
|
// Example of how to set the document to landscape
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, PageOrientation, Paragraph } from "docx";
|
import { Document, Packer, PageOrientation, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example demonstrating line numbers with suppression.
|
// Example demonstrating line numbers with suppression.
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
|
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example demonstrating page borders with style, colors and size
|
// Example demonstrating page borders with style, colors and size
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "docx";
|
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example on how to preserve word wrap text. Works with all languages.
|
// Example on how to preserve word wrap text. Works with all languages.
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "docx";
|
import { Document, Packer, Paragraph, TextRun, SpaceType } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,87 +1,11 @@
|
|||||||
// Simple example to add comments to a document
|
// Simple example to add comments to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "docx";
|
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
comments: {
|
comments: {
|
||||||
children: [
|
children: [{ id: 0, author: "Ray Chen", date: new Date(), text: "comment text content" }],
|
||||||
{
|
|
||||||
id: 0,
|
|
||||||
author: "Ray Chen",
|
|
||||||
date: new Date(),
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "some initial text content",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "comment text content",
|
|
||||||
}),
|
|
||||||
new TextRun({ text: "", break: 1 }),
|
|
||||||
new TextRun({
|
|
||||||
text: "More text here",
|
|
||||||
bold: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
author: "Bob Ross",
|
|
||||||
date: new Date(),
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "Some initial text content",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "comment text content",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
author: "John Doe",
|
|
||||||
date: new Date(),
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "Hello World",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
author: "Beatriz",
|
|
||||||
date: new Date(),
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "Another reply",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
sections: [
|
sections: [
|
||||||
{
|
{
|
||||||
@ -102,32 +26,6 @@ const doc = new Document({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new CommentRangeStart(1),
|
|
||||||
new CommentRangeStart(2),
|
|
||||||
new CommentRangeStart(3),
|
|
||||||
new TextRun({
|
|
||||||
text: "Some text which need commenting",
|
|
||||||
bold: true,
|
|
||||||
}),
|
|
||||||
new CommentRangeEnd(1),
|
|
||||||
new TextRun({
|
|
||||||
children: [new CommentReference(1)],
|
|
||||||
bold: true,
|
|
||||||
}),
|
|
||||||
new CommentRangeEnd(2),
|
|
||||||
new TextRun({
|
|
||||||
children: [new CommentReference(2)],
|
|
||||||
bold: true,
|
|
||||||
}),
|
|
||||||
new CommentRangeEnd(3),
|
|
||||||
new TextRun({
|
|
||||||
children: [new CommentReference(3)],
|
|
||||||
bold: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Exporting the document as a stream
|
// Exporting the document as a stream
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
// Example of using tab stops
|
// Example of using tab stops
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "docx";
|
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
|
||||||
|
|
||||||
const columnWidth = TabStopPosition.MAX / 4;
|
const columnWidth = TabStopPosition.MAX / 4;
|
||||||
const receiptTabStops = [
|
const receiptTabStops = [
|
||||||
// no need to define first left tab column
|
// no need to define first left tab column
|
||||||
// the right aligned tab column position should point to the end of column
|
// the right aligned tab column position should point to the end of column
|
||||||
// i.e. in this case
|
// i.e. in this case
|
||||||
// (end position of 1st) + (end position of current)
|
// (end position of 1st) + (end position of current)
|
||||||
// columnWidth + columnWidth = columnWidth * 2
|
// columnWidth + columnWidth = columnWidth * 2
|
||||||
|
|
||||||
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
||||||
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
||||||
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
|
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
|
||||||
];
|
],
|
||||||
const twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add compatibility options
|
// Add compatibility options
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "docx";
|
import { Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
compatibility: {
|
compatibility: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Exporting the document as a stream
|
// Exporting the document as a stream
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "docx";
|
import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "../build";
|
||||||
|
|
||||||
const table1 = new Table({
|
const table1 = new Table({
|
||||||
columnWidths: [3505, 5505],
|
columnWidths: [3505, 5505],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Simple example to add text to a document
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Packer, Paragraph, TextRun } from "docx";
|
import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Example of how you would create a table and add data to it from a data source
|
// Example of how you would create a table and add data to it from a data source
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
@ -13,7 +13,7 @@ import {
|
|||||||
TextDirection,
|
TextDirection,
|
||||||
TextRun,
|
TextRun,
|
||||||
WidthType,
|
WidthType,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
interface StockPrice {
|
interface StockPrice {
|
||||||
readonly date: Date;
|
readonly date: Date;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Add text to header and footer
|
// Add text to header and footer
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, Paragraph } from "docx";
|
import { Document, Footer, Header, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Simple example to add text to a document
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, convertMillimetersToTwip, Document, Packer, Paragraph, TextRun } from "docx";
|
import { AlignmentType, convertMillimetersToTwip, Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of a continuous header
|
// Example of a continuous header
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, Paragraph, SectionType, TextRun } from "docx";
|
import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
creator: "Creator",
|
creator: "Creator",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example of using headers and footers in a new section
|
// Example of using headers and footers in a new section
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, Paragraph, TextRun } from "docx";
|
import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
creator: "Creator",
|
creator: "Creator",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Simple example to add text to a document
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph } from "docx";
|
import { Document, Packer, Paragraph } from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
// Simple example apply positional tabs to a document
|
// Simple example apply positional tabs to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
Packer,
|
Packer,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
PositionalTab,
|
PositionalTab,
|
||||||
|
Tab,
|
||||||
TextRun,
|
TextRun,
|
||||||
PositionalTabAlignment,
|
PositionalTabAlignment,
|
||||||
PositionalTabRelativeTo,
|
PositionalTabRelativeTo,
|
||||||
PositionalTabLeader,
|
PositionalTabLeader,
|
||||||
} from "docx";
|
} from "../build";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
|
@ -1,155 +0,0 @@
|
|||||||
// Patch a document with patches
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import {
|
|
||||||
ExternalHyperlink,
|
|
||||||
HeadingLevel,
|
|
||||||
ImageRun,
|
|
||||||
Paragraph,
|
|
||||||
patchDocument,
|
|
||||||
PatchType,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
TextDirection,
|
|
||||||
TextRun,
|
|
||||||
VerticalAlign,
|
|
||||||
} from "docx";
|
|
||||||
|
|
||||||
patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
|
|
||||||
patches: {
|
|
||||||
name: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new TextRun("Sir. "), new TextRun("John Doe"), new TextRun("(The Conqueror)")],
|
|
||||||
},
|
|
||||||
table_heading_1: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new TextRun("Heading wow!")],
|
|
||||||
},
|
|
||||||
item_1: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [
|
|
||||||
new TextRun("#657"),
|
|
||||||
new ExternalHyperlink({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "BBC News Link",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
link: "https://www.bbc.co.uk/news",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
paragraph_replace: {
|
|
||||||
type: PatchType.DOCUMENT,
|
|
||||||
children: [
|
|
||||||
new Paragraph("Lorem ipsum paragraph"),
|
|
||||||
new Paragraph("Another paragraph"),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("This is a "),
|
|
||||||
new ExternalHyperlink({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "Google Link",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
link: "https://www.google.co.uk",
|
|
||||||
}),
|
|
||||||
new ImageRun({ data: fs.readFileSync("./demo/images/dog.png"), transformation: { width: 100, height: 100 } }),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
header_adjective: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new TextRun("Delightful Header")],
|
|
||||||
},
|
|
||||||
footer_text: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [
|
|
||||||
new TextRun("replaced just as"),
|
|
||||||
new TextRun(" well"),
|
|
||||||
new ExternalHyperlink({
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "BBC News Link",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
link: "https://www.bbc.co.uk/news",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
image_test: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new ImageRun({ data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, height: 100 } })],
|
|
||||||
},
|
|
||||||
table: {
|
|
||||||
type: PatchType.DOCUMENT,
|
|
||||||
children: [
|
|
||||||
new Table({
|
|
||||||
rows: [
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph({}), new Paragraph({})],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph({}), new Paragraph({})],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
|
|
||||||
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
|
|
||||||
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "This text should be in the middle of the cell",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "Text above should be vertical from bottom to top",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "Text above should be vertical from top to bottom",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((doc) => {
|
|
||||||
fs.writeFileSync("My Document.docx", doc);
|
|
||||||
});
|
|
@ -1,20 +0,0 @@
|
|||||||
// Generate a template document
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Packer, Paragraph, TextRun } from "docx";
|
|
||||||
|
|
||||||
const doc = new Document({
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("{{template}}")],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
|
||||||
fs.writeFileSync("My Document.docx", buffer);
|
|
||||||
});
|
|
@ -1,15 +0,0 @@
|
|||||||
// Patch a document with patches
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { patchDocument, PatchType, TextRun } from "docx";
|
|
||||||
|
|
||||||
patchDocument(fs.readFileSync("demo/assets/simple-template-2.docx"), {
|
|
||||||
patches: {
|
|
||||||
name: {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new TextRun("Max")],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((doc) => {
|
|
||||||
fs.writeFileSync("My Document.docx", doc);
|
|
||||||
});
|
|
@ -1,31 +0,0 @@
|
|||||||
// Patch a document with patches
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { IPatch, patchDocument, PatchType, TextRun } from "docx";
|
|
||||||
|
|
||||||
export const font = "Trebuchet MS";
|
|
||||||
export const getPatches = (fields: { [key: string]: string }) => {
|
|
||||||
const patches: { [key: string]: IPatch } = {};
|
|
||||||
|
|
||||||
for (const field in fields) {
|
|
||||||
patches[field] = {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new TextRun({ text: fields[field], font })],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return patches;
|
|
||||||
};
|
|
||||||
|
|
||||||
const patches = getPatches({
|
|
||||||
name: "Mr",
|
|
||||||
table_heading_1: "John",
|
|
||||||
item_1: "Doe",
|
|
||||||
paragraph_replace: "Lorem ipsum paragraph",
|
|
||||||
});
|
|
||||||
|
|
||||||
patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
|
|
||||||
patches,
|
|
||||||
}).then((doc) => {
|
|
||||||
fs.writeFileSync("My Document.docx", doc);
|
|
||||||
});
|
|
@ -1,29 +0,0 @@
|
|||||||
// Patch a document with patches
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { IPatch, patchDocument, PatchType, TextRun } from "docx";
|
|
||||||
|
|
||||||
export const font = "Trebuchet MS";
|
|
||||||
export const getPatches = (fields: { [key: string]: string }) => {
|
|
||||||
const patches: { [key: string]: IPatch } = {};
|
|
||||||
|
|
||||||
for (const field in fields) {
|
|
||||||
patches[field] = {
|
|
||||||
type: PatchType.PARAGRAPH,
|
|
||||||
children: [new TextRun({ text: fields[field], font })],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return patches;
|
|
||||||
};
|
|
||||||
|
|
||||||
const patches = getPatches({
|
|
||||||
salutation: "Mr.",
|
|
||||||
"first-name": "John",
|
|
||||||
});
|
|
||||||
|
|
||||||
patchDocument(fs.readFileSync("demo/assets/simple-template-3.docx"), {
|
|
||||||
patches,
|
|
||||||
}).then((doc) => {
|
|
||||||
fs.writeFileSync("My Document.docx", doc);
|
|
||||||
});
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user