js.documents 14.1.0 → 14.2.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 +8 -8
- package/dist/bin-dispatch.cjs +1 -1
- package/dist/bin-dispatch.d.cts +3 -3
- package/dist/bin-dispatch.d.ts +3 -3
- package/dist/bin-dispatch.js +1 -1
- package/dist/convert/composition.cjs +1 -1
- package/dist/convert/composition.js +1 -1
- package/dist/convert/convert.cjs +1 -1
- package/dist/convert/convert.js +1 -1
- package/dist/convert/document-fonts.cjs +1 -1
- package/dist/convert/document-fonts.js +1 -1
- package/dist/convert/from-package.cjs +2 -2
- package/dist/convert/from-package.js +2 -2
- package/dist/convert/variant-bridges.cjs +2 -2
- package/dist/convert/variant-bridges.js +2 -2
- package/dist/csv/write.cjs +2 -2
- package/dist/csv/write.js +2 -2
- package/dist/{diagnostics-9twvwLNY.d.cts → diagnostics-CGWySzd-.d.cts} +1 -0
- package/dist/{diagnostics-9twvwLNY.d.ts → diagnostics-CGWySzd-.d.ts} +1 -0
- package/dist/edit/doc/table.cjs +3 -3
- package/dist/edit/doc/table.js +3 -3
- package/dist/edit/docx/content.cjs +1 -1
- package/dist/edit/docx/content.js +1 -1
- package/dist/edit/docx/image.cjs +1 -1
- package/dist/edit/docx/image.js +1 -1
- package/dist/edit/docx/paragraph.cjs +1 -1
- package/dist/edit/docx/paragraph.js +1 -1
- package/dist/edit/markdown/table.cjs +3 -3
- package/dist/edit/markdown/table.js +3 -3
- package/dist/edit/odp/slide.d.cts +1 -1
- package/dist/edit/odp/slide.d.ts +1 -1
- package/dist/edit/ods/sheet.cjs +1 -1
- package/dist/edit/ods/sheet.js +1 -1
- package/dist/edit/odt/content.cjs +4 -2
- package/dist/edit/odt/content.d.cts +2 -2
- package/dist/edit/odt/content.d.ts +2 -2
- package/dist/edit/odt/content.js +4 -2
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +59 -4
- package/dist/edit/odt/table.d.cts +1 -1
- package/dist/edit/odt/table.d.ts +1 -1
- package/dist/edit/odt/table.js +59 -4
- package/dist/edit/pptx/content.cjs +12 -2
- package/dist/edit/pptx/content.d.cts +1 -1
- package/dist/edit/pptx/content.d.ts +1 -1
- package/dist/edit/pptx/content.js +12 -2
- package/dist/edit/pptx/diagnostics.cjs +4 -1
- package/dist/edit/pptx/diagnostics.d.cts +1 -1
- package/dist/edit/pptx/diagnostics.d.ts +1 -1
- package/dist/edit/pptx/diagnostics.js +4 -1
- package/dist/edit/table-grid.cjs +2 -2
- package/dist/edit/table-grid.js +2 -2
- package/dist/firebird/backup.cjs +4 -4
- package/dist/firebird/backup.js +4 -4
- package/dist/firebird/data.cjs +2 -2
- package/dist/firebird/data.js +2 -2
- package/dist/hsqldb/binary-script.cjs +3 -3
- package/dist/hsqldb/binary-script.js +3 -3
- package/dist/hsqldb/cache.cjs +2 -2
- package/dist/hsqldb/cache.js +2 -2
- package/dist/hsqldb/rowformat.cjs +2 -2
- package/dist/hsqldb/rowformat.js +2 -2
- package/dist/hsqldb/script.cjs +2 -2
- package/dist/hsqldb/script.js +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/layout/engine.cjs +1 -1
- package/dist/layout/engine.js +1 -1
- package/dist/layout/reconstruct.cjs +6 -6
- package/dist/layout/reconstruct.js +6 -6
- package/dist/layout/shared.cjs +4 -3
- package/dist/layout/shared.js +4 -3
- package/dist/layout/slides.cjs +1 -1
- package/dist/layout/slides.js +1 -1
- package/dist/markdown/render.cjs +3 -3
- package/dist/markdown/render.js +3 -3
- package/dist/metadata/write.cjs +12 -12
- package/dist/metadata/write.js +12 -12
- package/dist/odb/csv.cjs +2 -2
- package/dist/odb/csv.js +2 -2
- package/dist/odb/formula/errors.cjs +3 -3
- package/dist/odb/formula/errors.js +3 -3
- package/dist/odb/formula/evaluate.cjs +4 -4
- package/dist/odb/formula/evaluate.js +4 -4
- package/dist/odb/formula/parser.cjs +2 -2
- package/dist/odb/formula/parser.js +2 -2
- package/dist/odb/read.cjs +9 -9
- package/dist/odb/read.js +9 -9
- package/dist/odb/report/content.cjs +1 -1
- package/dist/odb/report/content.js +1 -1
- package/dist/odb/report/render.cjs +1 -1
- package/dist/odb/report/render.js +1 -1
- package/dist/odb/report/source.cjs +1 -1
- package/dist/odb/report/source.js +1 -1
- package/dist/odb/sql/errors.cjs +3 -3
- package/dist/odb/sql/errors.js +3 -3
- package/dist/odb/sql/evaluate.cjs +9 -9
- package/dist/odb/sql/evaluate.js +9 -9
- package/dist/odb/sql/parser.cjs +2 -2
- package/dist/odb/sql/parser.js +2 -2
- package/dist/package-codec.cjs +1 -1
- package/dist/package-codec.js +1 -1
- package/dist/svg/write.cjs +2 -2
- package/dist/svg/write.js +2 -2
- package/dist/{table-Cou5rKOo.d.ts → table-B5htMG3g.d.ts} +2 -0
- package/dist/{table-Bt9ahRyh.d.cts → table-DrE6jEWv.d.cts} +2 -0
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -167,13 +167,13 @@ const pdfFromOdg = odgToPdf(odgBytes);
|
|
|
167
167
|
const odgBytes2 = pdfToOdg(pdfFromOdg);
|
|
168
168
|
|
|
169
169
|
const pdfFromOds = odsToPdf(odsBytes);
|
|
170
|
-
const odsBytes2 = pdfToOds(pdfFromOds); // recovers what was printed, then heuristically re-types it
|
|
170
|
+
const odsBytes2 = pdfToOds(pdfFromOds); // recovers what was printed, then heuristically re-types it — see Fidelity
|
|
171
171
|
|
|
172
172
|
const pdfFromXlsx = xlsxToPdf(xlsxBytes); // composes xlsxToOds -> odsToPdf internally
|
|
173
173
|
const xlsxBytes2 = pdfToXlsx(pdfFromXlsx); // composes pdfToOds -> odsToXlsx internally
|
|
174
174
|
|
|
175
175
|
const pdfFromMarkdown = markdownToPdf(markdownBytes);
|
|
176
|
-
const markdownBytes2 = pdfToMarkdown(pdfFromMarkdown); // the lossiest conversion in the whole package
|
|
176
|
+
const markdownBytes2 = pdfToMarkdown(pdfFromMarkdown); // the lossiest conversion in the whole package — see Fidelity; it does carry page boundaries (one '<!-- page break -->' marker per page) and rank-inferred heading levels
|
|
177
177
|
|
|
178
178
|
const pdfFromCsv = csvToPdf(csvBytes); // composes csvToOds -> odsToPdf internally
|
|
179
179
|
const csvBytes2 = pdfToCsv(pdfFromCsv); // composes pdfToOds -> odsToCsv internally; recovers what was printed, then heuristically re-types it
|
|
@@ -214,7 +214,7 @@ const docxBytes = odtToDocx(odtBytes);
|
|
|
214
214
|
const odtBytes2 = docxToOdt(docxBytes);
|
|
215
215
|
|
|
216
216
|
const docxFromMarkdown = markdownToDocx(markdownBytes);
|
|
217
|
-
const markdownBytes3 = docxToMarkdown(docxFromMarkdown); // colour, font family/size, and explicit alignment have no markdown source construct
|
|
217
|
+
const markdownBytes3 = docxToMarkdown(docxFromMarkdown); // colour, font family/size, and explicit alignment have no markdown source construct — dropped on this hop
|
|
218
218
|
```
|
|
219
219
|
|
|
220
220
|
Each takes an optional `{ signal }` — no `onSubstitution`/`sink`, since there is no font substitution or PDF-parse degradation. `odtToDocx`/`markdownToDocx`/`docxToOdt`/`docxToMarkdown` additionally take `onMathDiagnostic`, called per formula construct that degraded crossing the bridge. The csv-sourced bridges (`csvToOds`, `csvToXlsx`, `csvToMarkdown`, `csvToPdf`) take `{ delimiter }` — `'\t'` parses the same format as TSV, since a delimiter is a parse option, not a different document format — and `onCellTypeInference`, the per-decision audit channel the read shares with `pdfToOds`. The csv-target bridges (`odsToCsv`, `xlsxToCsv`, `markdownToCsv`, `pdfToCsv`) take `{ delimiter, sheet }`: csv has no second sheet, so writing a multi-sheet source refuses with `CsvSheetNotSpecifiedError` naming every sheet until a caller selects one. The svg-sourced bridges (`svgToOdg`, `svgToPdf`) take `onSvgDiagnostic`, the reader's per-scope-limit channel; the svg-target bridges (`odgToSvg`, `pdfToSvg`) take `{ page, onSvgDiagnostic }`: an svg is a single drawing, so writing a multi-page source refuses with `SvgMultiPageNotSpecifiedError` naming the page count until `{ page }` selects one (an index, because drawing pages are anonymous where sheets are named).
|
|
@@ -254,7 +254,7 @@ import { docxToPdf } from "documents.js";
|
|
|
254
254
|
|
|
255
255
|
const pdfBytes = docxToPdf(docxBytes, {
|
|
256
256
|
onDocument: (pkg) => {
|
|
257
|
-
console.log(pkg.kind); // 'wordprocessing'
|
|
257
|
+
console.log(pkg.kind); // 'wordprocessing' — the document kind rides the tree's root
|
|
258
258
|
console.log(pkg.pages?.length); // populated for every X-to-PDF/PDF-to-X conversion
|
|
259
259
|
const content = flattenTree(pkg); // the flat ContentDocument, fully materialised
|
|
260
260
|
const block =
|
|
@@ -358,7 +358,7 @@ const patchedBytes = setDocumentMetadata("docx", "docx", docxBytes, {
|
|
|
358
358
|
import { readNativeDocumentTree } from "documents.js";
|
|
359
359
|
|
|
360
360
|
const tree = readNativeDocumentTree("xlsx", xlsxBytes);
|
|
361
|
-
console.log(tree.kind); // 'spreadsheet'
|
|
361
|
+
console.log(tree.kind); // 'spreadsheet' — the workbook's own shape, never a projection through some other target
|
|
362
362
|
```
|
|
363
363
|
|
|
364
364
|
Every module under `src/` is deep-importable by package-relative path:
|
|
@@ -525,7 +525,7 @@ page.addPath({
|
|
|
525
525
|
},
|
|
526
526
|
],
|
|
527
527
|
fill: { r: 1, g: 1, b: 0 },
|
|
528
|
-
}); // a genuine Bezier curve
|
|
528
|
+
}); // a genuine Bezier curve — writes a real svg:d/svg:viewBox pair, not a polygon approximation
|
|
529
529
|
page.addTextBox({
|
|
530
530
|
frame: { xPt: 20, yPt: 200, widthPt: 300, heightPt: 30 },
|
|
531
531
|
text: "A label on top",
|
|
@@ -802,7 +802,7 @@ The package is layered from generic primitives outward to the two conversion dir
|
|
|
802
802
|
- **`src/omml/`** — the MathML ⇄ OMML structural translator, both directions. `write.ts` covers the identical construct set `src/mathml/layout.ts` typesets; `read.ts` covers strictly more (reads what Word authored, not just what this package writes). Lives outside `src/mathml/` because its I/O type is `ooxml.js`'s `XmlElement` and `src/mathml/` imports no package.
|
|
803
803
|
- **`src/ooxml/`** — thin adapters over `ooxml.js`'s own flat `readDocxContent`/`readPptxContent` readers, wrapping results into `ContentDocument`. `docx/formula.ts` is the one local reading pass (splicing OOXML math equations). `docx/extras.ts`'s `readDocxExtras` returns comments/footnotes/header-footer parts, section header/footer references, and numbering.
|
|
804
804
|
- **`src/odf/`** — ODF-side counterparts: `readOdtContent`/`readOdpContent`/`readOdsContent`/`readOdgContent` are thin adapters over `odf.js`. `formula/read.ts`/`formula/detect.ts` handle embedded formula detection (genuinely new work with no `odf.js`-side equivalent).
|
|
805
|
-
- **`src/ppt/`** — the one legacy-binary-format adapter with a genuine wrap of its own: `ppt-codec`'s `readPptContent`/`writePptContent` operate on the flat `{ metadata, slides }` shape (mirroring `ooxml.js`'s/`odf.js`'s own upstream flat readers), not a full `'presentation'`-kind `ContentDocument` directly, so `read.ts`/`write.ts` do the envelope wrap/unwrap `src/ooxml/pptx/read.ts`/`src/odf/odp/read.ts` also do for their own formats
|
|
805
|
+
- **`src/ppt/`** — the one legacy-binary-format adapter with a genuine wrap of its own: `ppt-codec`'s `readPptContent`/`writePptContent` operate on the flat `{ metadata, slides }` shape (mirroring `ooxml.js`'s/`odf.js`'s own upstream flat readers), not a full `'presentation'`-kind `ContentDocument` directly, so `read.ts`/`write.ts` do the envelope wrap/unwrap `src/ooxml/pptx/read.ts`/`src/odf/odp/read.ts` also do for their own formats — minus the formula/vector-recovery passes those two run, since `ppt-codec` has no upstream equivalent to splice in. `doc` and `xls` need no equivalent module: `doc-codec`'s `readDocContent`/`writeDocContent` and `xls-codec`'s `readXlsContent`/`writeXlsContent` already read/write a real `ContentDocument` directly (the latter over `XlsContentDocument`, a plain narrowed alias), so both are called straight from `src/codecs/read.ts`/`src/codecs/registry.ts`/`src/convert/composition.ts`, exactly like `rtf-codec`'s own pair.
|
|
806
806
|
- **`src/latex/`** — the LaTeX presentation → `MathExpression` lowering: `temml.ts` is the pinned-parser boundary (exact-version temml, its internal parse API guarded behind structural type guards), `lower.ts` the mechanical rules and their degradations, `symbols.ts` the glyph/command map and the prose definition scanner, `rational.ts` the exact-rational helpers, `lint.ts` the coherence lint. See [LaTeX lowering into the semantic core](#latex-lowering-into-the-semantic-core).
|
|
807
807
|
- **`src/markdown/`** — third adapter family, via `markdown-codec`. `readMarkdownContent` passes `readMarkdownContent`'s (markdown-codec's flat reader, so named since that package's 4.0.0; the bare `readMarkdown` name is now its tree-form `DocumentTree` reader) result through the math-lowering pass (`math.ts` — markdown-codec's preserved `$$` display blocks and `\( \)` inline spans become two-layer formula blocks, with the document's symbol table seeded from its own prose). `buildMarkdownText` wraps `writeMarkdownContent`, reconstructing markdown math syntax from formula blocks carrying a presentation layer. `text.ts` is the byte↔text boundary. `MarkdownEditor` holds a mutable in-memory `ContentDocument`.
|
|
808
808
|
- **`src/csv/`** — fourth adapter family, sharing the spreadsheet variant with xlsx/ods. `records.ts` is the RFC 4180 record parser/writer (one shared `quoteCsvField`, also used by the `.odb` CSV exporter); `text.ts` is the byte↔text boundary, working the character encoding out from the bytes through [byte-codec](../byte-codec/README.md#text-decoding) rather than assuming UTF-8, so Excel's own windows-1252 export reads, and refusing bytes that are not text at all; `read.ts` turns records into a spreadsheet `ContentDocument` (first record as verbatim string header, data cells through the same cell-typing heuristic `pdfToOds` uses); `write.ts` turns one sheet of a spreadsheet `ContentDocument` back into records via each cell's `displayText`. TSV is the same format with `{ delimiter: '\t' }` on either side.
|
|
@@ -825,7 +825,7 @@ pnpm build # turbo run _build (tsdown -> dist/ (ESM + CJS + .d.ts))
|
|
|
825
825
|
pnpm typecheck # turbo run _typecheck _typecheck:node
|
|
826
826
|
pnpm lint # turbo run _lint (eslint . --fix --cache --max-warnings 0)
|
|
827
827
|
pnpm test # turbo run _test (vitest run --project unit)
|
|
828
|
-
pnpm test:workers # turbo run _test:workers (vitest run --config vitest.workers.config.ts
|
|
828
|
+
pnpm test:workers # turbo run _test:workers (vitest run --config vitest.workers.config.ts — Cloudflare Workers runtime)
|
|
829
829
|
pnpm test:watch # vitest --project unit
|
|
830
830
|
pnpm test:smoke # turbo run _test:smoke (rebuilds dist/, verifies ESM/CJS parity, real round trips across all conversions, font resolution, from the built CJS bundle)
|
|
831
831
|
```
|
package/dist/bin-dispatch.cjs
CHANGED
|
@@ -26,7 +26,7 @@ function detectPackageManager(userAgent) {
|
|
|
26
26
|
return "npm";
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice
|
|
29
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice — the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
30
30
|
*/
|
|
31
31
|
function resolveBinDispatch(argv, userAgent) {
|
|
32
32
|
const head = argv[0];
|
package/dist/bin-dispatch.d.cts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
interface BinDispatch {
|
|
3
3
|
/** The npm package the launcher resolves and invokes. */
|
|
4
4
|
readonly pkg: "document-cli" | "document-mcp";
|
|
5
|
-
/** The executable to spawn
|
|
5
|
+
/** The executable to spawn — each JS package manager's own download-and-run command. */
|
|
6
6
|
readonly command: "npx" | "pnpm" | "yarn" | "bunx";
|
|
7
|
-
/** Arguments after the command itself
|
|
7
|
+
/** Arguments after the command itself — begins with the manager's fetch flags, then the package name, then the passthrough args. */
|
|
8
8
|
readonly runnerArgs: readonly string[];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice
|
|
11
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice — the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
12
12
|
*/
|
|
13
13
|
declare function resolveBinDispatch(argv: readonly string[], userAgent: string | undefined): BinDispatch;
|
|
14
14
|
//#endregion
|
package/dist/bin-dispatch.d.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
interface BinDispatch {
|
|
3
3
|
/** The npm package the launcher resolves and invokes. */
|
|
4
4
|
readonly pkg: "document-cli" | "document-mcp";
|
|
5
|
-
/** The executable to spawn
|
|
5
|
+
/** The executable to spawn — each JS package manager's own download-and-run command. */
|
|
6
6
|
readonly command: "npx" | "pnpm" | "yarn" | "bunx";
|
|
7
|
-
/** Arguments after the command itself
|
|
7
|
+
/** Arguments after the command itself — begins with the manager's fetch flags, then the package name, then the passthrough args. */
|
|
8
8
|
readonly runnerArgs: readonly string[];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice
|
|
11
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice — the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
12
12
|
*/
|
|
13
13
|
declare function resolveBinDispatch(argv: readonly string[], userAgent: string | undefined): BinDispatch;
|
|
14
14
|
//#endregion
|
package/dist/bin-dispatch.js
CHANGED
|
@@ -25,7 +25,7 @@ function detectPackageManager(userAgent) {
|
|
|
25
25
|
return "npm";
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice
|
|
28
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice — the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
29
29
|
*/
|
|
30
30
|
function resolveBinDispatch(argv, userAgent) {
|
|
31
31
|
const head = argv[0];
|
|
@@ -99,7 +99,7 @@ function latin1ToBytes(text) {
|
|
|
99
99
|
const bytes = new Uint8Array(text.length);
|
|
100
100
|
for (let index = 0; index < text.length; index += 1) {
|
|
101
101
|
const code = text.charCodeAt(index);
|
|
102
|
-
if (code > 255) throw new TypeError(`latin1ToBytes: character at index ${String(index)} is U+${code.toString(16).toUpperCase().padStart(4, "0")}, above U+00FF
|
|
102
|
+
if (code > 255) throw new TypeError(`latin1ToBytes: character at index ${String(index)} is U+${code.toString(16).toUpperCase().padStart(4, "0")}, above U+00FF — this string no longer holds the file's original bytes`);
|
|
103
103
|
bytes[index] = code;
|
|
104
104
|
}
|
|
105
105
|
return bytes;
|
|
@@ -98,7 +98,7 @@ function latin1ToBytes(text) {
|
|
|
98
98
|
const bytes = new Uint8Array(text.length);
|
|
99
99
|
for (let index = 0; index < text.length; index += 1) {
|
|
100
100
|
const code = text.charCodeAt(index);
|
|
101
|
-
if (code > 255) throw new TypeError(`latin1ToBytes: character at index ${String(index)} is U+${code.toString(16).toUpperCase().padStart(4, "0")}, above U+00FF
|
|
101
|
+
if (code > 255) throw new TypeError(`latin1ToBytes: character at index ${String(index)} is U+${code.toString(16).toUpperCase().padStart(4, "0")}, above U+00FF — this string no longer holds the file's original bytes`);
|
|
102
102
|
bytes[index] = code;
|
|
103
103
|
}
|
|
104
104
|
return bytes;
|
package/dist/convert/convert.cjs
CHANGED
|
@@ -188,7 +188,7 @@ function markdownToCsv(bytes, options) {
|
|
|
188
188
|
var OdmUnresolvedSectionError = class extends Error {
|
|
189
189
|
hrefs;
|
|
190
190
|
constructor(hrefs) {
|
|
191
|
-
super(`odmToPdf: ${hrefs.length} chapter section(s) could not be resolved
|
|
191
|
+
super(`odmToPdf: ${hrefs.length} chapter section(s) could not be resolved — no inline content and no resolveSubDocument result for: ${hrefs.join(", ")}`);
|
|
192
192
|
this.name = "OdmUnresolvedSectionError";
|
|
193
193
|
this.hrefs = hrefs;
|
|
194
194
|
}
|
package/dist/convert/convert.js
CHANGED
|
@@ -187,7 +187,7 @@ function markdownToCsv(bytes, options) {
|
|
|
187
187
|
var OdmUnresolvedSectionError = class extends Error {
|
|
188
188
|
hrefs;
|
|
189
189
|
constructor(hrefs) {
|
|
190
|
-
super(`odmToPdf: ${hrefs.length} chapter section(s) could not be resolved
|
|
190
|
+
super(`odmToPdf: ${hrefs.length} chapter section(s) could not be resolved — no inline content and no resolveSubDocument result for: ${hrefs.join(", ")}`);
|
|
191
191
|
this.name = "OdmUnresolvedSectionError";
|
|
192
192
|
this.hrefs = hrefs;
|
|
193
193
|
}
|
|
@@ -17,7 +17,7 @@ function isFontSourceFormat(format) {
|
|
|
17
17
|
var UnsupportedFontSourceFormatError = class extends Error {
|
|
18
18
|
format;
|
|
19
19
|
constructor(format) {
|
|
20
|
-
super(`'${format}' documents carry no source-embedded font faces to extract
|
|
20
|
+
super(`'${format}' documents carry no source-embedded font faces to extract — expected one of docx, pptx, odt, odp, ods, odg`);
|
|
21
21
|
this.name = "UnsupportedFontSourceFormatError";
|
|
22
22
|
this.format = format;
|
|
23
23
|
}
|
|
@@ -16,7 +16,7 @@ function isFontSourceFormat(format) {
|
|
|
16
16
|
var UnsupportedFontSourceFormatError = class extends Error {
|
|
17
17
|
format;
|
|
18
18
|
constructor(format) {
|
|
19
|
-
super(`'${format}' documents carry no source-embedded font faces to extract
|
|
19
|
+
super(`'${format}' documents carry no source-embedded font faces to extract — expected one of docx, pptx, odt, odp, ods, odg`);
|
|
20
20
|
this.name = "UnsupportedFontSourceFormatError";
|
|
21
21
|
this.format = format;
|
|
22
22
|
}
|
|
@@ -15,7 +15,7 @@ let pdf_codec = require("pdf-codec");
|
|
|
15
15
|
//#region src/convert/from-package.ts
|
|
16
16
|
function buildDocumentBytes(pkg, target) {
|
|
17
17
|
if (target === "pdf") {
|
|
18
|
-
if (pkg.pages === void 0) throw new Error("this DocumentTree has no pages
|
|
18
|
+
if (pkg.pages === void 0) throw new Error("this DocumentTree has no pages — only a package dumped from a <format>-to-pdf or pdf-to-<format> conversion carries them; a bridge conversion's own dump (e.g. odt-to-docx) never does, so 'pdf' is not a reachable target from it");
|
|
19
19
|
const { document: layout, formulas, fonts } = packageToLayout(pkg);
|
|
20
20
|
return (0, pdf_codec.writePdf)(layout, formulas.length > 0 ? {
|
|
21
21
|
formulas,
|
|
@@ -24,7 +24,7 @@ function buildDocumentBytes(pkg, target) {
|
|
|
24
24
|
}
|
|
25
25
|
if (require_convert_capability.READ_ONLY_FORMATS.has(target)) throw new Error(`'${target}' is a read-only format: it cannot be built from a DocumentTree, because there is no ContentDocument-to-${target} builder`);
|
|
26
26
|
const content = require_codecs_registry.DOCUMENT_FORMAT_CODECS[target].content;
|
|
27
|
-
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, is not 'pdf', and is not read-only
|
|
27
|
+
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, is not 'pdf', and is not read-only — this is an internal invariant violation, not a caller error`);
|
|
28
28
|
return require_model_bytes.requireArrayBufferBytes(content.write((0, document_schema_js.flattenTree)(pkg)));
|
|
29
29
|
}
|
|
30
30
|
function pageOfFrame(state, frame) {
|
|
@@ -14,7 +14,7 @@ import { LAYOUT_FORMAT_VERSION, createFontMeasurer, createFontRegistry, loadMath
|
|
|
14
14
|
//#region src/convert/from-package.ts
|
|
15
15
|
function buildDocumentBytes(pkg, target) {
|
|
16
16
|
if (target === "pdf") {
|
|
17
|
-
if (pkg.pages === void 0) throw new Error("this DocumentTree has no pages
|
|
17
|
+
if (pkg.pages === void 0) throw new Error("this DocumentTree has no pages — only a package dumped from a <format>-to-pdf or pdf-to-<format> conversion carries them; a bridge conversion's own dump (e.g. odt-to-docx) never does, so 'pdf' is not a reachable target from it");
|
|
18
18
|
const { document: layout, formulas, fonts } = packageToLayout(pkg);
|
|
19
19
|
return writePdf(layout, formulas.length > 0 ? {
|
|
20
20
|
formulas,
|
|
@@ -23,7 +23,7 @@ function buildDocumentBytes(pkg, target) {
|
|
|
23
23
|
}
|
|
24
24
|
if (READ_ONLY_FORMATS.has(target)) throw new Error(`'${target}' is a read-only format: it cannot be built from a DocumentTree, because there is no ContentDocument-to-${target} builder`);
|
|
25
25
|
const content = DOCUMENT_FORMAT_CODECS[target].content;
|
|
26
|
-
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, is not 'pdf', and is not read-only
|
|
26
|
+
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, is not 'pdf', and is not read-only — this is an internal invariant violation, not a caller error`);
|
|
27
27
|
return requireArrayBufferBytes(content.write(flattenTree(pkg)));
|
|
28
28
|
}
|
|
29
29
|
function pageOfFrame(state, frame) {
|
|
@@ -120,11 +120,11 @@ function sheetToTableBlock(sheet) {
|
|
|
120
120
|
const visibleColumns = [];
|
|
121
121
|
for (let column = 0; column <= maxColumn; column += 1) if (!hiddenColumns.has(column)) visibleColumns.push(column);
|
|
122
122
|
const columnWidthByIndex = new Map(sheet.columns.map((column) => [column.index, column.widthPt]));
|
|
123
|
-
const
|
|
123
|
+
const columns = visibleColumns.map((column) => ({ widthPt: columnWidthByIndex.get(column) ?? 72 }));
|
|
124
124
|
return {
|
|
125
125
|
kind: "table",
|
|
126
126
|
rows: visibleRows.map((row) => ({ cells: visibleColumns.map((column) => spreadsheetCellToTableCell(cellByPosition.get(`${String(row)}:${String(column)}`))) })),
|
|
127
|
-
|
|
127
|
+
columns
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
function spreadsheetToWordprocessing(doc) {
|
|
@@ -119,11 +119,11 @@ function sheetToTableBlock(sheet) {
|
|
|
119
119
|
const visibleColumns = [];
|
|
120
120
|
for (let column = 0; column <= maxColumn; column += 1) if (!hiddenColumns.has(column)) visibleColumns.push(column);
|
|
121
121
|
const columnWidthByIndex = new Map(sheet.columns.map((column) => [column.index, column.widthPt]));
|
|
122
|
-
const
|
|
122
|
+
const columns = visibleColumns.map((column) => ({ widthPt: columnWidthByIndex.get(column) ?? 72 }));
|
|
123
123
|
return {
|
|
124
124
|
kind: "table",
|
|
125
125
|
rows: visibleRows.map((row) => ({ cells: visibleColumns.map((column) => spreadsheetCellToTableCell(cellByPosition.get(`${String(row)}:${String(column)}`))) })),
|
|
126
|
-
|
|
126
|
+
columns
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
function spreadsheetToWordprocessing(doc) {
|
package/dist/csv/write.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var CsvUnsupportedDocumentKindError = class extends Error {
|
|
|
12
12
|
var CsvSheetNotSpecifiedError = class extends Error {
|
|
13
13
|
availableSheets;
|
|
14
14
|
constructor(availableSheets) {
|
|
15
|
-
super(`buildCsvText: this document has more than one sheet (${availableSheets.join(", ")})
|
|
15
|
+
super(`buildCsvText: this document has more than one sheet (${availableSheets.join(", ")}) — pass { sheet: '<name>' } to select one`);
|
|
16
16
|
this.name = "CsvSheetNotSpecifiedError";
|
|
17
17
|
this.availableSheets = availableSheets;
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ var CsvSheetNotFoundError = class extends Error {
|
|
|
21
21
|
sheet;
|
|
22
22
|
availableSheets;
|
|
23
23
|
constructor(sheet, availableSheets) {
|
|
24
|
-
super(`buildCsvText: sheet "${sheet}" not found
|
|
24
|
+
super(`buildCsvText: sheet "${sheet}" not found — available sheet(s): ${availableSheets.length === 0 ? "(none)" : availableSheets.join(", ")}`);
|
|
25
25
|
this.name = "CsvSheetNotFoundError";
|
|
26
26
|
this.sheet = sheet;
|
|
27
27
|
this.availableSheets = availableSheets;
|
package/dist/csv/write.js
CHANGED
|
@@ -11,7 +11,7 @@ var CsvUnsupportedDocumentKindError = class extends Error {
|
|
|
11
11
|
var CsvSheetNotSpecifiedError = class extends Error {
|
|
12
12
|
availableSheets;
|
|
13
13
|
constructor(availableSheets) {
|
|
14
|
-
super(`buildCsvText: this document has more than one sheet (${availableSheets.join(", ")})
|
|
14
|
+
super(`buildCsvText: this document has more than one sheet (${availableSheets.join(", ")}) — pass { sheet: '<name>' } to select one`);
|
|
15
15
|
this.name = "CsvSheetNotSpecifiedError";
|
|
16
16
|
this.availableSheets = availableSheets;
|
|
17
17
|
}
|
|
@@ -20,7 +20,7 @@ var CsvSheetNotFoundError = class extends Error {
|
|
|
20
20
|
sheet;
|
|
21
21
|
availableSheets;
|
|
22
22
|
constructor(sheet, availableSheets) {
|
|
23
|
-
super(`buildCsvText: sheet "${sheet}" not found
|
|
23
|
+
super(`buildCsvText: sheet "${sheet}" not found — available sheet(s): ${availableSheets.length === 0 ? "(none)" : availableSheets.join(", ")}`);
|
|
24
24
|
this.name = "CsvSheetNotFoundError";
|
|
25
25
|
this.sheet = sheet;
|
|
26
26
|
this.availableSheets = availableSheets;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
type PptxWriteDiagnosticSeverity = "info" | "warning";
|
|
3
3
|
declare const PptxWriteDiagnosticCodes: {
|
|
4
4
|
readonly TABLE_HEADER_ROW_DROPPED: "pptx-write/table-header-row-dropped";
|
|
5
|
+
readonly TABLE_HEADER_COLUMN_DROPPED: "pptx-write/table-header-column-dropped";
|
|
5
6
|
};
|
|
6
7
|
type PptxWriteDiagnosticCode = (typeof PptxWriteDiagnosticCodes)[keyof typeof PptxWriteDiagnosticCodes];
|
|
7
8
|
interface PptxWriteDiagnostic {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
type PptxWriteDiagnosticSeverity = "info" | "warning";
|
|
3
3
|
declare const PptxWriteDiagnosticCodes: {
|
|
4
4
|
readonly TABLE_HEADER_ROW_DROPPED: "pptx-write/table-header-row-dropped";
|
|
5
|
+
readonly TABLE_HEADER_COLUMN_DROPPED: "pptx-write/table-header-column-dropped";
|
|
5
6
|
};
|
|
6
7
|
type PptxWriteDiagnosticCode = (typeof PptxWriteDiagnosticCodes)[keyof typeof PptxWriteDiagnosticCodes];
|
|
7
8
|
interface PptxWriteDiagnostic {
|
package/dist/edit/doc/table.cjs
CHANGED
|
@@ -81,7 +81,7 @@ var DocTable = class {
|
|
|
81
81
|
}
|
|
82
82
|
appendRow() {
|
|
83
83
|
const node = this.live();
|
|
84
|
-
const row = buildRow(node.
|
|
84
|
+
const row = buildRow(node.columns.length);
|
|
85
85
|
node.rows.push(row);
|
|
86
86
|
return new DocTableRow(row);
|
|
87
87
|
}
|
|
@@ -115,13 +115,13 @@ var DocTable = class {
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
function buildTable(init) {
|
|
118
|
-
const
|
|
118
|
+
const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
|
|
119
119
|
const rows = [];
|
|
120
120
|
for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
|
|
121
121
|
return {
|
|
122
122
|
kind: "table",
|
|
123
123
|
rows,
|
|
124
|
-
|
|
124
|
+
columns
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
//#endregion
|
package/dist/edit/doc/table.js
CHANGED
|
@@ -80,7 +80,7 @@ var DocTable = class {
|
|
|
80
80
|
}
|
|
81
81
|
appendRow() {
|
|
82
82
|
const node = this.live();
|
|
83
|
-
const row = buildRow(node.
|
|
83
|
+
const row = buildRow(node.columns.length);
|
|
84
84
|
node.rows.push(row);
|
|
85
85
|
return new DocTableRow(row);
|
|
86
86
|
}
|
|
@@ -114,13 +114,13 @@ var DocTable = class {
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
function buildTable(init) {
|
|
117
|
-
const
|
|
117
|
+
const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
|
|
118
118
|
const rows = [];
|
|
119
119
|
for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
|
|
120
120
|
return {
|
|
121
121
|
kind: "table",
|
|
122
122
|
rows,
|
|
123
|
-
|
|
123
|
+
columns
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
//#endregion
|
|
@@ -214,7 +214,7 @@ function appendTable(body, block) {
|
|
|
214
214
|
const table = body.appendTable({
|
|
215
215
|
rows: 0,
|
|
216
216
|
columns: (0, document_schema_js.tableGridColumnCount)(block),
|
|
217
|
-
columnWidthsTwips: block.
|
|
217
|
+
columnWidthsTwips: block.columns.map((c) => require_model_units.ptToTwips(c.widthPt))
|
|
218
218
|
});
|
|
219
219
|
const positionsByRow = (0, document_schema_js.walkTableGrid)(block);
|
|
220
220
|
block.rows.forEach((row, rowIndex) => {
|
|
@@ -213,7 +213,7 @@ function appendTable(body, block) {
|
|
|
213
213
|
const table = body.appendTable({
|
|
214
214
|
rows: 0,
|
|
215
215
|
columns: tableGridColumnCount(block),
|
|
216
|
-
columnWidthsTwips: block.
|
|
216
|
+
columnWidthsTwips: block.columns.map((c) => ptToTwips(c.widthPt))
|
|
217
217
|
});
|
|
218
218
|
const positionsByRow = walkTableGrid(block);
|
|
219
219
|
block.rows.forEach((row, rowIndex) => {
|
package/dist/edit/docx/image.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const require_model_units = require("../../model/units.cjs");
|
|
|
4
4
|
const require_opc_media = require("../../opc/media.cjs");
|
|
5
5
|
//#region src/edit/docx/image.ts
|
|
6
6
|
function assertDocxWritableImageFormat(format) {
|
|
7
|
-
if (format === "svg") throw new Error("buildDocxPackage: an image block in svg format has no OOXML blip this writer can produce (WordprocessingML's a:blip only references a raster part Word decodes directly
|
|
7
|
+
if (format === "svg") throw new Error("buildDocxPackage: an image block in svg format has no OOXML blip this writer can produce (WordprocessingML's a:blip only references a raster part Word decodes directly — png/jpeg/gif)");
|
|
8
8
|
}
|
|
9
9
|
const DRAWING_NS = {
|
|
10
10
|
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
package/dist/edit/docx/image.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ptToEmu } from "../../model/units.js";
|
|
|
3
3
|
import { addImageMedia } from "../../opc/media.js";
|
|
4
4
|
//#region src/edit/docx/image.ts
|
|
5
5
|
function assertDocxWritableImageFormat(format) {
|
|
6
|
-
if (format === "svg") throw new Error("buildDocxPackage: an image block in svg format has no OOXML blip this writer can produce (WordprocessingML's a:blip only references a raster part Word decodes directly
|
|
6
|
+
if (format === "svg") throw new Error("buildDocxPackage: an image block in svg format has no OOXML blip this writer can produce (WordprocessingML's a:blip only references a raster part Word decodes directly — png/jpeg/gif)");
|
|
7
7
|
}
|
|
8
8
|
const DRAWING_NS = {
|
|
9
9
|
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
@@ -204,7 +204,7 @@ var DocxParagraph = class {
|
|
|
204
204
|
if (existing !== void 0) require_xml_edit.removeChild(pPr.children, existing);
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
if (value.numId === void 0) throw new Error("DocxParagraph.list requires a numId
|
|
207
|
+
if (value.numId === void 0) throw new Error("DocxParagraph.list requires a numId — buildDocxPackage mints one for memberships that lack it; set numId explicitly (see src/edit/docx/numbering.ts)");
|
|
208
208
|
const numPr = require_xml_edit.getOrCreateChildElement(pPr, "w:numPr", require_edit_docx_props.PPR_ORDER, () => require_xml_fragment.el("w:numPr"));
|
|
209
209
|
numPr.children = [require_xml_fragment.el("w:ilvl", { "w:val": String(value.level) }), require_xml_fragment.el("w:numId", { "w:val": value.numId })];
|
|
210
210
|
}
|
|
@@ -203,7 +203,7 @@ var DocxParagraph = class {
|
|
|
203
203
|
if (existing !== void 0) removeChild(pPr.children, existing);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
if (value.numId === void 0) throw new Error("DocxParagraph.list requires a numId
|
|
206
|
+
if (value.numId === void 0) throw new Error("DocxParagraph.list requires a numId — buildDocxPackage mints one for memberships that lack it; set numId explicitly (see src/edit/docx/numbering.ts)");
|
|
207
207
|
const numPr = getOrCreateChildElement(pPr, "w:numPr", PPR_ORDER, () => el("w:numPr"));
|
|
208
208
|
numPr.children = [el("w:ilvl", { "w:val": String(value.level) }), el("w:numId", { "w:val": value.numId })];
|
|
209
209
|
}
|
|
@@ -66,7 +66,7 @@ var MarkdownTable = class {
|
|
|
66
66
|
}
|
|
67
67
|
appendRow() {
|
|
68
68
|
const node = this.live();
|
|
69
|
-
const row = buildRow(node.
|
|
69
|
+
const row = buildRow(node.columns.length);
|
|
70
70
|
node.rows.push(row);
|
|
71
71
|
return new MarkdownTableRow(row);
|
|
72
72
|
}
|
|
@@ -78,13 +78,13 @@ var MarkdownTable = class {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
function buildTable(init) {
|
|
81
|
-
const
|
|
81
|
+
const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
|
|
82
82
|
const rows = [];
|
|
83
83
|
for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
|
|
84
84
|
return {
|
|
85
85
|
kind: "table",
|
|
86
86
|
rows,
|
|
87
|
-
|
|
87
|
+
columns
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
@@ -65,7 +65,7 @@ var MarkdownTable = class {
|
|
|
65
65
|
}
|
|
66
66
|
appendRow() {
|
|
67
67
|
const node = this.live();
|
|
68
|
-
const row = buildRow(node.
|
|
68
|
+
const row = buildRow(node.columns.length);
|
|
69
69
|
node.rows.push(row);
|
|
70
70
|
return new MarkdownTableRow(row);
|
|
71
71
|
}
|
|
@@ -77,13 +77,13 @@ var MarkdownTable = class {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
function buildTable(init) {
|
|
80
|
-
const
|
|
80
|
+
const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
|
|
81
81
|
const rows = [];
|
|
82
82
|
for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
|
|
83
83
|
return {
|
|
84
84
|
kind: "table",
|
|
85
85
|
rows,
|
|
86
|
-
|
|
86
|
+
columns
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-D1z0T9Za.cjs";
|
|
2
2
|
import { t as OdpShape } from "../../shape-Kmmxib5z.cjs";
|
|
3
3
|
import { s as OdgVector } from "../../vector-DDP7hgvm.cjs";
|
|
4
|
-
import { o as TableInit, r as OdtTable } from "../../table-
|
|
4
|
+
import { o as TableInit, r as OdtTable } from "../../table-DrE6jEWv.cjs";
|
|
5
5
|
import { Box, ContentFormula, ContentVector } from "document-schema.js";
|
|
6
6
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
7
7
|
//#region src/edit/odp/slide.d.ts
|
package/dist/edit/odp/slide.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-D1z0T9Za.js";
|
|
2
2
|
import { t as OdpShape } from "../../shape-ZAfNsCC5.js";
|
|
3
3
|
import { s as OdgVector } from "../../vector-DDP7hgvm.js";
|
|
4
|
-
import { o as TableInit, r as OdtTable } from "../../table-
|
|
4
|
+
import { o as TableInit, r as OdtTable } from "../../table-B5htMG3g.js";
|
|
5
5
|
import { Box, ContentFormula, ContentVector } from "document-schema.js";
|
|
6
6
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
7
7
|
//#region src/edit/odp/slide.d.ts
|
package/dist/edit/ods/sheet.cjs
CHANGED
|
@@ -65,7 +65,7 @@ var OdsSheet = class {
|
|
|
65
65
|
cell(row, column) {
|
|
66
66
|
const tableElement = this.live();
|
|
67
67
|
const node = require_edit_ods_address.resolveCellNode(tableElement, row, column);
|
|
68
|
-
if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range
|
|
68
|
+
if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range — address the merge's own anchor cell instead`);
|
|
69
69
|
require_edit_ods_column_row.ensureColumnDefaultWidth(this.pkg, tableElement, column);
|
|
70
70
|
require_edit_ods_column_row.ensureRowDefaultHeight(this.pkg, tableElement, row);
|
|
71
71
|
return new require_edit_ods_cell.OdsCell(node, this.pkg);
|
package/dist/edit/ods/sheet.js
CHANGED
|
@@ -64,7 +64,7 @@ var OdsSheet = class {
|
|
|
64
64
|
cell(row, column) {
|
|
65
65
|
const tableElement = this.live();
|
|
66
66
|
const node = resolveCellNode(tableElement, row, column);
|
|
67
|
-
if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range
|
|
67
|
+
if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range — address the merge's own anchor cell instead`);
|
|
68
68
|
ensureColumnDefaultWidth(this.pkg, tableElement, column);
|
|
69
69
|
ensureRowDefaultHeight(this.pkg, tableElement, row);
|
|
70
70
|
return new OdsCell(node, this.pkg);
|
|
@@ -136,6 +136,7 @@ function populateOdtTable(table, block) {
|
|
|
136
136
|
require_edit_table_grid.assertTableObeysGridRule(block, "populateOdtTable");
|
|
137
137
|
const gridPositions = (0, document_schema_js.walkTableGrid)(block);
|
|
138
138
|
const headerFlags = block.rows.map((row) => row.isHeader === true);
|
|
139
|
+
const columnHeaderFlags = block.columns.map((column) => column.isHeader === true);
|
|
139
140
|
block.rows.forEach((row, rowIndex) => {
|
|
140
141
|
const tableRow = table.appendEmptyRow();
|
|
141
142
|
tableRow.heightPt = row.heightPt;
|
|
@@ -155,6 +156,7 @@ function populateOdtTable(table, block) {
|
|
|
155
156
|
});
|
|
156
157
|
});
|
|
157
158
|
table.setHeaderRows(headerFlags);
|
|
159
|
+
table.setHeaderColumns(columnHeaderFlags);
|
|
158
160
|
}
|
|
159
161
|
function applyCellDecoration(target, cell) {
|
|
160
162
|
if (cell.background !== void 0) target.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
@@ -163,7 +165,7 @@ function applyCellDecoration(target, cell) {
|
|
|
163
165
|
/**
|
|
164
166
|
* The arguments that create the empty `table:table` a ContentTable is written into: no rows, since populateOdtTable appends one per ContentTableRow, and as many columns as the table's grid is wide.
|
|
165
167
|
*
|
|
166
|
-
* The grid width is what the rows and `
|
|
168
|
+
* The grid width is what the rows and `columns` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. Each column's own `widthPt` is passed through untouched, so a width the table does state is always written; `isHeader` is not part of this init at all, since populateOdtTable states it afterwards via OdtTable.setHeaderColumns, the identical two-step `setHeaderRows` already needs for the same reason on the row axis.
|
|
167
169
|
*
|
|
168
170
|
* Throws when the table has no rows: ODF requires a `table:table` to hold at least one `table:table-row`, so no faithful spelling exists, and dropping the table would lose it without a trace. `entryPoint` names the caller in the message. A table that breaks the grid rule is refused by populateOdtTable before it writes anything, and a table with no rows has no grid fault to report, so the two checks never compete.
|
|
169
171
|
*/
|
|
@@ -172,7 +174,7 @@ function odtTableInit(block, entryPoint) {
|
|
|
172
174
|
return {
|
|
173
175
|
rows: 0,
|
|
174
176
|
columns: (0, document_schema_js.tableGridColumnCount)(block),
|
|
175
|
-
columnWidthsPt: block.
|
|
177
|
+
columnWidthsPt: block.columns.map((column) => column.widthPt)
|
|
176
178
|
};
|
|
177
179
|
}
|
|
178
180
|
function appendTable(body, block) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
|
|
2
2
|
import { t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
|
|
3
|
-
import { o as TableInit, r as OdtTable } from "../../table-
|
|
3
|
+
import { o as TableInit, r as OdtTable } from "../../table-DrE6jEWv.cjs";
|
|
4
4
|
import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
|
|
5
5
|
import { Package } from "odf.js";
|
|
6
6
|
//#region src/edit/odt/content.d.ts
|
|
@@ -16,7 +16,7 @@ declare function populateOdtTable(table: OdtTable, block: ContentTable): void;
|
|
|
16
16
|
/**
|
|
17
17
|
* The arguments that create the empty `table:table` a ContentTable is written into: no rows, since populateOdtTable appends one per ContentTableRow, and as many columns as the table's grid is wide.
|
|
18
18
|
*
|
|
19
|
-
* The grid width is what the rows and `
|
|
19
|
+
* The grid width is what the rows and `columns` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. Each column's own `widthPt` is passed through untouched, so a width the table does state is always written; `isHeader` is not part of this init at all, since populateOdtTable states it afterwards via OdtTable.setHeaderColumns, the identical two-step `setHeaderRows` already needs for the same reason on the row axis.
|
|
20
20
|
*
|
|
21
21
|
* Throws when the table has no rows: ODF requires a `table:table` to hold at least one `table:table-row`, so no faithful spelling exists, and dropping the table would lose it without a trace. `entryPoint` names the caller in the message. A table that breaks the grid rule is refused by populateOdtTable before it writes anything, and a table with no rows has no grid fault to report, so the two checks never compete.
|
|
22
22
|
*/
|