odf-kit 0.10.0 → 0.10.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +49 -3
  3. package/package.json +32 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to odf-kit will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.10.0] - 2026-04-12
9
+
10
+ ### Added
11
+
12
+ - **`docxToOdt()`** — Convert `.docx` files directly to `.odt`. Pure ESM, zero new dependencies, runs in Node.js 22+ and browsers. No CommonJS, no LibreOffice, no intermediate HTML step. Available via `odf-kit/docx`.
13
+ - **Native DOCX parser** — Reads the full DOCX ZIP structure: `word/document.xml`, `word/styles.xml`, `word/numbering.xml`, `word/_rels/document.xml.rels`, `word/footnotes.xml`, `word/endnotes.xml`, `word/header*.xml`, `word/footer*.xml`, `word/settings.xml`, `word/media/*`, `docProps/core.xml`.
14
+ - **Content preserved:** paragraphs, headings (style-name and outlineLvl detection), bold, italic, underline, strikethrough, superscript/subscript, small caps, all caps, font size, font family, text color, highlight color, text alignment, paragraph spacing (before/after), line height, indentation (left, right, first-line/hanging), bullet lists, numbered lists (decimal, roman, alpha), nested lists, tables (column widths, merged cells — colSpan and rowSpan, cell background color, vertical alignment), hyperlinks (external and internal anchor), bookmarks (two-pass cross-paragraph resolution), images (actual EMU dimensions, not defaulted to 10cm), page layout (size, margins, orientation from `w:sectPr`), headers and footers, footnotes and endnotes, page breaks, tabs, line breaks, tracked changes (final-text mode — insertions included, deletions skipped).
15
+ - **Metadata** — title, creator, description read from `docProps/core.xml` (Dublin Core / OCP core properties).
16
+ - **Style inheritance** — `w:basedOn` chain walked at conversion time; each style layer correctly overrides its parent.
17
+ - **Complex fields** — `w:fldChar`/`w:instrText` HYPERLINK fields handled via state machine in addition to `w:hyperlink` elements. `w:fldSimple` fields (including in headers/footers) also handled.
18
+ - **`w:pict` legacy VML images** — Dimensions parsed from `v:shape style` attribute; image bytes loaded via `v:imagedata r:id`.
19
+ - **`w:sdt` structured document tags** — Always unwrapped and processed; checkboxes rendered as ☐/☑.
20
+ - **`pageBreakBefore`** paragraph property respected — emits a page break before the affected paragraph.
21
+ - **`DocxToOdtOptions`** — `pageFormat`, `orientation`, `preservePageLayout` (default: true), `styleMap` (custom style name → heading level), `metadata` override.
22
+ - **`DocxToOdtResult`** — `{ bytes: Uint8Array, warnings: string[] }`. Warnings report content that could not be fully converted (unrecognised fields, missing images, mid-document section breaks, etc.).
23
+ - **`odf-kit/docx`** sub-export added.
24
+ - **Deprecates** `@odf-kit/docx-to-odt` (CommonJS, browser-incompatible) — use `odf-kit/docx` instead.
25
+ - Spec-validated against ECMA-376 5th edition Part 1 (WordprocessingML). Every XSD schema element verified against the authoritative spec PDF.
26
+ - 117 new tests (1053 total, 23 test suites).
27
+ - Landing page updated: eleven modes, all 11 code examples, updated stats.
28
+ - New guide: [Convert DOCX to ODT in JavaScript](https://githubnewbie0.github.io/odf-kit/guides/docx-to-odt.html).
29
+ - All 7 tool pages now linked from README and landing page footer.
30
+
8
31
  ## [0.9.9] - 2026-04-11
9
32
 
10
33
  ### Added
@@ -202,6 +225,7 @@ Initial release. Complete ODT generation support.
202
225
  - Tables, page layout, headers/footers, page breaks, lists, tab stops.
203
226
  - Method chaining. Full TypeScript types. ESM-only, Node.js 22+. 102 tests.
204
227
 
228
+ [0.10.0]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.10.0
205
229
  [0.9.9]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.9.9
206
230
  [0.9.8]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.9.8
207
231
  [0.9.7]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.9.7
@@ -221,3 +245,4 @@ Initial release. Complete ODT generation support.
221
245
  [0.3.0]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.3.0
222
246
  [0.2.0]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.2.0
223
247
  [0.1.0]: https://github.com/GitHubNewbie0/odf-kit/releases/tag/v0.1.0
248
+
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # odf-kit
2
2
 
3
- Generate, fill, read, and convert OpenDocument Format files (.odt, .ods) in TypeScript and JavaScript. Convert HTML, Markdown, and TipTap JSON to ODT. Works in Node.js and browsers. No LibreOffice dependency — pure spec-compliant ODF.
3
+ Generate, fill, read, and convert OpenDocument Format files (.odt, .ods) in TypeScript and JavaScript. Convert HTML, Markdown, TipTap JSON, and DOCX to ODT. Works in Node.js and browsers. No LibreOffice dependency — pure spec-compliant ODF.
4
4
 
5
5
  **[Documentation & examples →](https://githubnewbie0.github.io/odf-kit/)**
6
6
 
@@ -8,7 +8,7 @@ Generate, fill, read, and convert OpenDocument Format files (.odt, .ods) in Type
8
8
  npm install odf-kit
9
9
  ```
10
10
 
11
- ## Ten ways to work with ODF files
11
+ ## Eleven ways to work with ODF files
12
12
 
13
13
  ```typescript
14
14
  // 1. Build an ODT document from scratch
@@ -145,6 +145,21 @@ writeFileSync("letter.typ", typst);
145
145
  execSync("typst compile letter.typ letter.pdf");
146
146
  ```
147
147
 
148
+ ```typescript
149
+ // 11. Convert .docx to .odt — pure ESM, zero new dependencies, browser-safe
150
+ import { docxToOdt } from "odf-kit/docx";
151
+
152
+ const { bytes, warnings } = await docxToOdt(readFileSync("report.docx"));
153
+ writeFileSync("report.odt", bytes);
154
+ if (warnings.length > 0) console.warn(warnings);
155
+
156
+ // With options
157
+ const { bytes: bytes2 } = await docxToOdt(readFileSync("report.docx"), {
158
+ pageFormat: "letter",
159
+ styleMap: { "Section Title": 1 }, // map custom Word style → heading level
160
+ });
161
+ ```
162
+
148
163
  ---
149
164
 
150
165
  ## Installation
@@ -160,6 +175,7 @@ import { OdtDocument, OdsDocument, htmlToOdt, markdownToOdt, tiptapToOdt, fillTe
160
175
  import { readOdt, odtToHtml } from "odf-kit/odt-reader";
161
176
  import { readOds, odsToHtml } from "odf-kit/ods-reader";
162
177
  import { odtToTypst, modelToTypst } from "odf-kit/typst";
178
+ import { docxToOdt } from "odf-kit/docx";
163
179
  ```
164
180
 
165
181
  Works in Node.js, browsers, Deno, Bun, and Cloudflare Workers. Runtime dependencies: [fflate](https://github.com/101arrowz/fflate) for ZIP, [marked](https://marked.js.org/) for Markdown parsing.
@@ -739,6 +755,27 @@ execSync("typst compile letter.typ letter.pdf");
739
755
 
740
756
  ## API Reference
741
757
 
758
+ ### docxToOdt
759
+
760
+ ```typescript
761
+ import { docxToOdt } from "odf-kit/docx"
762
+
763
+ const { bytes, warnings } = await docxToOdt(input, options?)
764
+
765
+ interface DocxToOdtOptions {
766
+ pageFormat?: "A4" | "letter" | "legal" | "A3" | "A5";
767
+ orientation?: "portrait" | "landscape";
768
+ preservePageLayout?: boolean; // default: true — read layout from DOCX
769
+ styleMap?: Record<string, number>; // custom style name → heading level
770
+ metadata?: { title?: string; creator?: string; description?: string };
771
+ }
772
+
773
+ interface DocxToOdtResult {
774
+ bytes: Uint8Array; // the .odt file
775
+ warnings: string[]; // content that could not be fully converted
776
+ }
777
+ ```
778
+
742
779
  ### htmlToOdt / markdownToOdt
743
780
 
744
781
  ```typescript
@@ -862,7 +899,7 @@ ESM only. Zero Node-specific APIs in the library source — enforced at the Type
862
899
  - **Two runtime dependencies** — fflate (ZIP) and marked (Markdown parsing). No transitive dependencies.
863
900
  - **Spec-compliant output** — every generated file passes the OASIS ODF validator. Enforced on every commit by CI.
864
901
  - **Multiple ODF formats** — ODT documents and ODS spreadsheets from the same library.
865
- - **Eight complete capability modes** — build ODT, build ODS, convert HTML→ODT, convert Markdown→ODT, convert TipTap JSON→ODT, fill templates, read, convert to Typst/PDF.
902
+ - **Nine complete capability modes** — build ODT, build ODS, convert HTML→ODT, convert Markdown→ODT, convert TipTap JSON→ODT, convert DOCX→ODT, fill templates, read, convert to Typst/PDF.
866
903
  - **TipTap/ProseMirror integration** — direct JSON→ODT conversion for any TipTap-based editor, no intermediate HTML step.
867
904
  - **Zero-dependency Typst emitter** — the only JavaScript library with built-in ODT→Typst conversion for PDF generation.
868
905
  - **TypeScript-first** — full types across all sub-exports.
@@ -879,6 +916,7 @@ ESM only. Zero Node-specific APIs in the library source — enforced at the Type
879
916
  | Convert HTML → ODT | ✅ | ❌ | ❌ |
880
917
  | Convert Markdown → ODT | ✅ | ❌ | ❌ |
881
918
  | Convert TipTap JSON → ODT | ✅ | ❌ | ❌ |
919
+ | Convert DOCX → ODT | ✅ native, browser-safe | ❌ | ❌ |
882
920
  | Fill .odt templates | ✅ | ❌ | ✅ .docx only |
883
921
  | Read .odt files | ✅ | ❌ | ❌ |
884
922
  | Convert to HTML | ✅ | ❌ | ❌ |
@@ -897,6 +935,8 @@ odf-kit targets ODF 1.2 (ISO/IEC 26300). Generated files include proper ZIP pack
897
935
 
898
936
  ## Version history
899
937
 
938
+ **v0.10.0** — `docxToOdt()` via `odf-kit/docx`. Native DOCX→ODT converter — pure ESM, zero new dependencies, browser-safe. Preserves text, headings, formatting, tables, lists, images (actual dimensions), hyperlinks, bookmarks, footnotes, page layout, headers/footers, and tracked changes. Spec-validated against ECMA-376 5th edition. 1053 tests passing.
939
+
900
940
  **v0.9.9** — `xlsxToOds()` via `odf-kit/xlsx`. XLSX→ODS conversion with zero new dependencies. 936 tests passing.
901
941
 
902
942
  **v0.9.8** — ODS reader: `readOds()` and `odsToHtml()` via `odf-kit/ods-reader`. Typed values, formula strings, merged cell handling, formatting, metadata. `odf-kit/odt-reader` alias added. 889 tests passing.
@@ -933,14 +973,20 @@ odf-kit targets ODF 1.2 (ISO/IEC 26300). Generated files include proper ZIP pack
933
973
  - [Generate ODT files in the browser](https://githubnewbie0.github.io/odf-kit/guides/generate-odt-browser.html)
934
974
  - [Fill ODT templates in JavaScript](https://githubnewbie0.github.io/odf-kit/guides/fill-odt-template-javascript.html)
935
975
  - [Convert ODT to HTML in JavaScript](https://githubnewbie0.github.io/odf-kit/guides/odt-to-html-javascript.html)
976
+ - [Convert DOCX to ODT in JavaScript](https://githubnewbie0.github.io/odf-kit/guides/docx-to-odt.html)
936
977
  - [ODT to PDF via Typst](https://githubnewbie0.github.io/odf-kit/guides/odt-to-typst-pdf.html)
937
978
  - [Generate ODT without LibreOffice](https://githubnewbie0.github.io/odf-kit/guides/generate-odt-without-libreoffice.html)
938
979
  - [ODF government compliance](https://githubnewbie0.github.io/odf-kit/guides/odf-government-compliance.html)
939
980
  - [simple-odf alternative](https://githubnewbie0.github.io/odf-kit/guides/simple-odf-alternative.html)
940
981
  - [docxtemplater alternative for ODF](https://githubnewbie0.github.io/odf-kit/guides/docxtemplater-odf-alternative.html)
941
982
  - [ODT JavaScript ecosystem](https://githubnewbie0.github.io/odf-kit/guides/odt-javascript-ecosystem.html)
983
+ - [Free DOCX to ODT converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/docx-to-odt.html)
942
984
  - [Free ODT to HTML converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/odt-to-html.html)
943
985
  - [Free ODT to PDF converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/odt-to-pdf.html)
986
+ - [Free XLSX to ODS converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/xlsx-to-ods.html)
987
+ - [Free Markdown to ODT converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/markdown-to-odt.html)
988
+ - [Free HTML to ODT converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/html-to-odt.html)
989
+ - [Free ODS to HTML converter (online tool)](https://githubnewbie0.github.io/odf-kit/tools/ods-to-html.html)
944
990
 
945
991
  ---
946
992
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odf-kit",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Generate, fill, read, and convert OpenDocument Format (.odt) files in JavaScript and TypeScript. Works in Node.js and browsers.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -47,6 +47,37 @@
47
47
  "import": "./dist/docx/index.js"
48
48
  }
49
49
  },
50
+ "typesVersions": {
51
+ "*": {
52
+ "odt": [
53
+ "./dist/odt/index.d.ts"
54
+ ],
55
+ "odt-reader": [
56
+ "./dist/reader/index.d.ts"
57
+ ],
58
+ "ods": [
59
+ "./dist/ods/index.d.ts"
60
+ ],
61
+ "ods-reader": [
62
+ "./dist/ods-reader/index.d.ts"
63
+ ],
64
+ "xlsx": [
65
+ "./dist/xlsx/index.d.ts"
66
+ ],
67
+ "template": [
68
+ "./dist/template/index.d.ts"
69
+ ],
70
+ "reader": [
71
+ "./dist/reader/index.d.ts"
72
+ ],
73
+ "typst": [
74
+ "./dist/typst/index.d.ts"
75
+ ],
76
+ "docx": [
77
+ "./dist/docx/index.d.ts"
78
+ ]
79
+ }
80
+ },
50
81
  "files": [
51
82
  "dist",
52
83
  "LICENSE",