Compare commits

...

24 Commits
7.0.0 ... 7.1.0

Author SHA1 Message Date
34da2f4289 Update lock file 2021-09-29 00:49:38 +01:00
b986403656 Version bump 2021-09-28 22:20:05 +01:00
5cba664f70 Merge branch 'master' of github.com:dolanmiu/docx 2021-09-28 22:08:57 +01:00
9a35029f16 Merge pull request #1196 from mattpow/mpowell/suppress-line-numbers
Add suppressLineNumber option to Paragraph
2021-09-28 22:08:42 +01:00
3c768c5630 Update 70-line-numbers-suppression.ts 2021-09-28 12:22:59 -07:00
f77ddb4037 Add tests for suppressLineNumbers 2021-09-28 12:21:51 -07:00
536204e5ef Add back types absolute fixer 2021-09-28 19:56:29 +01:00
1f078e0687 Merge pull request #1199 from anti-the-social/table-width-percent-unit-handling
Table width percent unit handling
2021-09-28 18:54:30 +01:00
705b1f7cfc Fix to table percent width test + additional test on DXA table width 2021-09-28 16:16:50 +03:00
28233075bd Append % if type is "pct" (WidthType.PERCENTAGE) 2021-09-28 15:57:33 +03:00
f1627c378d Merge pull request #1188 from dolanmiu/dependabot/npm_and_yarn/mocha-9.1.2
Bump mocha from 9.1.1 to 9.1.2
2021-09-28 13:02:08 +01:00
0aa5510b9c Merge pull request #1189 from dolanmiu/dependabot/npm_and_yarn/types/sinon-10.0.4
Bump @types/sinon from 10.0.3 to 10.0.4
2021-09-28 13:01:57 +01:00
3d9216e8bf Merge pull request #1190 from dolanmiu/dependabot/npm_and_yarn/types/node-16.10.1
Bump @types/node from 16.9.6 to 16.10.1
2021-09-28 13:01:11 +01:00
054ece38ab Merge pull request #1191 from dolanmiu/dependabot/npm_and_yarn/webpack-5.54.0
Bump webpack from 5.53.0 to 5.54.0
2021-09-28 13:01:01 +01:00
951094c6fb Merge pull request #1192 from dolanmiu/dependabot/npm_and_yarn/nanoid-3.1.28
Bump nanoid from 3.1.25 to 3.1.28
2021-09-28 13:00:52 +01:00
ea01ddb337 Update Paragraph/properties.ts with supressLineNumber docs 2021-09-27 19:18:58 -07:00
34036bca8f Add suppressLineNumber option to Paragraph 2021-09-27 19:11:09 -07:00
0256968240 Remove Travis CI 2021-09-28 00:45:51 +01:00
1f894303d3 Bump nanoid from 3.1.25 to 3.1.28
Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.25 to 3.1.28.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.1.25...3.1.28)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 11:02:18 +00:00
c79e9ded71 Bump webpack from 5.53.0 to 5.54.0
Bumps [webpack](https://github.com/webpack/webpack) from 5.53.0 to 5.54.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.53.0...v5.54.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 11:02:02 +00:00
0d72de7e53 Bump @types/node from 16.9.6 to 16.10.1
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.9.6 to 16.10.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 11:01:46 +00:00
750368ac08 Bump @types/sinon from 10.0.3 to 10.0.4
Bumps [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/sinon) from 10.0.3 to 10.0.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/sinon)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 11:01:12 +00:00
4394a9b575 Bump mocha from 9.1.1 to 9.1.2
Bumps [mocha](https://github.com/mochajs/mocha) from 9.1.1 to 9.1.2.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v9.1.1...v9.1.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 11:00:59 +00:00
4c58e3c47d Merge pull request #3 from dolanmiu/master
merge latest changes from Dolans master
2021-09-23 10:38:47 +03:00
11 changed files with 176 additions and 113 deletions

View File

@ -10,7 +10,6 @@
[![NPM version][npm-image]][npm-url] [![NPM version][npm-image]][npm-url]
[![Downloads per month][downloads-image]][downloads-url] [![Downloads per month][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url] [![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
[![Dependency Status][daviddm-image]][daviddm-url] [![Dependency Status][daviddm-image]][daviddm-url]
[![Known Vulnerabilities][snky-image]][snky-url] [![Known Vulnerabilities][snky-image]][snky-url]
@ -103,8 +102,6 @@ Made with 💖
[npm-url]: https://npmjs.org/package/docx [npm-url]: https://npmjs.org/package/docx
[downloads-image]: https://img.shields.io/npm/dm/docx.svg [downloads-image]: https://img.shields.io/npm/dm/docx.svg
[downloads-url]: https://npmjs.org/package/docx [downloads-url]: https://npmjs.org/package/docx
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
[travis-url]: https://travis-ci.org/dolanmiu/docx
[github-actions-workflow-image]: https://github.com/dolanmiu/docx/workflows/Default/badge.svg [github-actions-workflow-image]: https://github.com/dolanmiu/docx/workflows/Default/badge.svg
[github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions [github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io [daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io

View File

@ -0,0 +1,37 @@
// Example demonstrating line numbers with suppression.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
const doc = new Document({
sections: [
{
properties: {
lineNumbers: {
countBy: 1,
restart: LineNumberRestartFormat.CONTINUOUS,
},
},
children: [
new Paragraph({
text: "Hello",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph(
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
),
new Paragraph({
text: 'Enim mollit nostrud ut dolor eiusmod id sit occaecat dolore culpa amet. Veniam dolor consequat dolor labore ullamco laborum dolore eiusmod qui adipisicing. Elit nulla cupidatat et magna. Id eiusmod tempor non laborum ipsum. Veniam et aliqua excepteur duis officia enim elit excepteur fugiat duis. Sit sunt ullamco non dolor est qui deserunt consequat magna. Esse pariatur esse dolor ut excepteur dolor nisi nisi non est cupidatat mollit.',
suppressLineNumbers: true
}),
new Paragraph(
"Sed laoreet id mattis egestas nam mollis elit lacinia convallis dui tincidunt ultricies habitant, pharetra per maximus interdum neque tempor risus efficitur morbi imperdiet senectus. Lectus laoreet senectus finibus inceptos donec potenti fermentum, ultrices eleifend odio suscipit magnis tellus maximus nibh, ac sit nullam eget felis himenaeos. Diam class sem magnis aenean commodo faucibus id proin mi, nullam sodales nec mus parturient ornare ad inceptos velit hendrerit, bibendum placerat eleifend integer facilisis urna dictumst suspendisse.",
),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

168
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "docx", "name": "docx",
"version": "7.0.0", "version": "7.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -590,9 +590,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "16.9.6", "version": "16.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.6.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.1.tgz",
"integrity": "sha512-YHUZhBOMTM3mjFkXVcK+WwAcYmyhe1wL4lfqNtzI0b3qAy7yuSetnM7QJazgE5PFmgVTNGiLOgRFfJMqW7XpSQ==" "integrity": "sha512-4/Z9DMPKFexZj/Gn3LylFgamNKHm4K3QDi0gz9B26Uk0c8izYf97B5fxfpspMNkWlFupblKM/nV8+NA9Ffvr+w=="
}, },
"@types/request": { "@types/request": {
"version": "2.48.6", "version": "2.48.6",
@ -630,9 +630,9 @@
} }
}, },
"@types/sinon": { "@types/sinon": {
"version": "10.0.3", "version": "10.0.4",
"resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.4.tgz",
"integrity": "sha512-XUaFuUOQ3A/r6gS1qCU/USMleascaqGeQpGR1AZ5JdRtBPlzijRzKsik1TuGzvdtPA0mdq42JqaJmJ+Afg1LJg==", "integrity": "sha512-fOYjrxQv8zJsqOY6V6ecP4eZhQBxtY80X0er1VVnUIAIZo74jHm8e1vguG5Yt4Iv8W2Wr7TgibB8MfRe32k9pA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@sinonjs/fake-timers": "^7.1.0" "@sinonjs/fake-timers": "^7.1.0"
@ -1193,24 +1193,16 @@
"dev": true "dev": true
}, },
"browserslist": { "browserslist": {
"version": "4.17.0", "version": "4.17.1",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.0.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.1.tgz",
"integrity": "sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g==", "integrity": "sha512-aLD0ZMDSnF4lUt4ZDNgqi5BUn9BZ7YdQdI/cYlILrhdSSZJLU9aNZoD5/NBmM4SK34APB2e83MOsRt1EnkuyaQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"caniuse-lite": "^1.0.30001254", "caniuse-lite": "^1.0.30001259",
"colorette": "^1.3.0", "electron-to-chromium": "^1.3.846",
"electron-to-chromium": "^1.3.830",
"escalade": "^3.1.1", "escalade": "^3.1.1",
"node-releases": "^1.1.75" "nanocolors": "^0.1.5",
}, "node-releases": "^1.1.76"
"dependencies": {
"colorette": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.4.0.tgz",
"integrity": "sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==",
"dev": true
}
} }
}, },
"buffer": { "buffer": {
@ -1300,10 +1292,13 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001258", "version": "1.0.30001260",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001258.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001260.tgz",
"integrity": "sha512-RBByOG6xWXUp0CR2/WU2amXz3stjKpSl5J1xU49F1n2OxD//uBZO4wCKUiG+QMGf7CHGfDDcqoKriomoGVxTeA==", "integrity": "sha512-Fhjc/k8725ItmrvW5QomzxLeojewxvqiYCKeFcfFEhut28IVLdpHU19dneOmltZQIE5HNbawj1HYD+1f2bM1Dg==",
"dev": true "dev": true,
"requires": {
"nanocolors": "^0.1.0"
}
}, },
"caseless": { "caseless": {
"version": "0.12.0", "version": "0.12.0",
@ -1923,9 +1918,9 @@
"dev": true "dev": true
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.842", "version": "1.3.850",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.842.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.850.tgz",
"integrity": "sha512-P/nDMPIYdb2PyqCQwhTXNi5JFjX1AsDVR0y6FrHw752izJIAJ+Pn5lugqyBq4tXeRSZBMBb2ZGvRGB1djtELEQ==", "integrity": "sha512-ZzkDcdzePeF4dhoGZQT77V2CyJOpwfTZEOg4h0x6R/jQhGt/rIRpbRyVreWLtD7B/WsVxo91URm2WxMKR9JQZA==",
"dev": true "dev": true
}, },
"emoji-regex": { "emoji-regex": {
@ -1983,9 +1978,9 @@
"dev": true "dev": true
}, },
"es-module-lexer": { "es-module-lexer": {
"version": "0.7.1", "version": "0.9.0",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.7.1.tgz", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.0.tgz",
"integrity": "sha512-MgtWFl5No+4S3TmhDmCz2ObFGm6lEpTnzbQi+Dd+pw4mlTIZTmM2iAs5gRlmx5zS9luzobCSBSI90JM/1/JgOw==", "integrity": "sha512-qU2eN/XHsrl3E4y7mK1wdWnyy5c8gXtCbfP6Xcsemm7fPUR1PIV1JhZfP7ojcN0Fzp69CfrS3u76h2tusvfKiQ==",
"dev": true "dev": true
}, },
"es6-error": { "es6-error": {
@ -2999,9 +2994,9 @@
} }
}, },
"jest-worker": { "jest-worker": {
"version": "27.2.0", "version": "27.2.2",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.2.0.tgz", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.2.2.tgz",
"integrity": "sha512-laB0ZVIBz+voh/QQy9dmUuuDsadixeerrKqyVpgPz+CCWiOYjOBabUXHIXZhsdvkWbLqSHbgkAHWl5cg24Q6RA==", "integrity": "sha512-aG1xq9KgWB2CPC8YdMIlI8uZgga2LFNcGbHJxO8ctfXAydSaThR4EewKQGg3tBOC+kS3vhPGgymsBdi9VINjPw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "*", "@types/node": "*",
@ -3512,16 +3507,16 @@
"dev": true "dev": true
}, },
"mocha": { "mocha": {
"version": "9.1.1", "version": "9.1.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.1.tgz", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.2.tgz",
"integrity": "sha512-0wE74YMgOkCgBUj8VyIDwmLUjTsS13WV1Pg7l0SHea2qzZzlq7MDnfbPsHKcELBRk3+izEVkRofjmClpycudCA==", "integrity": "sha512-ta3LtJ+63RIBP03VBjMGtSqbe6cWXRejF9SyM9Zyli1CKZJZ+vfCTj3oW24V7wAphMJdpOFLoMI3hjJ1LWbs0w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@ungap/promise-all-settled": "1.1.2", "@ungap/promise-all-settled": "1.1.2",
"ansi-colors": "4.1.1", "ansi-colors": "4.1.1",
"browser-stdout": "1.3.1", "browser-stdout": "1.3.1",
"chokidar": "3.5.2", "chokidar": "3.5.2",
"debug": "4.3.1", "debug": "4.3.2",
"diff": "5.0.0", "diff": "5.0.0",
"escape-string-regexp": "4.0.0", "escape-string-regexp": "4.0.0",
"find-up": "5.0.0", "find-up": "5.0.0",
@ -3532,12 +3527,11 @@
"log-symbols": "4.1.0", "log-symbols": "4.1.0",
"minimatch": "3.0.4", "minimatch": "3.0.4",
"ms": "2.1.3", "ms": "2.1.3",
"nanoid": "3.1.23", "nanoid": "3.1.25",
"serialize-javascript": "6.0.0", "serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1", "strip-json-comments": "3.1.1",
"supports-color": "8.1.1", "supports-color": "8.1.1",
"which": "2.0.2", "which": "2.0.2",
"wide-align": "1.1.3",
"workerpool": "6.1.5", "workerpool": "6.1.5",
"yargs": "16.2.0", "yargs": "16.2.0",
"yargs-parser": "20.2.4", "yargs-parser": "20.2.4",
@ -3551,9 +3545,9 @@
"dev": true "dev": true
}, },
"debug": { "debug": {
"version": "4.3.1", "version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
"dev": true, "dev": true,
"requires": { "requires": {
"ms": "2.1.2" "ms": "2.1.2"
@ -3609,9 +3603,9 @@
"dev": true "dev": true
}, },
"nanoid": { "nanoid": {
"version": "3.1.23", "version": "3.1.25",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz",
"integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==", "integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==",
"dev": true "dev": true
}, },
"strip-json-comments": { "strip-json-comments": {
@ -3658,10 +3652,16 @@
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true "dev": true
}, },
"nanocolors": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/nanocolors/-/nanocolors-0.1.12.tgz",
"integrity": "sha512-2nMHqg1x5PU+unxX7PGY7AuYxl2qDx7PSrTRjizr8sxdd3l/3hBuWWaki62qmtYm2U5i4Z5E7GbjlyDFhs9/EQ==",
"dev": true
},
"nanoid": { "nanoid": {
"version": "3.1.25", "version": "3.1.28",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.28.tgz",
"integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==" "integrity": "sha512-gSu9VZ2HtmoKYe/lmyPFES5nknFrHa+/DT9muUFWFMi6Jh9E1I7bkvlQ8xxf1Kos9pi9o8lBnIOkatMhKX/YUw=="
}, },
"neo-async": { "neo-async": {
"version": "2.6.2", "version": "2.6.2",
@ -3704,9 +3704,9 @@
} }
}, },
"node-releases": { "node-releases": {
"version": "1.1.75", "version": "1.1.76",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.76.tgz",
"integrity": "sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw==", "integrity": "sha512-9/IECtNr8dXNmPWmFXepT0/7o5eolGesHUa3mtr0KlgnCvnZxwh2qensKL42JJY2vQKC3nIBXetFAqR+PW1CmA==",
"dev": true "dev": true
}, },
"normalize-path": { "normalize-path": {
@ -4984,33 +4984,6 @@
} }
} }
}, },
"string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"dev": true,
"requires": {
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"dev": true,
"requires": {
"ansi-regex": "^3.0.0"
}
}
}
},
"string_decoder": { "string_decoder": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
@ -5077,9 +5050,9 @@
"dev": true "dev": true
}, },
"terser": { "terser": {
"version": "5.8.0", "version": "5.9.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.8.0.tgz", "resolved": "https://registry.npmjs.org/terser/-/terser-5.9.0.tgz",
"integrity": "sha512-f0JH+6yMpneYcRJN314lZrSwu9eKkUFEHLN/kNy8ceh8gaRiLgFPJqrB9HsXjhEGdv4e/ekjTOFxIlL6xlma8A==", "integrity": "sha512-h5hxa23sCdpzcye/7b8YqbE5OwKca/ni0RQz1uRX3tGh8haaGHqcuSqbGRybuAKNdntZ0mDgFNXPJ48xQ2RXKQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"commander": "^2.20.0", "commander": "^2.20.0",
@ -5615,9 +5588,9 @@
} }
}, },
"webpack": { "webpack": {
"version": "5.53.0", "version": "5.54.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.53.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.54.0.tgz",
"integrity": "sha512-RZ1Z3z3ni44snoWjfWeHFyzvd9HMVYDYC5VXmlYUT6NWgEOWdCNpad5Fve2CzzHoRED7WtsKe+FCyP5Vk4pWiQ==", "integrity": "sha512-MAVKJMsIUotOQKzFOmN8ZkmMlj7BOyjDU6t1lomW9dWOme5WTStzGa3HMLdV1KYD1AiFETGsznL4LMSvj4tukw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -5629,8 +5602,8 @@
"acorn-import-assertions": "^1.7.6", "acorn-import-assertions": "^1.7.6",
"browserslist": "^4.14.5", "browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2", "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.8.0", "enhanced-resolve": "^5.8.3",
"es-module-lexer": "^0.7.1", "es-module-lexer": "^0.9.0",
"eslint-scope": "5.1.1", "eslint-scope": "5.1.1",
"events": "^3.2.0", "events": "^3.2.0",
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",
@ -5646,6 +5619,16 @@
"webpack-sources": "^3.2.0" "webpack-sources": "^3.2.0"
}, },
"dependencies": { "dependencies": {
"enhanced-resolve": {
"version": "5.8.3",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.8.3.tgz",
"integrity": "sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
}
},
"graceful-fs": { "graceful-fs": {
"version": "4.2.8", "version": "4.2.8",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
@ -5723,15 +5706,6 @@
"isexe": "^2.0.0" "isexe": "^2.0.0"
} }
}, },
"wide-align": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
"integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==",
"dev": true,
"requires": {
"string-width": "^1.0.2 || 2"
}
},
"widest-line": { "widest-line": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "docx", "name": "docx",
"version": "7.0.0", "version": "7.1.0",
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.", "description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
"main": "build/index.js", "main": "build/index.js",
"scripts": { "scripts": {
@ -10,7 +10,7 @@
"test.watch": "npm test -- --watch", "test.watch": "npm test -- --watch",
"prepublishOnly": "npm run build --production", "prepublishOnly": "npm run build --production",
"lint": "tslint --project .", "lint": "tslint --project .",
"build": "npm run webpack", "build": "npm run webpack && npm run fix-types",
"webpack": "rimraf ./build && webpack --config ./webpack.config.ts", "webpack": "rimraf ./build && webpack --config ./webpack.config.ts",
"demo": "npm run build && npm run ts-node --skip-project ./demo", "demo": "npm run build && npm run ts-node --skip-project ./demo",
"typedoc": "rimraf ./build && typedoc src/index.ts --tsconfig tsconfig.typedoc.json", "typedoc": "rimraf ./build && typedoc src/index.ts --tsconfig tsconfig.typedoc.json",

View File

@ -1,18 +1,16 @@
import * as glob from "glob"; import * as glob from "glob";
import * as replace from "replace-in-file"; import { replaceInFile } from "replace-in-file";
const files = glob.sync("build/**/*.d.ts"); const files = glob.sync("build/**/*.d.ts");
for (const file of files) { for (const file of files) {
replace({ replaceInFile({
files: file, files: file,
from: /"file[a-z/-]*"/gi, from: /"file[a-z/-]*"/gi,
to: (match) => { to: (match) => {
const matchSlug = match.replace(/['"]+/g, "").trim(); const matchSlug = match.replace(/['"]+/g, "").trim();
const levelCount = file.split("/").length - 2; const levelCount = file.split("/").length - 2;
const backLevels = Array(levelCount) const backLevels = Array(levelCount).fill("../").join("");
.fill("../")
.join("");
return `"${backLevels}${matchSlug}"`; return `"${backLevels}${matchSlug}"`;
}, },

View File

@ -1,7 +1,7 @@
// http://officeopenxml.com/WPparagraph-textFrames.php // http://officeopenxml.com/WPparagraph-textFrames.php
import { HeightRule } from "file";
import { HorizontalPositionAlign, VerticalPositionAlign } from "file/shared/alignment"; import { HorizontalPositionAlign, VerticalPositionAlign } from "file/shared/alignment";
import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { HeightRule } from "/file";
export enum DropCapType { export enum DropCapType {
NONE = "none", NONE = "none",

View File

@ -830,6 +830,18 @@ describe("Paragraph", () => {
}); });
}); });
describe("#suppressLineNumbers", () => {
it("should disable line numbers", () => {
const paragraph = new Paragraph({
suppressLineNumbers: true,
});
const tree = new Formatter().format(paragraph);
expect(tree).to.deep.equal({
"w:p": [{ "w:pPr": [{ "w:suppressLineNumbers": EMPTY_OBJECT }] }],
});
});
});
describe("#outlineLevel", () => { describe("#outlineLevel", () => {
it("should set paragraph outline level to the given value", () => { it("should set paragraph outline level to the given value", () => {
const paragraph = new Paragraph({ const paragraph = new Paragraph({

View File

@ -1,4 +1,5 @@
// http://officeopenxml.com/WPparagraphProperties.php // http://officeopenxml.com/WPparagraphProperties.php
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_suppressLineNumbers_topic_ID0ECJAO.html
import { IContext, IgnoreIfEmptyXmlComponent, IXmlableObject, OnOffElement, XmlComponent } from "file/xml-components"; import { IContext, IgnoreIfEmptyXmlComponent, IXmlableObject, OnOffElement, XmlComponent } from "file/xml-components";
import { DocumentWrapper } from "../document-wrapper"; import { DocumentWrapper } from "../document-wrapper";
import { IShadingAttributesProperties, Shading } from "../shading"; import { IShadingAttributesProperties, Shading } from "../shading";
@ -52,6 +53,7 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
readonly shading?: IShadingAttributesProperties; readonly shading?: IShadingAttributesProperties;
readonly widowControl?: boolean; readonly widowControl?: boolean;
readonly frame?: IFrameOptions; readonly frame?: IFrameOptions;
readonly suppressLineNumbers?: boolean;
} }
export class ParagraphProperties extends IgnoreIfEmptyXmlComponent { export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
@ -166,6 +168,10 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
if (options.outlineLevel !== undefined) { if (options.outlineLevel !== undefined) {
this.push(new OutlineLevel(options.outlineLevel)); this.push(new OutlineLevel(options.outlineLevel));
} }
if (options.suppressLineNumbers !== undefined) {
this.push(new OnOffElement("w:suppressLineNumbers", options.suppressLineNumbers));
}
} }
public push(item: XmlComponent): void { public push(item: XmlComponent): void {

View File

@ -38,6 +38,10 @@ export class TableWidthElement extends XmlComponent {
constructor(name: string, { type = WidthType.AUTO, size }: ITableWidthProperties) { constructor(name: string, { type = WidthType.AUTO, size }: ITableWidthProperties) {
super(name); super(name);
// super("w:tblW"); // super("w:tblW");
this.root.push(new TableWidthAttributes({ type: type, size: measurementOrPercentValue(size) })); let tableWidthValue = size;
if (type === WidthType.PERCENTAGE && typeof size === "number") {
tableWidthValue = `${size}%`;
}
this.root.push(new TableWidthAttributes({ type: type, size: measurementOrPercentValue(tableWidthValue) }));
} }
} }

View File

@ -257,7 +257,7 @@ describe("Table", () => {
}); });
}); });
it("should set the table to provided width", () => { it("should set the table to provided 100% width", () => {
const table = new Table({ const table = new Table({
rows: [ rows: [
new TableRow({ new TableRow({
@ -282,7 +282,42 @@ describe("Table", () => {
"w:tblW": { "w:tblW": {
_attr: { _attr: {
"w:type": "pct", "w:type": "pct",
"w:w": 100, "w:w": "100%",
},
},
},
BORDERS,
{ "w:tblLayout": { _attr: { "w:type": "fixed" } } },
],
});
});
it("should set the table to provided 1000 DXA", () => {
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("hello")],
}),
],
}),
],
width: {
size: 1000,
type: WidthType.DXA,
},
layout: TableLayoutType.FIXED,
});
const tree = new Formatter().format(table);
expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1);
expect(tree["w:tbl"][0]).to.deep.equal({
"w:tblPr": [
{
"w:tblW": {
_attr: {
"w:type": "dxa",
"w:w": 1000,
}, },
}, },
}, },

View File

@ -13,9 +13,9 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"baseUrl": "./src", "baseUrl": "./src",
"paths": { "paths": {
"/*": ["./*"],
"convenience-functions": ["./convenience-functions"], "convenience-functions": ["./convenience-functions"],
"@export/*": ["./export/*"] "@export/*": ["./export/*"],
"file/*": ["./file/*"]
} }
}, },
"include": ["src"] "include": ["src"]