@turbodocx/html-to-docx 1.20.1 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
[](https://typescript.org)
|
|
9
9
|
[](https://discord.gg/NYKwz4BcpX)
|
|
10
10
|
[](https://www.npmjs.com/package/@turbodocx/html-to-docx)
|
|
11
|
+
[](https://agentskills.io)
|
|
12
|
+
[](https://github.com/TurboDocx/quickstart)
|
|
11
13
|
[](https://twitter.com/TurboDocx)
|
|
12
14
|
[](https://www.turbodocx.com/use-cases/embedded-api?utm_source=github&utm_medium=repo&utm_campaign=open_source)
|
|
13
15
|
|
|
@@ -42,6 +44,23 @@ Based on the original work and assisted by the original contributors of [private
|
|
|
42
44
|
|
|
43
45
|
🛠️ **Developer Experience** - Full TypeScript support, comprehensive documentation, and extensive examples to get you up and running in minutes.
|
|
44
46
|
|
|
47
|
+
## ⚡ Skip the boilerplate — let an agent scaffold it for you
|
|
48
|
+
|
|
49
|
+
Have an AI coding agent (Claude Code, Cursor, Copilot, Codex, Gemini CLI, OpenCode) install `@turbodocx/html-to-docx`, generate a helper module, and write a working framework-appropriate route handler in one step:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx skills add TurboDocx/quickstart
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then run `/turbodocx-html-to-docx` inside your agent. The skill will:
|
|
56
|
+
|
|
57
|
+
1. Install `@turbodocx/html-to-docx` and any required peer dependencies
|
|
58
|
+
2. Detect your project structure (Express, Next.js, Fastify, NestJS, plain Node.js, etc.)
|
|
59
|
+
3. Generate a helper module and a framework-appropriate route/handler that returns a `.docx` response
|
|
60
|
+
4. Add example usage matching your existing code patterns
|
|
61
|
+
|
|
62
|
+
Source: [github.com/TurboDocx/quickstart](https://github.com/TurboDocx/quickstart).
|
|
63
|
+
|
|
45
64
|
## Installation
|
|
46
65
|
|
|
47
66
|
Use the npm to install the project.
|
|
@@ -181,13 +200,25 @@ The library provides a standalone browser build that bundles all dependencies in
|
|
|
181
200
|
|
|
182
201
|
### Build Outputs
|
|
183
202
|
|
|
184
|
-
When you run `npm run build`,
|
|
203
|
+
When you run `npm run build`, four distribution files are generated:
|
|
185
204
|
|
|
186
205
|
| File | Format | Size | Dependencies | Use Case |
|
|
187
206
|
|------|--------|------|--------------|----------|
|
|
188
|
-
| `dist/html-to-docx.esm.js` | ES Module | ~1.6 MB | External |
|
|
189
|
-
| `dist/html-to-docx.umd.js` | UMD | ~1.6 MB | External | Node.js
|
|
190
|
-
| `dist/html-to-docx.browser.js` |
|
|
207
|
+
| `dist/html-to-docx.esm.js` | ES Module | ~1.6 MB | External | Node.js ESM, server-side bundling |
|
|
208
|
+
| `dist/html-to-docx.umd.js` | UMD | ~1.6 MB | External | Node.js `require`, AMD |
|
|
209
|
+
| `dist/html-to-docx.browser.esm.js` | ES Module | ~1.6 MB | **All bundled** | Browser bundlers (Next.js, Vite, webpack) |
|
|
210
|
+
| `dist/html-to-docx.browser.js` | IIFE | ~1.6 MB | **All bundled** | Direct browser usage via `<script>`, CDN |
|
|
211
|
+
|
|
212
|
+
The package `exports` map points each environment at the right file
|
|
213
|
+
automatically, so consumers don't choose manually:
|
|
214
|
+
|
|
215
|
+
- **Browser bundlers** (Next.js/Turbopack, Vite, webpack) resolve the `browser`
|
|
216
|
+
condition to `html-to-docx.browser.esm.js` — a self-contained ESM build with
|
|
217
|
+
Node polyfills bundled in. `import HTMLtoDOCX from "@turbodocx/html-to-docx"`
|
|
218
|
+
works with **no extra configuration**. See
|
|
219
|
+
[`example/nextjs-example`](example/nextjs-example) for a complete app.
|
|
220
|
+
- **Node.js** resolves `import` → `esm.js` and `require` → `umd.js`.
|
|
221
|
+
- **`<script>` tags / CDNs** use `html-to-docx.browser.js` (IIFE) directly by URL.
|
|
191
222
|
|
|
192
223
|
### Build Commands
|
|
193
224
|
|
|
@@ -323,7 +354,8 @@ You can also host the browser build on a CDN for easy inclusion:
|
|
|
323
354
|
await HTMLtoDOCX(htmlString, headerHTMLString, documentOptions, footerHTMLString)
|
|
324
355
|
```
|
|
325
356
|
|
|
326
|
-
|
|
357
|
+
Full examples can be found under `example/`, including a complete
|
|
358
|
+
[Next.js app](example/nextjs-example) that generates a `.docx` in the browser.
|
|
327
359
|
|
|
328
360
|
### Parameters
|
|
329
361
|
|
|
@@ -413,7 +445,14 @@ full fledged examples can be found under `example/`
|
|
|
413
445
|
|
|
414
446
|
## Notes
|
|
415
447
|
|
|
416
|
-
|
|
448
|
+
Page breaks can be added using CSS `page-break-before: always` or `page-break-after` on any block element (`<p>`, `<h1>`–`<h6>`, `<div>`, etc.):
|
|
449
|
+
```html
|
|
450
|
+
<p style="page-break-before: always;">This paragraph starts on a new page</p>
|
|
451
|
+
<p style="page-break-after: always;">A page break follows this paragraph</p>
|
|
452
|
+
<div style="page-break-before: always;"><p>Content on new page</p></div>
|
|
453
|
+
```
|
|
454
|
+
`page-break-before` only triggers on the value `always`. `page-break-after` triggers on any value for backward compatibility.
|
|
455
|
+
The legacy `<div class="page-break"></div>` pattern is still supported for backward compatibility (contents inside are ignored).
|
|
417
456
|
|
|
418
457
|
|
|
419
458
|
CSS list-style-type for `<ol>` element are now supported. Just do something like this in the HTML:
|