document-cli 5.3.0 → 5.3.2
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/ExaDev/documents.js/tree/main/packages/document-cli) [](https://www.npmjs.com/package/document-cli) [](https://www.npmjs.com/package/document-cli) [](https://github.com/ExaDev/documents.js/actions)
|
|
4
4
|
|
|
5
|
-
> A command-line interface and an interactive terminal (Ink) app for [`documents.js`](https://github.com/ExaDev/documents.js): every docx/pptx/odt/odp/ods/odg/odf/pdf/odm/odb/xlsx/csv/svg/markdown/rtf/wpd conversion, bridge, and editor documents.js exposes, plus the outline projection [`document-outline.js`](../document-outline.js/README.md) builds over any readable document, wired up as a scriptable subcommand or a full-screen terminal editor. Installs as either `document-cli` or `doculi`.
|
|
5
|
+
> A command-line interface and an interactive terminal (Ink) app for [`documents.js`](https://github.com/ExaDev/documents.js): every docx/pptx/odt/odp/ods/odg/odf/pdf/odm/odb/xlsx/csv/svg/markdown/rtf/wpd/doc/xls/ppt conversion, bridge, and editor documents.js exposes, plus the outline projection [`document-outline.js`](../document-outline.js/README.md) builds over any readable document, wired up as a scriptable subcommand or a full-screen terminal editor. Installs as either `document-cli` or `doculi`.
|
|
6
6
|
|
|
7
7
|
`document-cli` adds no conversion or editing logic of its own — it is a dispatch layer over `documents.js`'s existing conversion functions, `DocumentConverter` port, live-view editors, and `.odb`/PDF readers. What it adds is two ways to drive them without writing TypeScript: a scriptable, Unix-shaped CLI (stdin/stdout, exit codes, `--json` diagnostics) for pipelines, and a full-screen Ink terminal app for browsing and editing a document interactively.
|
|
8
8
|
|
|
@@ -143,7 +143,7 @@ document-cli pdf-inspect report.pdf
|
|
|
143
143
|
document-cli pdf-inspect report.pdf --json
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
**`fonts <input>`** — lists every source-embedded font face a docx/pptx/odt/odp/ods/odg document carries (family, weight/style, byte length) — the same embedded faces every `<format>-to-pdf` conversion already extracts and renders through automatically (see [Real fonts](#real-fonts) below); this command just reports what's there without converting anything. Rejects a format with no source-embedded-font concept at all (xlsx, csv, svg, pdf, markdown, odf, rtf, wpd), naming it:
|
|
146
|
+
**`fonts <input>`** — lists every source-embedded font face a docx/pptx/odt/odp/ods/odg document carries (family, weight/style, byte length) — the same embedded faces every `<format>-to-pdf` conversion already extracts and renders through automatically (see [Real fonts](#real-fonts) below); this command just reports what's there without converting anything. Rejects a format with no source-embedded-font concept at all (xlsx, csv, svg, pdf, markdown, odf, rtf, wpd, doc, xls, ppt), naming it:
|
|
147
147
|
|
|
148
148
|
```sh
|
|
149
149
|
document-cli fonts report.docx
|
|
@@ -155,7 +155,7 @@ document-cli fonts report.docx
|
|
|
155
155
|
document-cli docx-extras report.docx
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
**`metadata <input>`** — prints a document's own title/author/subject/keywords/creator/producer/created/modified metadata, for any of the
|
|
158
|
+
**`metadata <input>`** — prints a document's own title/author/subject/keywords/creator/producer/created/modified metadata, for any of the seventeen supported formats (docx, pptx, xlsx, odt, odp, ods, odg, svg, odf, csv, markdown, rtf, wpd, doc, xls, ppt, pdf); csv, svg, doc, xls, and ppt carry no metadata container of their own (doc-codec/xls-codec/ppt-codec don't read one yet — see each package's own README), so they always report none. `--json` emits the raw metadata object:
|
|
159
159
|
|
|
160
160
|
```sh
|
|
161
161
|
document-cli metadata report.pdf
|
|
@@ -168,7 +168,7 @@ document-cli set-metadata report.docx report.docx --set-title "Q3 Report" --set-
|
|
|
168
168
|
document-cli set-metadata report.docx report.odt --set-keywords "draft,internal"
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
**`outline <input>`** — prints a document's outline: the table-of-contents projection over the tree-form `DocumentTree` read straight off the source document's own bytes — headings nested by heading level, list items nested under their heading or slide, one group per slide (labelled `Slide N`), sheet (labelled with the sheet's own name), or draw page (labelled `Page N`) — rendered as indented text, two spaces per nesting depth. Leaves render their own text (a paragraph's runs, a table's cell text, an image's alt text, a formula's LaTeX) or their kind in brackets when they carry none (`[page-break]`, `[vector]`, `[embeddedObject]`). Works on any of the
|
|
171
|
+
**`outline <input>`** — prints a document's outline: the table-of-contents projection over the tree-form `DocumentTree` read straight off the source document's own bytes — headings nested by heading level, list items nested under their heading or slide, one group per slide (labelled `Slide N`), sheet (labelled with the sheet's own name), or draw page (labelled `Page N`) — rendered as indented text, two spaces per nesting depth. Leaves render their own text (a paragraph's runs, a table's cell text, an image's alt text, a formula's LaTeX) or their kind in brackets when they carry none (`[page-break]`, `[vector]`, `[embeddedObject]`). Works on any of the seventeen readable formats: the command reads the source's own native tree directly (documents.js's `readNativeDocumentTree`) — no bridging conversion runs and no output bytes are discarded — and projects that tree through [`document-outline.js`](../document-outline.js/README.md)'s own `buildOutline`, this command being that package's first real consumer. `--json` emits the outline tree itself — groups as `{ text, level, children }`, leaves as the package leaves they are — rather than a CLI-private shape; a `pdf` source's own `readPdf` parse diagnostics still reach stderr exactly as they would on the matching `pdf-to-docx` command. `--from <format>` names the source format when the input path carries no recognised extension to infer it from — the only way to outline a document read from stdin (`-`), which otherwise has no extension to read at all. Heading nesting depends on the source document actually carrying a heading-level signal on disk (`w:outlineLvl` for docx, `text:outline-level` for odt) — present in anything authored by Word or LibreOffice, and always present for a markdown source, whose own reader parses `#`/`##` headings directly; a docx or odt this ecosystem's own writers produce does not currently stamp that signal even though the paragraph still carries its `Heading1`/`Heading2`-style reference, so outlining a docx/odt generated by this CLI's own conversions loses heading nesting specifically (list nesting and slide/sheet/page grouping are unaffected):
|
|
172
172
|
|
|
173
173
|
```sh
|
|
174
174
|
document-cli outline report.docx
|
|
@@ -231,7 +231,7 @@ It supports the same seven formats documents.js's live-view editors cover — do
|
|
|
231
231
|
|
|
232
232
|
Markdown (`.md`/`.markdown`) shares the same paragraph/run/table body-list screens docx and odt already use, through documents.js's own `MarkdownEditor` (`openMarkdown`/`createMarkdownEditor`) — a genuine live view over a mutable `ContentDocument`, the same live-view contract every other editor here follows, even though there is no `XmlElement` tree underneath it the way there is for docx/odt (`MarkdownEditor.toMarkdownText()` re-serialises the whole document fresh on every call, rather than exposing a `toBytes()`). Appending a paragraph, appending a run, and toggling bold/italic all go through the identical reducer actions docx/odt use; a markdown run has no underline, colour, font family, or font size at all (CommonMark/GFM has no construct for any of the four), so those keys — along with image insertion, which `MarkdownParagraph` has no counterpart for — are simply absent from a markdown paragraph's own key hints rather than opening a prompt that could only end in a warning. A markdown table can be created and its cells edited through the same 'T' wizard and table-view screens docx/odt use, but GFM tables have no cell-merge concept, so a merge requested alongside table creation still creates the table (unmerged) and reports why the merge itself didn't happen. `:view-source` (markdown documents only) shows the literal text the document was opened with side by side with what a save would write right now — these can genuinely differ even with no edits made this session, from a heading-style, bullet-marker, or line-ending choice the writer normalises. Every save re-serialises the whole document fresh through `buildMarkdownText`, a deliberate, permanent consequence of structured editing rather than something to work around. Diagnostics from the read side (a clamped heading level, a dropped front-matter key, a fenced code block's own info string with nowhere to go, …) now surface into the same diagnostics panel a PDF export's own substitutions already populate, the moment a `.md` file is opened, not only on export. documents.js's own `createMarkdownEditor()` exists now, but this TUI does not yet wire a "new markdown document" flow into `:new`/the new-document picker, so a markdown document can still only be opened from an existing file.
|
|
233
233
|
|
|
234
|
-
Three further kinds of format open read-only: a `.odb` browses its tables and rows with no write path at all (documents.js's own `.odb` support has no write direction to offer), a `.pdf` browses its pages and positioned items rather than being edited in place, and a `.xlsx`, `.csv`, `.svg`, `.rtf`, or `.
|
|
234
|
+
Three further kinds of format open read-only: a `.odb` browses its tables and rows with no write path at all (documents.js's own `.odb` support has no write direction to offer), a `.pdf` browses its pages and positioned items rather than being edited in place, and a `.xlsx`, `.csv`, `.svg`, `.rtf`, `.wpd`, `.doc`, `.xls`, or `.ppt` opens as a converted PDF preview — documents.js has no spreadsheet, svg, rtf, wpd, doc, xls, or ppt editor to hold a live view into (wpd-codec ships no writer at all, so a wpd document could never gain one; doc-codec/xls-codec/ppt-codec ship real writers now, but no live TUI editor targets them yet), so opening one runs `xlsxToPdf`, `csvToPdf`, `svgToPdf`, `rtfToPdf`, `convertDocument("wpd", "pdf", ...)`, `docToPdf`, `xlsToPdf`, or `pptToPdf` once at open time and browses the result through the identical page-list/page-items/item-detail screens a real `.pdf` uses, with the original bytes kept alongside so a later export re-runs the same conversion with the caller's own fonts and diagnostics rather than reusing the fixed preview conversion. A `.odb` additionally browses its _structure_ alongside its data: `f` from the table list opens the form browser and `r` the report browser, each listing what the database declares and opening one to show it in full — a form's own data source and field-bound controls (sub-forms nested under their parent), a report's data-source command, band and group structure, and every `rpt:` formula. Both are rendered through the same `src/odb-structure.ts` the `odb-forms`/`odb-reports` commands print, so the two views cannot drift apart, and search filters by line (`/SUM` narrows a long report to its aggregate expressions). `Enter` on a report's own detail screen renders it — its data-source command resolved, its `rpt:` formulas evaluated, its bands laid out — to a real `docx`/`odt`/`pdf` file, through the same two-field destination-path-then-font-list form the PDF-export screen below uses; the TUI counterpart to the `odb-render-report` command. A standalone `.odf` formula document has no TUI editor either — nothing to edit interactively, only a PDF conversion.
|
|
235
235
|
|
|
236
236
|
The export-to-PDF screen (`e` from any editor screen) is a two-field form: a destination path, then an optional comma-separated list of local `.ttf`/`.otf` paths, which are the same `--font-file` faces the CLI takes and are derived the same way — each font's family, weight, and slope come from the file itself. `Enter` on the path field moves to the fonts field and `Enter` there exports, so leaving fonts empty is still "type a path, press Enter twice". Comma-separated rather than space-separated because a font path routinely contains spaces and almost never a comma. A face falling back to a substitute is reported into the same diagnostics panel a character substitution already is, and a bad font path fails the export with the file named, before anything is written to the destination.
|
|
237
237
|
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as odbFormSummary, c as formatDocxExtrasLines, d as writeOutput, f as loadProvidedFonts, h as isDocumentFormat, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, r as formatOdbFormLines, s as presentMetadataEntries, t as describeOdbForm, u as resolveDefaultOutputPath } from "./odb-structure-
|
|
2
|
+
import { a as odbFormSummary, c as formatDocxExtrasLines, d as writeOutput, f as loadProvidedFonts, h as isDocumentFormat, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, r as formatOdbFormLines, s as presentMetadataEntries, t as describeOdbForm, u as resolveDefaultOutputPath } from "./odb-structure-DsWeqhGj.js";
|
|
3
3
|
import { Command, CommanderError, InvalidArgumentError } from "commander";
|
|
4
4
|
import { writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
@@ -1199,7 +1199,7 @@ function registerSetMetadataCommand(program) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
//#endregion
|
|
1201
1201
|
//#region package.json
|
|
1202
|
-
var version = "5.3.
|
|
1202
|
+
var version = "5.3.2";
|
|
1203
1203
|
//#endregion
|
|
1204
1204
|
//#region src/program.ts
|
|
1205
1205
|
function createProgram() {
|
|
@@ -1227,7 +1227,7 @@ function createProgram() {
|
|
|
1227
1227
|
//#region src/cli.ts
|
|
1228
1228
|
async function launchTui(startPath, signal) {
|
|
1229
1229
|
try {
|
|
1230
|
-
const { runTui } = await import("./tui-
|
|
1230
|
+
const { runTui } = await import("./tui-BYCDgi8p.js");
|
|
1231
1231
|
await runTui({
|
|
1232
1232
|
startPath,
|
|
1233
1233
|
signal
|
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,9 @@ const EXTENSION_TO_FORMAT = {
|
|
|
33
33
|
md: "markdown",
|
|
34
34
|
rtf: "rtf",
|
|
35
35
|
wpd: "wpd",
|
|
36
|
+
doc: "doc",
|
|
37
|
+
xls: "xls",
|
|
38
|
+
ppt: "ppt",
|
|
36
39
|
pdf: "pdf"
|
|
37
40
|
};
|
|
38
41
|
const FORMAT_TO_EXTENSION = {
|
|
@@ -49,6 +52,9 @@ const FORMAT_TO_EXTENSION = {
|
|
|
49
52
|
markdown: "md",
|
|
50
53
|
rtf: "rtf",
|
|
51
54
|
wpd: "wpd",
|
|
55
|
+
doc: "doc",
|
|
56
|
+
xls: "xls",
|
|
57
|
+
ppt: "ppt",
|
|
52
58
|
pdf: "pdf"
|
|
53
59
|
};
|
|
54
60
|
function isDocumentFormat(value) {
|
|
@@ -1541,7 +1547,7 @@ function registerSetMetadataCommand(program) {
|
|
|
1541
1547
|
}
|
|
1542
1548
|
//#endregion
|
|
1543
1549
|
//#region package.json
|
|
1544
|
-
var version = "5.3.
|
|
1550
|
+
var version = "5.3.2";
|
|
1545
1551
|
//#endregion
|
|
1546
1552
|
//#region src/program.ts
|
|
1547
1553
|
function createProgram() {
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,9 @@ const EXTENSION_TO_FORMAT = {
|
|
|
32
32
|
md: "markdown",
|
|
33
33
|
rtf: "rtf",
|
|
34
34
|
wpd: "wpd",
|
|
35
|
+
doc: "doc",
|
|
36
|
+
xls: "xls",
|
|
37
|
+
ppt: "ppt",
|
|
35
38
|
pdf: "pdf"
|
|
36
39
|
};
|
|
37
40
|
const FORMAT_TO_EXTENSION = {
|
|
@@ -48,6 +51,9 @@ const FORMAT_TO_EXTENSION = {
|
|
|
48
51
|
markdown: "md",
|
|
49
52
|
rtf: "rtf",
|
|
50
53
|
wpd: "wpd",
|
|
54
|
+
doc: "doc",
|
|
55
|
+
xls: "xls",
|
|
56
|
+
ppt: "ppt",
|
|
51
57
|
pdf: "pdf"
|
|
52
58
|
};
|
|
53
59
|
function isDocumentFormat(value) {
|
|
@@ -1540,7 +1546,7 @@ function registerSetMetadataCommand(program) {
|
|
|
1540
1546
|
}
|
|
1541
1547
|
//#endregion
|
|
1542
1548
|
//#region package.json
|
|
1543
|
-
var version = "5.3.
|
|
1549
|
+
var version = "5.3.2";
|
|
1544
1550
|
//#endregion
|
|
1545
1551
|
//#region src/program.ts
|
|
1546
1552
|
function createProgram() {
|
|
@@ -28,6 +28,9 @@ const EXTENSION_TO_FORMAT = {
|
|
|
28
28
|
md: "markdown",
|
|
29
29
|
rtf: "rtf",
|
|
30
30
|
wpd: "wpd",
|
|
31
|
+
doc: "doc",
|
|
32
|
+
xls: "xls",
|
|
33
|
+
ppt: "ppt",
|
|
31
34
|
pdf: "pdf"
|
|
32
35
|
};
|
|
33
36
|
const FORMAT_TO_EXTENSION = {
|
|
@@ -44,6 +47,9 @@ const FORMAT_TO_EXTENSION = {
|
|
|
44
47
|
markdown: "md",
|
|
45
48
|
rtf: "rtf",
|
|
46
49
|
wpd: "wpd",
|
|
50
|
+
doc: "doc",
|
|
51
|
+
xls: "xls",
|
|
52
|
+
ppt: "ppt",
|
|
47
53
|
pdf: "pdf"
|
|
48
54
|
};
|
|
49
55
|
function isDocumentFormat(value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as formatDocxExtrasLines, f as loadProvidedFonts, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, p as formatToExtension, r as formatOdbFormLines, t as describeOdbForm } from "./odb-structure-
|
|
1
|
+
import { c as formatDocxExtrasLines, f as loadProvidedFonts, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, p as formatToExtension, r as formatOdbFormLines, t as describeOdbForm } from "./odb-structure-DsWeqhGj.js";
|
|
2
2
|
import { readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import { basename, dirname, extname, join } from "node:path";
|
|
4
|
-
import { bytesToBase64, cellReference, columnIndexToLetters, convertDocument, createDocx, createOdg, createOdp, createOds, createOdt, createPdf, createPptx, csvToPdf, decodeMarkdownText, decodeOdbPackage, docxToPdf, encodeMarkdownText, hsqldbCellDisplayText, markdownToPdf, odbReportToDocx, odbReportToOdt, odbReportToPdf, odgToPdf, odpToPdf, odsToPdf, odtToPdf, openDocx, openMarkdown, openOdg, openOdp, openOds, openOdt, openPdf, openPptx, parseXml, pptxToPdf, readDocxContent, readDocxExtras, readMarkdownContent, readOdbForms, readOdbReportContent, readOdbReports, readOdbTables, readOdgContent, readOdpContent, readOdsContent, readOdtContent, readPdf, readPptxContent, rgbHexToColor, rtfToPdf, svgToPdf, xlsxToPdf } from "documents.js";
|
|
4
|
+
import { bytesToBase64, cellReference, columnIndexToLetters, convertDocument, createDocx, createOdg, createOdp, createOds, createOdt, createPdf, createPptx, csvToPdf, decodeMarkdownText, decodeOdbPackage, docToPdf, docxToPdf, encodeMarkdownText, hsqldbCellDisplayText, markdownToPdf, odbReportToDocx, odbReportToOdt, odbReportToPdf, odgToPdf, odpToPdf, odsToPdf, odtToPdf, openDocx, openMarkdown, openOdg, openOdp, openOds, openOdt, openPdf, openPptx, parseXml, pptToPdf, pptxToPdf, readDocxContent, readDocxExtras, readMarkdownContent, readOdbForms, readOdbReportContent, readOdbReports, readOdbTables, readOdgContent, readOdpContent, readOdsContent, readOdtContent, readPdf, readPptxContent, rgbHexToColor, rtfToPdf, svgToPdf, xlsToPdf, xlsxToPdf } from "documents.js";
|
|
5
5
|
import { readdirSync } from "node:fs";
|
|
6
6
|
import { Box, Text, render, useApp, useInput, useWindowSize } from "ink";
|
|
7
7
|
import { createContext, useContext, useEffect, useReducer, useState } from "react";
|
|
@@ -67,6 +67,21 @@ async function exportToPdf(openDocument, destinationPath, options) {
|
|
|
67
67
|
await writeFile(destinationPath, pdfBytes);
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
+
if (openDocument.format === "doc") {
|
|
71
|
+
const pdfBytes = docToPdf(openDocument.bytes, pdfOptions);
|
|
72
|
+
await writeFile(destinationPath, pdfBytes);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (openDocument.format === "xls") {
|
|
76
|
+
const pdfBytes = xlsToPdf(openDocument.bytes, pdfOptions);
|
|
77
|
+
await writeFile(destinationPath, pdfBytes);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (openDocument.format === "ppt") {
|
|
81
|
+
const pdfBytes = pptToPdf(openDocument.bytes, pdfOptions);
|
|
82
|
+
await writeFile(destinationPath, pdfBytes);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
70
85
|
const bytes = openDocument.editor.toBytes();
|
|
71
86
|
const pdfBytes = convert(openDocument.format, bytes, pdfOptions);
|
|
72
87
|
await writeFile(destinationPath, pdfBytes);
|
|
@@ -192,6 +207,24 @@ async function openDocumentAtPath(path, options = {}) {
|
|
|
192
207
|
bytes,
|
|
193
208
|
path
|
|
194
209
|
};
|
|
210
|
+
case "doc": return {
|
|
211
|
+
format,
|
|
212
|
+
layout: readPdf(docToPdf(bytes)),
|
|
213
|
+
bytes,
|
|
214
|
+
path
|
|
215
|
+
};
|
|
216
|
+
case "xls": return {
|
|
217
|
+
format,
|
|
218
|
+
layout: readPdf(xlsToPdf(bytes)),
|
|
219
|
+
bytes,
|
|
220
|
+
path
|
|
221
|
+
};
|
|
222
|
+
case "ppt": return {
|
|
223
|
+
format,
|
|
224
|
+
layout: readPdf(pptToPdf(bytes)),
|
|
225
|
+
bytes,
|
|
226
|
+
path
|
|
227
|
+
};
|
|
195
228
|
case "odf": throw new Error("A standalone .odf formula document has no editor; convert it to PDF (odfToPdf) instead");
|
|
196
229
|
}
|
|
197
230
|
}
|
|
@@ -239,7 +272,7 @@ function createNewDocument(format) {
|
|
|
239
272
|
}
|
|
240
273
|
}
|
|
241
274
|
async function saveDocumentTo(openDocument, path) {
|
|
242
|
-
if (openDocument.format === "odb" || openDocument.format === "xlsx" || openDocument.format === "csv" || openDocument.format === "svg" || openDocument.format === "rtf" || openDocument.format === "wpd") throw new Error(`A ${openDocument.format} document is opened read-only and cannot be written back`);
|
|
275
|
+
if (openDocument.format === "odb" || openDocument.format === "xlsx" || openDocument.format === "csv" || openDocument.format === "svg" || openDocument.format === "rtf" || openDocument.format === "wpd" || openDocument.format === "doc" || openDocument.format === "xls" || openDocument.format === "ppt") throw new Error(`A ${openDocument.format} document is opened read-only and cannot be written back`);
|
|
243
276
|
if (openDocument.format === "markdown") {
|
|
244
277
|
await writeFile(path, encodeMarkdownText(openDocument.editor.toMarkdownText()));
|
|
245
278
|
return;
|
|
@@ -325,7 +358,10 @@ function rootScreenForFormat(format) {
|
|
|
325
358
|
case "csv":
|
|
326
359
|
case "svg":
|
|
327
360
|
case "rtf":
|
|
328
|
-
case "wpd":
|
|
361
|
+
case "wpd":
|
|
362
|
+
case "doc":
|
|
363
|
+
case "xls":
|
|
364
|
+
case "ppt": return { kind: "pdfPageList" };
|
|
329
365
|
}
|
|
330
366
|
}
|
|
331
367
|
function currentScreen(state) {
|
|
@@ -486,6 +522,24 @@ function documentWithPath(doc, path) {
|
|
|
486
522
|
bytes: doc.bytes,
|
|
487
523
|
path
|
|
488
524
|
};
|
|
525
|
+
case "doc": return {
|
|
526
|
+
format: "doc",
|
|
527
|
+
layout: doc.layout,
|
|
528
|
+
bytes: doc.bytes,
|
|
529
|
+
path
|
|
530
|
+
};
|
|
531
|
+
case "xls": return {
|
|
532
|
+
format: "xls",
|
|
533
|
+
layout: doc.layout,
|
|
534
|
+
bytes: doc.bytes,
|
|
535
|
+
path
|
|
536
|
+
};
|
|
537
|
+
case "ppt": return {
|
|
538
|
+
format: "ppt",
|
|
539
|
+
layout: doc.layout,
|
|
540
|
+
bytes: doc.bytes,
|
|
541
|
+
path
|
|
542
|
+
};
|
|
489
543
|
}
|
|
490
544
|
}
|
|
491
545
|
function reopenEditable(doc, bytes) {
|
|
@@ -804,7 +858,7 @@ function appReducer(state, action) {
|
|
|
804
858
|
selection: {},
|
|
805
859
|
errorDetail: void 0,
|
|
806
860
|
stack: [rootScreenForFormat(action.doc.format)]
|
|
807
|
-
}, "info", action.doc.format === "xlsx" || action.doc.format === "csv" || action.doc.format === "svg" || action.doc.format === "rtf" || action.doc.format === "wpd" ? `Opened ${action.path} as a read-only PDF preview -- press ':' then 'export pdf' to save it as a real PDF` : `Opened ${action.path}`);
|
|
861
|
+
}, "info", action.doc.format === "xlsx" || action.doc.format === "csv" || action.doc.format === "svg" || action.doc.format === "rtf" || action.doc.format === "wpd" || action.doc.format === "doc" || action.doc.format === "xls" || action.doc.format === "ppt" ? `Opened ${action.path} as a read-only PDF preview -- press ':' then 'export pdf' to save it as a real PDF` : `Opened ${action.path}`);
|
|
808
862
|
case "OPEN_FILE_ERROR": return withStatus({
|
|
809
863
|
...state,
|
|
810
864
|
errorDetail: {
|
|
@@ -1399,7 +1453,7 @@ function appReducer(state, action) {
|
|
|
1399
1453
|
case "UNDO": {
|
|
1400
1454
|
const doc = state.openDocument;
|
|
1401
1455
|
if (doc === void 0) return withStatus(state, "info", "There is nothing to undo");
|
|
1402
|
-
if (doc.format === "odb" || doc.format === "xlsx" || doc.format === "csv" || doc.format === "svg" || doc.format === "rtf" || doc.format === "wpd") return withStatus(state, "warning", `A ${doc.format} document is read-only, so it has no history to undo`);
|
|
1456
|
+
if (doc.format === "odb" || doc.format === "xlsx" || doc.format === "csv" || doc.format === "svg" || doc.format === "rtf" || doc.format === "wpd" || doc.format === "doc" || doc.format === "xls" || doc.format === "ppt") return withStatus(state, "warning", `A ${doc.format} document is read-only, so it has no history to undo`);
|
|
1403
1457
|
const snapshot = state.undoStack.at(-1);
|
|
1404
1458
|
if (snapshot === void 0) return withStatus(state, "info", "There is nothing to undo");
|
|
1405
1459
|
const restored = doc.format === "markdown" ? {
|
|
@@ -7243,7 +7297,7 @@ function OdtBodyListScreen() {
|
|
|
7243
7297
|
//#endregion
|
|
7244
7298
|
//#region src/tui/screens/editors/pdf/shared.ts
|
|
7245
7299
|
function requirePdfDocument(openDocument) {
|
|
7246
|
-
if (openDocument?.format !== "pdf" && openDocument?.format !== "xlsx" && openDocument?.format !== "csv" && openDocument?.format !== "svg" && openDocument?.format !== "rtf" && openDocument?.format !== "wpd") throw new Error("A PDF inspection screen rendered without an open PDF, xlsx, csv, svg, rtf, or
|
|
7300
|
+
if (openDocument?.format !== "pdf" && openDocument?.format !== "xlsx" && openDocument?.format !== "csv" && openDocument?.format !== "svg" && openDocument?.format !== "rtf" && openDocument?.format !== "wpd" && openDocument?.format !== "doc" && openDocument?.format !== "xls" && openDocument?.format !== "ppt") throw new Error("A PDF inspection screen rendered without an open PDF, xlsx, csv, svg, rtf, wpd, doc, xls, or ppt document; the app router only reaches this screen group from pdfPageList, which is only ever the root screen of one of those nine formats.");
|
|
7247
7301
|
return openDocument;
|
|
7248
7302
|
}
|
|
7249
7303
|
function isEditablePdfDocument(doc) {
|
|
@@ -9076,7 +9130,10 @@ function metadataFor(doc) {
|
|
|
9076
9130
|
case "csv":
|
|
9077
9131
|
case "svg":
|
|
9078
9132
|
case "rtf":
|
|
9079
|
-
case "wpd":
|
|
9133
|
+
case "wpd":
|
|
9134
|
+
case "doc":
|
|
9135
|
+
case "xls":
|
|
9136
|
+
case "ppt": return doc.layout.metadata;
|
|
9080
9137
|
case "odb": throw new Error("A .odb database has no document-level metadata -- it is a table/form/report container, not a single document with its own title/author/etc.");
|
|
9081
9138
|
}
|
|
9082
9139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-cli",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
4
4
|
"description": "CLI and interactive Ink TUI for documents.js: every docx/pptx/odt/odp/ods/odg/odf/pdf/odm/odb/xlsx/csv/svg/markdown/rtf conversion, bridge, and editor as a scriptable command or a terminal app.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"packageManager": "pnpm@11.6.0",
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"commander": "^15.0.0",
|
|
93
|
-
"document-outline.js": "^3.2.
|
|
94
|
-
"document-schema.js": "^5.5.
|
|
95
|
-
"documents.js": "^6.
|
|
93
|
+
"document-outline.js": "^3.2.3",
|
|
94
|
+
"document-schema.js": "^5.5.1",
|
|
95
|
+
"documents.js": "^6.5.0",
|
|
96
96
|
"ink": "^7.1.1",
|
|
97
97
|
"ink-text-input": "^6.0.0",
|
|
98
98
|
"react": "^19.2.8"
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"eslint": "^10.8.0",
|
|
107
107
|
"husky": "^9.1.7",
|
|
108
108
|
"ink-testing-library": "^4.0.0",
|
|
109
|
-
"odf.js": "^6.
|
|
109
|
+
"odf.js": "^6.4.0",
|
|
110
110
|
"publint": "^0.3.22",
|
|
111
111
|
"semantic-release": "^25.0.8",
|
|
112
112
|
"tsdown": "^0.22.14",
|