bun-docx 0.6.0 → 0.7.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 +27 -10
- package/dist/index.js +1419 -217
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ bunx bun-docx read doc.docx
|
|
|
31
31
|
|
|
32
32
|
```sh
|
|
33
33
|
docx create FILE [--title T] [--author A] [--text "..."]
|
|
34
|
-
docx read FILE [--markdown [--from pN] [--to pN] [--
|
|
34
|
+
docx read FILE [--markdown [--from pN] [--to pN] [--accepted | --baseline] [--comments]]
|
|
35
35
|
docx insert FILE --after p3 --text "..." [--style HeadingN] [--color HEX] [--bold] [--italic] [--url URL]
|
|
36
36
|
docx insert FILE --after p3 --runs '[{"type":"text","text":"X","bold":true}]'
|
|
37
37
|
docx edit FILE --at p3 --text "..." | --runs '[...]'
|
|
@@ -40,6 +40,9 @@ docx delete FILE --at p3
|
|
|
40
40
|
docx find FILE QUERY [--regex] [--ignore-case] [--all] [--nth N]
|
|
41
41
|
docx replace FILE PATTERN REPLACEMENT [--regex] [--ignore-case] [--all] [--limit N] [--dry-run]
|
|
42
42
|
|
|
43
|
+
docx wc FILE [LOCATOR] [--accepted | --baseline]
|
|
44
|
+
docx outline FILE
|
|
45
|
+
|
|
43
46
|
docx comments add FILE --range p3:5-20 --text "..." [--author NAME]
|
|
44
47
|
docx comments reply FILE --to c0 --text "..."
|
|
45
48
|
docx comments resolve FILE --id c0 [--unset]
|
|
@@ -56,13 +59,18 @@ docx hyperlinks replace FILE --at linkN --with URL
|
|
|
56
59
|
docx hyperlinks delete FILE --at linkN
|
|
57
60
|
|
|
58
61
|
docx track-changes FILE on|off
|
|
62
|
+
docx track-changes list FILE
|
|
63
|
+
docx track-changes accept FILE (--at tcN | --all)
|
|
64
|
+
docx track-changes reject FILE (--at tcN | --all)
|
|
59
65
|
docx info schema [--ts]
|
|
60
66
|
docx info locators [--json]
|
|
61
67
|
```
|
|
62
68
|
|
|
63
69
|
Every command has `--help`. Mutating commands accept `--dry-run` and `-o/--output PATH` (write to a parallel file instead of overwriting `FILE`). JSON output by default for `read` and `*.list`; structured `{ok, code, error, hint}` on failure.
|
|
64
70
|
|
|
65
|
-
When `<w:trackChanges/>` is set in the doc (toggle via `docx track-changes FILE on`), `insert`/`edit`/`delete`/`replace` automatically emit `<w:ins>`/`<w:del>` markers
|
|
71
|
+
When `<w:trackChanges/>` is set in the doc (toggle via `docx track-changes FILE on`), `insert`/`edit`/`delete`/`replace` automatically emit `<w:ins>`/`<w:del>` markers. Author resolution: per-call `--author NAME` overrides `$DOCX_AUTHOR`, which falls back to `docx-cli`. To make a one-off untracked edit, flip the flag off, edit, then flip it back on. `find` results inside tracked-change wrappers carry a `trackedChanges` array so agents can decide what to do with hits in pending insertions/deletions. `docx track-changes list FILE` returns a JSON inventory of every revision wrapper (`<w:ins>` / `<w:del>` / `<w:moveFrom>` / `<w:moveTo>`) with stable `tcN` ids, author, date, paragraph location, and the affected text. `docx track-changes accept FILE --at tcN | --all` incorporates changes — additive wrappers (`<w:ins>` / `<w:moveTo>`) get unwrapped, subtractive wrappers (`<w:del>` / `<w:moveFrom>`) get deleted; `reject` is the inverse (additive deleted, subtractive unwrapped after `<w:delText>` → `<w:t>`). moveFrom/moveTo halves are processed independently, so `--all` handles a complete move; targeting one half by `tcN` leaves the other in place. Accept/reject themselves bypass tracking — they're doc surgery, not edits.
|
|
72
|
+
|
|
73
|
+
OOXML has no native tracked-change form for hyperlink edits or image swaps, so when track-changes is on, `hyperlinks add/replace/delete` and `images replace` auto-emit a `[docx-cli] …` comment anchored to the affected span/run instead. The comment carries the same `--author` attribution as the other tracked operations. Word itself silently bypasses tracking for these — we trade silence for an explicit audit trail.
|
|
66
74
|
|
|
67
75
|
### Markdown rendering
|
|
68
76
|
|
|
@@ -80,9 +88,14 @@ When `<w:trackChanges/>` is set in the doc (toggle via `docx track-changes FILE
|
|
|
80
88
|
- Footnotes / endnotes → inline `[^fnN]` / `[^enN]` refs with GFM footnote definitions at end of output
|
|
81
89
|
- Charts / SmartArt / shapes / other non-picture drawings → `` `[chart]` `` / `` `[smartart]` `` / `` `[shape]` `` / `` `[drawing]` `` placeholders
|
|
82
90
|
|
|
83
|
-
`--from LOC` and `--to LOC` slice by top-level block (both inclusive). Accepts paragraph, table, cell, span, and range locators; cell/span/range collapse to their enclosing top-level block. Comment/image/hyperlink locators are rejected.
|
|
91
|
+
`--from LOC` and `--to LOC` slice by top-level block (both inclusive). Accepts paragraph, table, cell, span, and range locators; cell/span/range collapse to their enclosing top-level block. Comment/image/hyperlink/tracked-change locators are rejected.
|
|
92
|
+
|
|
93
|
+
**Tracked changes — three views.** By default, additive wrappers (`<w:ins>`, `<w:moveTo>`) render as CriticMarkup `{++text++}[^tcN]` and subtractive wrappers (`<w:del>`, `<w:moveFrom>`) as `{--text--}[^tcN]`, with `[^tcN]: insertion|deletion|moveTo|moveFrom by author (date)` definitions appended after any comment/footnote/endnote definitions. The `[^tcN]` reference is a stable positional id (`tc0`, `tc1`, …) that's also addressable as a locator and reported by `docx track-changes list`. Two flags switch view; they're mutually exclusive:
|
|
94
|
+
|
|
95
|
+
- `--accepted` — post-accept view: `<w:del>` and `<w:moveFrom>` runs are dropped, `<w:ins>` and `<w:moveTo>` runs render as plain text. No CriticMarkup, no `[^tcN]` refs, no appendix.
|
|
96
|
+
- `--baseline` — pre-change view: `<w:ins>` and `<w:moveTo>` runs are dropped, `<w:del>` and `<w:moveFrom>` runs render as plain text. No CriticMarkup, no `[^tcN]` refs, no appendix.
|
|
84
97
|
|
|
85
|
-
`--
|
|
98
|
+
`docx wc` accepts the same `--accepted` / `--baseline` flags with parallel semantics: default counts everything currently on disk (plain + ins + del), `--accepted` skips deletions, `--baseline` skips insertions. The response includes a `view` field so agents know which mode the count was taken from.
|
|
86
99
|
|
|
87
100
|
`--comments` appends a GFM footnote reference (`[^cN]`) at the end of each commented span and emits one footnote definition per comment at the end of the output:
|
|
88
101
|
|
|
@@ -98,11 +111,11 @@ Footnotes/endnotes (the document's own `<w:footnoteReference>` / `<w:endnoteRefe
|
|
|
98
111
|
### Locators
|
|
99
112
|
|
|
100
113
|
```
|
|
101
|
-
pN
|
|
102
|
-
pN:S-E
|
|
103
|
-
pN:S-pM:E
|
|
104
|
-
tN
|
|
105
|
-
cN, imgN, linkN comment / image / hyperlink ids
|
|
114
|
+
pN paragraph N (e.g., p3)
|
|
115
|
+
pN:S-E characters S..E within paragraph N
|
|
116
|
+
pN:S-pM:E cross-paragraph range
|
|
117
|
+
tN table N; tN:rRcC for cell at row R, col C
|
|
118
|
+
cN, imgN, linkN, tcN comment / image / hyperlink / tracked-change ids
|
|
106
119
|
```
|
|
107
120
|
|
|
108
121
|
Run `docx info locators` for the full reference.
|
|
@@ -139,10 +152,14 @@ src/
|
|
|
139
152
|
insert/ # insert FILE (uses ./emit Paragraph component)
|
|
140
153
|
edit/ # edit FILE
|
|
141
154
|
delete/ # delete FILE
|
|
155
|
+
find/ # find FILE QUERY
|
|
156
|
+
replace/ # replace FILE PATTERN REPLACEMENT
|
|
157
|
+
wc/ # wc FILE [LOCATOR]
|
|
158
|
+
outline/ # outline FILE
|
|
142
159
|
comments/ # add | reply | resolve | delete | list
|
|
143
160
|
images/ # list | extract | replace
|
|
144
161
|
hyperlinks/ # add | list | replace | delete
|
|
145
|
-
track-changes/ #
|
|
162
|
+
track-changes/ # on|off | list | accept | reject (apply.ts holds the unwrap/delete logic)
|
|
146
163
|
info/ # schema | locators (reference output)
|
|
147
164
|
core/
|
|
148
165
|
package/ # JSZip open/close, named-part read/write
|