Compare commits

..

28 Commits

Author SHA1 Message Date
74e2259b5c Don't throw "token not found" 2025-06-10 15:26:56 +00:00
88ddfa79be build(deps): bump @types/node from 22.15.3 to 22.15.27 (#3127)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.15.3 to 22.15.27.
- [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-version: 22.15.27
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-31 14:32:01 +01:00
f6ee55a947 build(deps-dev): bump typescript-eslint from 8.30.1 to 8.33.0 (#3122)
Bumps [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) from 8.30.1 to 8.33.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.33.0/packages/typescript-eslint)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-31 14:31:38 +01:00
b8cc44a31b build(deps-dev): bump @vitest/coverage-v8 from 3.1.2 to 3.1.4 (#3116)
Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 3.1.2 to 3.1.4.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v3.1.4/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-v8"
  dependency-version: 3.1.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-31 14:31:31 +01:00
e1a478cd72 build(deps-dev): bump eslint-plugin-unicorn from 59.0.0 to 59.0.1 (#3095)
Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 59.0.0 to 59.0.1.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v59.0.0...v59.0.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-31 14:31:24 +01:00
e39bed6032 build(deps-dev): bump @types/inquirer from 9.0.7 to 9.0.8 (#3094)
Bumps [@types/inquirer](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/inquirer) from 9.0.7 to 9.0.8.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/inquirer)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-31 14:31:16 +01:00
495f2e4888 Version bump 2025-05-05 23:44:24 +01:00
ba292d07f7 build(deps-dev): bump eslint-plugin-unicorn from 58.0.0 to 59.0.0 (#3089)
Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 58.0.0 to 59.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v58.0.0...v59.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:43:37 +01:00
db8a5be998 build(deps-dev): bump cspell from 8.19.2 to 9.0.0 (#3093)
Bumps [cspell](https://github.com/streetsidesoftware/cspell/tree/HEAD/packages/cspell) from 8.19.2 to 9.0.0.
- [Release notes](https://github.com/streetsidesoftware/cspell/releases)
- [Changelog](https://github.com/streetsidesoftware/cspell/blob/main/packages/cspell/CHANGELOG.md)
- [Commits](https://github.com/streetsidesoftware/cspell/commits/v9.0.0/packages/cspell)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:42:36 +01:00
a7a6b69004 build(deps-dev): bump vite from 6.3.4 to 6.3.5 (#3092)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.3.4 to 6.3.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.3.5/packages/vite)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:39:00 +01:00
b60f940994 build(deps-dev): bump tsx from 4.19.3 to 4.19.4 (#3091)
Bumps [tsx](https://github.com/privatenumber/tsx) from 4.19.3 to 4.19.4.
- [Release notes](https://github.com/privatenumber/tsx/releases)
- [Changelog](https://github.com/privatenumber/tsx/blob/master/release.config.cjs)
- [Commits](https://github.com/privatenumber/tsx/compare/v4.19.3...v4.19.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:38:52 +01:00
afa3374376 build(deps-dev): bump typedoc from 0.28.3 to 0.28.4 (#3090)
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.28.3 to 0.28.4.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Changelog](https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.28.3...v0.28.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:38:31 +01:00
45795bf43d build(deps-dev): bump eslint from 9.25.1 to 9.26.0 (#3088)
Bumps [eslint](https://github.com/eslint/eslint) from 9.25.1 to 9.26.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.25.1...v9.26.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:38:07 +01:00
bd7321d221 build(deps-dev): bump @typescript-eslint/eslint-plugin (#3084)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 8.30.1 to 8.31.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.31.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-version: 8.31.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-05 23:37:52 +01:00
aa2d72507c build(deps-dev): bump vite from 6.3.2 to 6.3.4 (#3086)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.3.2 to 6.3.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.3.4/packages/vite)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-03 23:56:03 +01:00
a2755f57f4 build(deps-dev): bump @typescript-eslint/parser from 8.30.1 to 8.31.1 (#3083)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 8.30.1 to 8.31.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.31.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-version: 8.31.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-03 23:55:37 +01:00
a604677a37 build(deps): bump @types/node from 22.14.1 to 22.15.3 (#3082)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.14.1 to 22.15.3.
- [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-version: 22.15.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-03 23:55:29 +01:00
e3436de693 build(deps-dev): bump eslint-plugin-jsdoc from 50.6.9 to 50.6.11 (#3081)
Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 50.6.9 to 50.6.11.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc)
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v50.6.9...v50.6.11)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-03 23:55:17 +01:00
e2f4556ac3 build(deps-dev): bump glob from 11.0.1 to 11.0.2 (#3077)
Bumps [glob](https://github.com/isaacs/node-glob) from 11.0.1 to 11.0.2.
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v11.0.1...v11.0.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-02 20:08:16 +01:00
42151c1534 build(deps-dev): bump inquirer from 12.5.2 to 12.6.0 (#3075)
Bumps [inquirer](https://github.com/SBoudrias/Inquirer.js) from 12.5.2 to 12.6.0.
- [Release notes](https://github.com/SBoudrias/Inquirer.js/releases)
- [Commits](https://github.com/SBoudrias/Inquirer.js/compare/inquirer@12.5.2...inquirer@12.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-02 20:08:08 +01:00
7d1129900f Fix: separate vertical alignment enums for ITableCellOptions and ISectionPropertiesOptions (#3079)
* fix: separate vertical alignment enums for table and section properties

- Introduced `VerticalAlignTable` for table-cell vertical alignment with valid values: `top`, `center`, and `bottom`.
- Added `VerticalAlignSection` for section properties, extending `VerticalAlignTable` with an additional value `both`.
- Marked the original `VerticalAlign` as deprecated for backward compatibility, directing users to the new enums.
- Updated type definitions for better clarity on valid vertical alignments.

* refactor: update vertical alignment imports and types for section and table properties

- Renamed `VerticalAlign` to `VerticalAlignSection` in section properties and `VerticalAlignTable` in table-cell properties for clarity.
- Updated type definitions to reflect the new enum names, ensuring better organization and understanding of vertical alignment options.
- Adjusted related test cases to utilize the new imports and types.

* refactor: update demos to use new enums for table and section properties for vertical alignment
2025-05-02 19:58:10 +01:00
1e6c9e1772 fix: omit empty descr/title in <wp:docPr> for Word 2007 compatibility (#3073) 2025-05-02 19:55:22 +01:00
c38d0a253e build(deps-dev): bump eslint from 9.24.0 to 9.25.1 (#3068)
Bumps [eslint](https://github.com/eslint/eslint) from 9.24.0 to 9.25.1.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.24.0...v9.25.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-22 22:18:00 +01:00
89464ea7fc build(deps-dev): bump eslint-import-resolver-typescript (#3067)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 4.3.2 to 4.3.4.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v4.3.2...v4.3.4)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-version: 4.3.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-22 22:17:52 +01:00
61ed317f24 build(deps-dev): bump typedoc from 0.28.2 to 0.28.3 (#3065)
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.28.2 to 0.28.3.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Changelog](https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.28.2...v0.28.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-22 22:17:40 +01:00
b1bb95df79 build(deps-dev): bump cspell from 8.19.0 to 8.19.2 (#3064)
Bumps [cspell](https://github.com/streetsidesoftware/cspell/tree/HEAD/packages/cspell) from 8.19.0 to 8.19.2.
- [Release notes](https://github.com/streetsidesoftware/cspell/releases)
- [Changelog](https://github.com/streetsidesoftware/cspell/blob/main/packages/cspell/CHANGELOG.md)
- [Commits](https://github.com/streetsidesoftware/cspell/commits/v8.19.2/packages/cspell)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-22 22:17:31 +01:00
2b73c243f3 build(deps-dev): bump @vitest/coverage-v8 from 3.1.1 to 3.1.2 (#3059)
Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v3.1.2/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-v8"
  dependency-version: 3.1.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-22 22:17:17 +01:00
f29c2687dd build(deps-dev): bump vite from 6.3.1 to 6.3.2 (#3058)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.3.1 to 6.3.2.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.3.2/packages/vite)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-22 22:17:09 +01:00
18 changed files with 2624 additions and 1474 deletions

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it
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, VerticalAlignTable, TextDirection } from "docx";
const doc = new Document({
sections: [
@ -13,11 +13,11 @@ const doc = new Document({
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
@ -45,7 +45,7 @@ const doc = new Document({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -53,7 +53,7 @@ const doc = new Document({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -61,7 +61,7 @@ const doc = new Document({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
],
}),

View File

@ -1,13 +1,13 @@
// Example of making content of section vertically aligned
import * as fs from "fs";
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "docx";
import { Document, Packer, Paragraph, VerticalAlignSection, TextRun, Tab } from "docx";
const doc = new Document({
sections: [
{
properties: {
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignSection.CENTER,
},
children: [
new Paragraph({

View File

@ -12,7 +12,7 @@ import {
TableCell,
TableRow,
TextDirection,
VerticalAlign,
VerticalAlignTable,
} from "docx";
const table = new Table({
@ -102,11 +102,11 @@ const noBorderTable = new Table({
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
@ -134,7 +134,7 @@ const noBorderTable = new Table({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -142,7 +142,7 @@ const noBorderTable = new Table({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -150,7 +150,7 @@ const noBorderTable = new Table({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
],
}),

View File

@ -1,7 +1,7 @@
// The demo on the README.md
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, VerticalAlignTable } from "docx";
const table = new Table({
rows: [
@ -13,6 +13,7 @@ const table = new Table({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
type: "jpg",
transformation: {
width: 100,
height: 100,
@ -21,7 +22,7 @@ const table = new Table({
],
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -30,7 +31,7 @@ const table = new Table({
heading: HeadingLevel.HEADING_1,
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
],
}),
@ -50,6 +51,7 @@ const table = new Table({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
type: "jpg",
transformation: {
width: 100,
height: 100,
@ -77,6 +79,7 @@ const doc = new Document({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
type: "gif",
transformation: {
width: 100,
height: 100,

View File

@ -9,7 +9,7 @@ import {
Table,
TableCell,
TableRow,
VerticalAlign,
VerticalAlignTable,
TextDirection,
TextRun,
WidthType,
@ -101,17 +101,17 @@ const generateRows = (prices: StockPrice[]): TableRow[] =>
children: [
new TableCell({
children: [new Paragraph(date.toString())],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
textDirection: TextDirection.LEFT_TO_RIGHT_TOP_TO_BOTTOM,
}),
new TableCell({
children: [new Paragraph(ticker)],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
textDirection: TextDirection.LEFT_TO_RIGHT_TOP_TO_BOTTOM,
}),
new TableCell({
children: [new Paragraph(price.toString())],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
}),
],
@ -143,7 +143,7 @@ const doc = new Document({
],
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
textDirection: TextDirection.LEFT_TO_RIGHT_TOP_TO_BOTTOM,
}),
new TableCell({
@ -159,7 +159,7 @@ const doc = new Document({
],
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
textDirection: TextDirection.LEFT_TO_RIGHT_TOP_TO_BOTTOM,
}),
new TableCell({
@ -175,7 +175,7 @@ const doc = new Document({
],
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
}),
],

View File

@ -13,7 +13,7 @@ import {
TableRow,
TextDirection,
TextRun,
VerticalAlign,
VerticalAlignTable,
} from "docx";
patchDocument({
@ -105,11 +105,11 @@ patchDocument({
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
@ -137,7 +137,7 @@ patchDocument({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -145,7 +145,7 @@ patchDocument({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -153,7 +153,7 @@ patchDocument({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
],
}),

View File

@ -13,7 +13,7 @@ import {
TableRow,
TextDirection,
TextRun,
VerticalAlign,
VerticalAlignTable,
} from "docx";
patchDocument({
@ -105,11 +105,11 @@ patchDocument({
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
@ -137,7 +137,7 @@ patchDocument({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -145,7 +145,7 @@ patchDocument({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
new TableCell({
children: [
@ -153,7 +153,7 @@ patchDocument({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
}),
],
}),

View File

@ -159,7 +159,7 @@ const tableRow = new TableRow({
| children | `Array<Paragraph or Table>` | Required. You can nest tables by adding a table into a cell |
| shading | `IShadingAttributesProperties` | Optional |
| margins | `ITableCellMarginOptions` | Optional |
| verticalAlign | `VerticalAlign` | Optional |
| verticalAlign | `VerticalAlignTable` | Optional |
| columnSpan | `number` | Optional |
| rowSpan | `number` | Optional |
| borders | `BorderOptions` | Optional |
@ -266,7 +266,7 @@ Sets the vertical alignment of the contents of the cell
```ts
const cell = new TableCell({
...,
verticalAlign: VerticalAlign,
verticalAlign: VerticalAlignTable,
});
```
@ -282,7 +282,7 @@ For example, to center align a cell:
```ts
const cell = new TableCell({
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
});
```

3906
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "docx",
"version": "9.4.1",
"version": "9.5.0",
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
"type": "module",
"main": "dist/index.umd.cjs",
@ -81,7 +81,7 @@
"@typescript-eslint/parser": "^8.8.1",
"@vitest/coverage-v8": "^3.0.8",
"@vitest/ui": "^3.0.8",
"cspell": "^8.2.3",
"cspell": "^9.0.0",
"docsify-cli": "^4.3.0",
"eslint": "^9.13.0",
"eslint-import-resolver-typescript": "^4.3.2",
@ -90,7 +90,7 @@
"eslint-plugin-jsdoc": "^50.3.1",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-unicorn": "^58.0.0",
"eslint-plugin-unicorn": "^59.0.0",
"execa": "^9.4.0",
"glob": "^11.0.0",
"inquirer": "^12.0.0",

View File

@ -6,7 +6,7 @@ import { FooterWrapper } from "@file/footer-wrapper";
import { HeaderWrapper } from "@file/header-wrapper";
import { Media } from "@file/media";
import { NumberFormat } from "@file/shared/number-format";
import { VerticalAlign } from "@file/vertical-align";
import { VerticalAlignSection } from "@file/vertical-align";
import { convertInchesToTwip } from "@util/convenience-functions";
import { PageOrientation } from "./properties";
@ -75,7 +75,7 @@ describe("SectionProperties", () => {
even: new FooterWrapper(media, 200),
},
titlePage: true,
verticalAlign: VerticalAlign.TOP,
verticalAlign: VerticalAlignSection.TOP,
});
const tree = new Formatter().format(properties);

View File

@ -2,7 +2,7 @@
import { FooterWrapper } from "@file/footer-wrapper";
import { HeaderWrapper } from "@file/header-wrapper";
import { VerticalAlign, VerticalAlignElement } from "@file/vertical-align";
import { SectionVerticalAlign, VerticalAlignElement } from "@file/vertical-align";
import { OnOffElement, XmlComponent } from "@file/xml-components";
import { Columns, IColumnsAttributes } from "./properties/columns";
@ -35,7 +35,7 @@ export type ISectionPropertiesOptions = {
readonly footerWrapperGroup?: IHeaderFooterGroup<FooterWrapper>;
readonly lineNumbers?: ILineNumberAttributes;
readonly titlePage?: boolean;
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
readonly verticalAlign?: SectionVerticalAlign;
readonly column?: IColumnsAttributes;
readonly type?: (typeof SectionType)[keyof typeof SectionType];
};

View File

@ -19,8 +19,8 @@ import { createHyperlinkClick } from "./doc-properties-children";
export type DocPropertiesOptions = {
readonly name: string;
readonly description: string;
readonly title: string;
readonly description?: string;
readonly title?: string;
};
export class DocProperties extends XmlComponent {
@ -29,26 +29,32 @@ export class DocProperties extends XmlComponent {
public constructor({ name, description, title }: DocPropertiesOptions = { name: "", description: "", title: "" }) {
super("wp:docPr");
this.root.push(
new NextAttributeComponent({
id: {
key: "id",
value: this.docPropertiesUniqueNumericId(),
},
name: {
key: "name",
value: name,
},
description: {
key: "descr",
value: description,
},
title: {
key: "title",
value: title,
},
}),
);
const attributes: Record<string, { readonly key: string; readonly value: string | number }> = {
id: {
key: "id",
value: this.docPropertiesUniqueNumericId(),
},
name: {
key: "name",
value: name,
},
};
if (description !== null && description !== undefined) {
attributes.description = {
key: "descr",
value: description,
};
}
if (title !== null && title !== undefined) {
attributes.title = {
key: "title",
value: title,
};
}
this.root.push(new NextAttributeComponent(attributes));
}
public prepForXml(context: IContext): IXmlableObject | undefined {
@ -59,7 +65,6 @@ export class DocProperties extends XmlComponent {
}
this.root.push(createHyperlinkClick(element.linkId, true));
break;
}

View File

@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter";
import { BorderStyle } from "@file/border";
import { VerticalAlign } from "@file/vertical-align";
import { VerticalAlignTable } from "@file/vertical-align";
import { WidthType } from "../table-width";
import { VerticalMergeType } from "./table-cell-components";
@ -32,7 +32,7 @@ describe("TableCellProperties", () => {
});
it("sets vertical align", () => {
const properties = new TableCellProperties({ verticalAlign: VerticalAlign.BOTTOM });
const properties = new TableCellProperties({ verticalAlign: VerticalAlignTable.BOTTOM });
const tree = new Formatter().format(properties);
expect(tree).to.deep.equal({ "w:tcPr": [{ "w:vAlign": { _attr: { "w:val": "bottom" } } }] });
});

View File

@ -1,4 +1,4 @@
import { VerticalAlign, VerticalAlignElement } from "@file/vertical-align";
import { TableVerticalAlign, VerticalAlignElement } from "@file/vertical-align";
import { IgnoreIfEmptyXmlComponent } from "@file/xml-components";
import { IShadingAttributesProperties, Shading } from "../../shading";
@ -17,7 +17,7 @@ import {
export type ITableCellPropertiesOptions = {
readonly shading?: IShadingAttributesProperties;
readonly margins?: ITableCellMarginOptions;
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
readonly verticalAlign?: TableVerticalAlign;
readonly textDirection?: (typeof TextDirection)[keyof typeof TextDirection];
readonly verticalMerge?: (typeof VerticalMergeType)[keyof typeof VerticalMergeType];
readonly width?: ITableWidthProperties;

View File

@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter";
import { BorderStyle } from "@file/border";
import { ShadingType } from "@file/shading";
import { VerticalAlign } from "@file/vertical-align";
import { VerticalAlignTable } from "@file/vertical-align";
import { WidthType } from "../table-width";
import { TableCell } from "./table-cell";
@ -286,7 +286,7 @@ describe("TableCell", () => {
it("should create with vertical align", () => {
const cell = new TableCell({
children: [],
verticalAlign: VerticalAlign.CENTER,
verticalAlign: VerticalAlignTable.CENTER,
});
const tree = new Formatter().format(cell);

View File

@ -6,17 +6,43 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
// <xsd:simpleType name="ST_VerticalJc">
// <xsd:restriction base="xsd:string">
// <xsd:enumeration value="both"/>
// <xsd:enumeration value="top"/>
// <xsd:enumeration value="center"/>
// <xsd:enumeration value="bottom"/>
// </xsd:restriction>
// </xsd:simpleType>
export const VerticalAlign = {
BOTTOM: "bottom",
CENTER: "center",
/**
* Enumeration for table-cell vertical alignment. Only `top`, `center`, `bottom`
* are valid according to ECMA-376 (§17.18.87 ST_VerticalJc within <w:tcPr>).
*/
export const VerticalAlignTable = {
TOP: "top",
CENTER: "center",
BOTTOM: "bottom",
} as const;
/**
* Enumeration for section (<w:sectPr>) vertical alignment. Adds `both` on top of
* the table-cell set (§17.18.87 ST_VerticalJc within <w:sectPr>).
*/
export const VerticalAlignSection = {
...VerticalAlignTable,
BOTH: "both",
} as const;
/**
* @deprecated Use {@link VerticalAlignTable} for table cells or
* {@link VerticalAlignSection} for section properties. This alias remains for
* backward-compatibility and will be removed in the next major release.
*/
export const VerticalAlign = VerticalAlignSection;
export type TableVerticalAlign = (typeof VerticalAlignTable)[keyof typeof VerticalAlignTable];
export type SectionVerticalAlign = (typeof VerticalAlignSection)[keyof typeof VerticalAlignSection];
export class VerticalAlignAttributes extends XmlAttributeComponent<{
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
}> {

View File

@ -19,8 +19,6 @@ export const findRunElementIndexWithToken = (paragraphElement: Element, token: s
}
}
}
throw new Error("Token not found");
};
export const splitRunElement = (runElement: Element, token: string): { readonly left: Element; readonly right: Element } => {