js.documents 6.5.3 → 7.0.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.
- package/README.md +10 -1
- package/dist/convert/from-package.cjs +6 -4
- package/dist/convert/from-package.js +7 -5
- package/dist/edit/docx/content.cjs +2 -1
- package/dist/edit/docx/content.js +2 -1
- package/dist/edit/docx/table.cjs +2 -4
- package/dist/edit/docx/table.js +4 -6
- package/dist/edit/odp/slide.d.cts +1 -1
- package/dist/edit/odp/slide.d.ts +1 -1
- package/dist/edit/odt/content.cjs +3 -1
- package/dist/edit/odt/content.d.cts +1 -1
- package/dist/edit/odt/content.d.ts +1 -1
- package/dist/edit/odt/content.js +3 -1
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +64 -0
- package/dist/edit/odt/table.d.cts +1 -1
- package/dist/edit/odt/table.d.ts +1 -1
- package/dist/edit/odt/table.js +65 -1
- package/dist/edit/pptx/content.cjs +2 -1
- package/dist/edit/pptx/content.js +2 -1
- package/dist/edit/pptx/table.cjs +3 -1
- package/dist/edit/pptx/table.js +3 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/latex/lint.cjs +2 -26
- package/dist/latex/lint.js +2 -26
- package/dist/layout/engine.cjs +3 -2
- package/dist/layout/engine.js +4 -3
- package/dist/layout/reconstruct.cjs +6 -3
- package/dist/layout/reconstruct.js +6 -3
- package/dist/layout/sheets.cjs +3 -1
- package/dist/layout/sheets.js +4 -2
- package/dist/layout/slides.cjs +3 -2
- package/dist/layout/slides.js +4 -3
- package/dist/metadata/write.cjs +19 -2
- package/dist/metadata/write.d.cts +5 -1
- package/dist/metadata/write.d.ts +5 -1
- package/dist/metadata/write.js +19 -3
- package/dist/model/formula.cjs +70 -2
- package/dist/model/formula.d.cts +10 -3
- package/dist/model/formula.d.ts +10 -3
- package/dist/model/formula.js +70 -3
- package/dist/{table-DCqmpGAB.d.ts → table-BmMyqRML.d.ts} +2 -0
- package/dist/{table-CnRh10dW.d.cts → table-COmzfIOe.d.cts} +2 -0
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -332,7 +332,15 @@ const docxBytesAgain = encodeDocumentPackage("docx", pkg);
|
|
|
332
332
|
const odbPkg = decodeOdbPackage(odbBytes);
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
-
`readDocumentMetadata`/`setDocumentMetadata` read or patch metadata across any `DocumentFormat`. `setDocumentMetadata` patches in place (source/target formats must match); `odf` is rejected in both directions, and `csv` is rejected in both directions too (RFC 4180 text has no metadata container) — `readDocumentMetadata('csv', ...)` answers an empty `LayoutMetadata` for the same reason. `svg` reads its root `<title>` as `metadata.title` and is rejected as a `setDocumentMetadata` source/target for the mirror-image reason: `<title>` is svg's whole metadata surface, so any other override would be silently dropped by the rebuild. `readDocumentMetadata('xlsx', ...)` reads the workbook's own `docProps` like every other content format — `createdIso`/`modifiedIso` from `docProps/core.xml` when the file declares them, `docProps/app.xml`'s Application as `creator`, and `producer` unset (a PDF-only concept no semantic reader sets). It previously rendered a `xlsxToPdf` preview and read that PDF's metadata instead, which for a file carrying no timestamps of its own reported facts about the render rather than the workbook: timestamps stamped at the render moment and a producer naming the preview PDF's writer.
|
|
335
|
+
`readDocumentMetadata`/`setDocumentMetadata` read or patch metadata across any `DocumentFormat`. `setDocumentMetadata` patches in place (source/target formats must match); most formats rebuild a fresh package from that format's own `ContentDocument`, which is lossy wherever that format's own build function is (a docx rebuild, for instance, would drop comments, footnotes, header/footer parts, and numbering definitions — everything `readDocxExtras` covers). `docx`/`docx` is the one exception: it patches `docProps/core.xml` directly on the decoded `Package` instead of rebuilding (the identical mechanism `patchDocxMetadata` below exposes directly), so all of that survives byte-faithful — every caller of `setDocumentMetadata` gets this for free, with nothing to opt into. `pdf`/`pdf` similarly patches the parsed `LayoutDocument` directly, with no layout engine involved. `odf` is rejected in both directions, and `csv` is rejected in both directions too (RFC 4180 text has no metadata container) — `readDocumentMetadata('csv', ...)` answers an empty `LayoutMetadata` for the same reason. `svg` reads its root `<title>` as `metadata.title` and is rejected as a `setDocumentMetadata` source/target for the mirror-image reason: `<title>` is svg's whole metadata surface, so any other override would be silently dropped by the rebuild. `readDocumentMetadata('xlsx', ...)` reads the workbook's own `docProps` like every other content format — `createdIso`/`modifiedIso` from `docProps/core.xml` when the file declares them, `docProps/app.xml`'s Application as `creator`, and `producer` unset (a PDF-only concept no semantic reader sets). It previously rendered a `xlsxToPdf` preview and read that PDF's metadata instead, which for a file carrying no timestamps of its own reported facts about the render rather than the workbook: timestamps stamped at the render moment and a producer naming the preview PDF's writer.
|
|
336
|
+
|
|
337
|
+
`patchDocxMetadata` is the docx-specific patch `setDocumentMetadata` calls internally, exported in its own right for a caller that wants the lossless guarantee explicit at the call site rather than implied by passing `'docx'`/`'docx'`:
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
import { patchDocxMetadata } from "documents.js";
|
|
341
|
+
|
|
342
|
+
const patchedBytes = patchDocxMetadata(docxBytes, { title: "New title" });
|
|
343
|
+
```
|
|
336
344
|
|
|
337
345
|
```ts
|
|
338
346
|
import { readDocumentMetadata, setDocumentMetadata } from "documents.js";
|
|
@@ -870,6 +878,7 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
870
878
|
- **A rotated vector renders as `LayoutPath`** — `LayoutRect`/`LayoutEllipse` carry no rotation field. The rotation is exact (affine maps edges to edges, cubics to cubics); only the `rotationDeg` field is lost on PDF round trip.
|
|
871
879
|
- **`ContentVector.path.fillRule` is read from real `svg:fill-rule` markup.**
|
|
872
880
|
- **Cell borders render with real `style` (`solid`/`dashed`/`dotted`/`double`)** — `LayoutLineSchema` carries the enum, `pushCellBorderLines` sets it, pdf-codec renders it. The `'double'` inter-line offset is an internal constant (not in the data model).
|
|
881
|
+
- **A table/sheet cell's own `background` is document-schema.js's discriminated `ContentCellFill` (ExaDev/documents.js#951), not a bare `Color`.** `LayoutRect.fill` still carries only one flat colour, so every layout engine (`engine.ts`/`slides.ts`/`sheets.ts`) and PDF-to-package reconstruction (`from-package.ts`) renders a `'pattern'` fill through `resolveCellFillColor`'s own single representative colour (its foreground, falling back to its background) rather than the genuine two-colour pattern PDF has no primitive for. The live-view editors (`DocxTableCell`/`OdtTableCell`/`PptxTableCell`) keep their own `background: Color | undefined` setters unchanged for the same reason — none of their own underlying formats' editor writers states more than one flat colour — so writing a source cell's fill into one of these editors resolves it through the identical helper first.
|
|
873
882
|
- **Font resolution uses a real registry, standard 14 as last resort.** A family with no embedded/caller/vendored face (Aptos, third-party typefaces) renders through the nearest standard-14 face with a width-correction factor — expect a visual approximation, not line-identical output. MathML formula rendering is separate: it embeds STIX Two Math, not registry-resolvable.
|
|
874
883
|
- **Justified paragraphs stretch inter-word gaps** in all three layout engines (`engine.ts`, `slides.ts`, `sheets.ts`). `justifyLineGapsPt` divides slack evenly across detected word gaps; final lines stay left-aligned.
|
|
875
884
|
- **Encrypted PDFs and CCITT/JBIG2/JPX images are real capabilities** in pdf-codec — not scope boundaries. The permanent boundary is adversarial/malformed-input robustness.
|
|
@@ -74,13 +74,14 @@ function emitTableCell(state, cell) {
|
|
|
74
74
|
for (const frame of cell.frames ?? []) {
|
|
75
75
|
const page = pageOfFrame(state, frame);
|
|
76
76
|
if (page === void 0) continue;
|
|
77
|
-
|
|
77
|
+
const cellFill = cell.background === void 0 ? void 0 : (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
78
|
+
if (cellFill !== void 0) page.items.push({
|
|
78
79
|
kind: "rect",
|
|
79
80
|
xPt: frame.xPt,
|
|
80
81
|
yPt: frame.yPt,
|
|
81
82
|
widthPt: frame.widthPt,
|
|
82
83
|
heightPt: frame.heightPt,
|
|
83
|
-
fill:
|
|
84
|
+
fill: cellFill
|
|
84
85
|
});
|
|
85
86
|
if (cell.borders !== void 0) {
|
|
86
87
|
const frameYDown = require_model_geometry.flipY({
|
|
@@ -125,13 +126,14 @@ function emitSheetCell(state, cell) {
|
|
|
125
126
|
for (const frame of cell.frames ?? []) {
|
|
126
127
|
const page = pageOfFrame(state, frame);
|
|
127
128
|
if (page === void 0) continue;
|
|
128
|
-
|
|
129
|
+
const cellFill = cell.background === void 0 ? void 0 : (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
130
|
+
if (cellFill !== void 0) page.items.push({
|
|
129
131
|
kind: "rect",
|
|
130
132
|
xPt: frame.xPt,
|
|
131
133
|
yPt: frame.yPt,
|
|
132
134
|
widthPt: frame.widthPt,
|
|
133
135
|
heightPt: frame.heightPt,
|
|
134
|
-
fill:
|
|
136
|
+
fill: cellFill
|
|
135
137
|
});
|
|
136
138
|
if (cell.borders !== void 0) {
|
|
137
139
|
const frameYDown = require_model_geometry.flipY({
|
|
@@ -5,7 +5,7 @@ import "../layout/sheets.js";
|
|
|
5
5
|
import { convertVector } from "../layout/drawing.js";
|
|
6
6
|
import { READ_ONLY_FORMATS } from "./capability.js";
|
|
7
7
|
import { DOCUMENT_FORMAT_CODECS } from "../codecs/registry.js";
|
|
8
|
-
import { COLOR_BLACK, DEFAULT_LAYOUT_FONT, flattenTree } from "document-schema.js";
|
|
8
|
+
import { COLOR_BLACK, DEFAULT_LAYOUT_FONT, flattenTree, resolveCellFillColor } from "document-schema.js";
|
|
9
9
|
import { LAYOUT_FORMAT_VERSION, writePdf } from "pdf-codec";
|
|
10
10
|
//#region src/convert/from-package.ts
|
|
11
11
|
function buildDocumentBytes(pkg, target) {
|
|
@@ -73,13 +73,14 @@ function emitTableCell(state, cell) {
|
|
|
73
73
|
for (const frame of cell.frames ?? []) {
|
|
74
74
|
const page = pageOfFrame(state, frame);
|
|
75
75
|
if (page === void 0) continue;
|
|
76
|
-
|
|
76
|
+
const cellFill = cell.background === void 0 ? void 0 : resolveCellFillColor(cell.background);
|
|
77
|
+
if (cellFill !== void 0) page.items.push({
|
|
77
78
|
kind: "rect",
|
|
78
79
|
xPt: frame.xPt,
|
|
79
80
|
yPt: frame.yPt,
|
|
80
81
|
widthPt: frame.widthPt,
|
|
81
82
|
heightPt: frame.heightPt,
|
|
82
|
-
fill:
|
|
83
|
+
fill: cellFill
|
|
83
84
|
});
|
|
84
85
|
if (cell.borders !== void 0) {
|
|
85
86
|
const frameYDown = flipY({
|
|
@@ -124,13 +125,14 @@ function emitSheetCell(state, cell) {
|
|
|
124
125
|
for (const frame of cell.frames ?? []) {
|
|
125
126
|
const page = pageOfFrame(state, frame);
|
|
126
127
|
if (page === void 0) continue;
|
|
127
|
-
|
|
128
|
+
const cellFill = cell.background === void 0 ? void 0 : resolveCellFillColor(cell.background);
|
|
129
|
+
if (cellFill !== void 0) page.items.push({
|
|
128
130
|
kind: "rect",
|
|
129
131
|
xPt: frame.xPt,
|
|
130
132
|
yPt: frame.yPt,
|
|
131
133
|
widthPt: frame.widthPt,
|
|
132
134
|
heightPt: frame.heightPt,
|
|
133
|
-
fill:
|
|
135
|
+
fill: cellFill
|
|
134
136
|
});
|
|
135
137
|
if (cell.borders !== void 0) {
|
|
136
138
|
const frameYDown = flipY({
|
|
@@ -11,6 +11,7 @@ const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs
|
|
|
11
11
|
const require_model_formula = require("../../model/formula.cjs");
|
|
12
12
|
const require_edit_docx_numbering = require("./numbering.cjs");
|
|
13
13
|
let ooxml_js = require("ooxml.js");
|
|
14
|
+
let document_schema_js = require("document-schema.js");
|
|
14
15
|
//#region src/edit/docx/content.ts
|
|
15
16
|
function buildDocxPackage(content, options) {
|
|
16
17
|
if (content.kind !== "wordprocessing") throw new Error("buildDocxPackage requires a wordprocessing ContentDocument");
|
|
@@ -191,7 +192,7 @@ function appendTable(body, block) {
|
|
|
191
192
|
gridSpan: span
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
|
-
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
195
|
+
if (cell.background !== void 0) tableCell.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
195
196
|
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
196
197
|
populateCellBlocks(tableCell, cell.blocks);
|
|
197
198
|
colIndex += span;
|
|
@@ -10,6 +10,7 @@ import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from ".
|
|
|
10
10
|
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
11
11
|
import { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingRoot, declaration } from "./numbering.js";
|
|
12
12
|
import { base64ToBytes } from "ooxml.js";
|
|
13
|
+
import { resolveCellFillColor } from "document-schema.js";
|
|
13
14
|
//#region src/edit/docx/content.ts
|
|
14
15
|
function buildDocxPackage(content, options) {
|
|
15
16
|
if (content.kind !== "wordprocessing") throw new Error("buildDocxPackage requires a wordprocessing ContentDocument");
|
|
@@ -190,7 +191,7 @@ function appendTable(body, block) {
|
|
|
190
191
|
gridSpan: span
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
|
-
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
194
|
+
if (cell.background !== void 0) tableCell.background = resolveCellFillColor(cell.background);
|
|
194
195
|
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
195
196
|
populateCellBlocks(tableCell, cell.blocks);
|
|
196
197
|
colIndex += span;
|
package/dist/edit/docx/table.cjs
CHANGED
|
@@ -78,10 +78,8 @@ var DocxTableCell = class {
|
|
|
78
78
|
}
|
|
79
79
|
get background() {
|
|
80
80
|
const tcPr = this.tcPrElement(false);
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
if (fill === void 0 || fill === "auto" || fill === "none") return;
|
|
84
|
-
return (0, document_schema_js.rgbHexToColor)(fill);
|
|
81
|
+
const fill = (0, ooxml_js.readCellShading)(tcPr);
|
|
82
|
+
return fill === void 0 ? void 0 : (0, document_schema_js.resolveCellFillColor)(fill);
|
|
85
83
|
}
|
|
86
84
|
set background(value) {
|
|
87
85
|
if (value === void 0) {
|
package/dist/edit/docx/table.js
CHANGED
|
@@ -2,8 +2,8 @@ import { el } from "../../xml/fragment.js";
|
|
|
2
2
|
import { ptToTwips, twipsToPt } from "../../model/units.js";
|
|
3
3
|
import { directChildElement, insertInSchemaOrder, removeChild } from "../../xml/edit.js";
|
|
4
4
|
import { DocxParagraph, buildParagraph } from "./paragraph.js";
|
|
5
|
-
import { attr } from "ooxml.js";
|
|
6
|
-
import { colorToRgbHex, rgbHexToColor } from "document-schema.js";
|
|
5
|
+
import { attr, readCellShading } from "ooxml.js";
|
|
6
|
+
import { colorToRgbHex, resolveCellFillColor, rgbHexToColor } from "document-schema.js";
|
|
7
7
|
//#region src/edit/docx/table.ts
|
|
8
8
|
const DEFAULT_TABLE_WIDTH_TWIPS = 9360;
|
|
9
9
|
const TC_PR_CHILD_ORDER = [
|
|
@@ -77,10 +77,8 @@ var DocxTableCell = class {
|
|
|
77
77
|
}
|
|
78
78
|
get background() {
|
|
79
79
|
const tcPr = this.tcPrElement(false);
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
if (fill === void 0 || fill === "auto" || fill === "none") return;
|
|
83
|
-
return rgbHexToColor(fill);
|
|
80
|
+
const fill = readCellShading(tcPr);
|
|
81
|
+
return fill === void 0 ? void 0 : resolveCellFillColor(fill);
|
|
84
82
|
}
|
|
85
83
|
set background(value) {
|
|
86
84
|
if (value === void 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-D1z0T9Za.cjs";
|
|
2
2
|
import { t as OdpShape } from "../../shape-CAm2tKw5.cjs";
|
|
3
3
|
import { s as OdgVector } from "../../vector-DDP7hgvm.cjs";
|
|
4
|
-
import { a as TableInit, n as OdtTable } from "../../table-
|
|
4
|
+
import { a as TableInit, n as OdtTable } from "../../table-COmzfIOe.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-DAt3nOQm.js";
|
|
3
3
|
import { s as OdgVector } from "../../vector-DDP7hgvm.js";
|
|
4
|
-
import { a as TableInit, n as OdtTable } from "../../table-
|
|
4
|
+
import { a as TableInit, n as OdtTable } from "../../table-BmMyqRML.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
|
|
@@ -6,6 +6,7 @@ const require_model_formula = require("../../model/formula.cjs");
|
|
|
6
6
|
const require_edit_odt_paragraph = require("./paragraph.cjs");
|
|
7
7
|
const require_edit_odt_scaffold = require("./scaffold.cjs");
|
|
8
8
|
const require_edit_odt_editor = require("./editor.cjs");
|
|
9
|
+
let document_schema_js = require("document-schema.js");
|
|
9
10
|
let odf_js = require("odf.js");
|
|
10
11
|
//#region src/edit/odt/content.ts
|
|
11
12
|
function buildOdtPackage(content, options) {
|
|
@@ -133,6 +134,7 @@ function populateOdtTable(table, block) {
|
|
|
133
134
|
const verticalMerges = /* @__PURE__ */ new Map();
|
|
134
135
|
block.rows.forEach((row) => {
|
|
135
136
|
const tableRow = table.appendEmptyRow();
|
|
137
|
+
if (row.heightPt !== void 0) tableRow.heightPt = row.heightPt;
|
|
136
138
|
let colIndex = 0;
|
|
137
139
|
let horizontalCoverRemaining = 0;
|
|
138
140
|
row.cells.forEach((cell) => {
|
|
@@ -159,7 +161,7 @@ function populateOdtTable(table, block) {
|
|
|
159
161
|
tableCell.rowSpan = cell.rowSpan;
|
|
160
162
|
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
161
163
|
}
|
|
162
|
-
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
164
|
+
if (cell.background !== void 0) tableCell.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
163
165
|
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
164
166
|
populateCellBlocks(tableCell, cell.blocks);
|
|
165
167
|
colIndex += 1;
|
|
@@ -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 { n as OdtTable } from "../../table-
|
|
3
|
+
import { n as OdtTable } from "../../table-COmzfIOe.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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.js";
|
|
2
2
|
import { t as OdtParagraph } from "../../paragraph-D4f705GG.js";
|
|
3
|
-
import { n as OdtTable } from "../../table-
|
|
3
|
+
import { n as OdtTable } from "../../table-BmMyqRML.js";
|
|
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
|
package/dist/edit/odt/content.js
CHANGED
|
@@ -5,6 +5,7 @@ import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
|
5
5
|
import { headingStyleName } from "./paragraph.js";
|
|
6
6
|
import { createEmptyOdtPackage } from "./scaffold.js";
|
|
7
7
|
import { OdtEditor } from "./editor.js";
|
|
8
|
+
import { resolveCellFillColor } from "document-schema.js";
|
|
8
9
|
import { base64ToBytes } from "odf.js";
|
|
9
10
|
//#region src/edit/odt/content.ts
|
|
10
11
|
function buildOdtPackage(content, options) {
|
|
@@ -132,6 +133,7 @@ function populateOdtTable(table, block) {
|
|
|
132
133
|
const verticalMerges = /* @__PURE__ */ new Map();
|
|
133
134
|
block.rows.forEach((row) => {
|
|
134
135
|
const tableRow = table.appendEmptyRow();
|
|
136
|
+
if (row.heightPt !== void 0) tableRow.heightPt = row.heightPt;
|
|
135
137
|
let colIndex = 0;
|
|
136
138
|
let horizontalCoverRemaining = 0;
|
|
137
139
|
row.cells.forEach((cell) => {
|
|
@@ -158,7 +160,7 @@ function populateOdtTable(table, block) {
|
|
|
158
160
|
tableCell.rowSpan = cell.rowSpan;
|
|
159
161
|
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
160
162
|
}
|
|
161
|
-
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
163
|
+
if (cell.background !== void 0) tableCell.background = resolveCellFillColor(cell.background);
|
|
162
164
|
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
163
165
|
populateCellBlocks(tableCell, cell.blocks);
|
|
164
166
|
colIndex += 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
|
|
2
2
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
|
|
3
3
|
import { t as OdtList } from "../../list-yc0dJrOX.cjs";
|
|
4
|
-
import { a as TableInit, n as OdtTable } from "../../table-
|
|
4
|
+
import { a as TableInit, n as OdtTable } from "../../table-COmzfIOe.cjs";
|
|
5
5
|
import { Box, ContentFormula, ContentVector } from "document-schema.js";
|
|
6
6
|
import { Package } from "odf.js";
|
|
7
7
|
//#region src/edit/odt/editor.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.js";
|
|
2
2
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-D4f705GG.js";
|
|
3
3
|
import { t as OdtList } from "../../list-C32h8MNc.js";
|
|
4
|
-
import { a as TableInit, n as OdtTable } from "../../table-
|
|
4
|
+
import { a as TableInit, n as OdtTable } from "../../table-BmMyqRML.js";
|
|
5
5
|
import { Box, ContentFormula, ContentVector } from "document-schema.js";
|
|
6
6
|
import { Package } from "odf.js";
|
|
7
7
|
//#region src/edit/odt/editor.d.ts
|
package/dist/edit/odt/table.cjs
CHANGED
|
@@ -9,6 +9,7 @@ let odf_js = require("odf.js");
|
|
|
9
9
|
const DEFAULT_TABLE_WIDTH_PT = 468;
|
|
10
10
|
const TABLE_COLUMN_STYLE_PREFIX = "OdtCol";
|
|
11
11
|
const TABLE_CELL_STYLE_PREFIX = "OdtCell";
|
|
12
|
+
const TABLE_ROW_STYLE_PREFIX = "OdtRow";
|
|
12
13
|
const BORDER_EDGE_ATTRS = {
|
|
13
14
|
top: "fo:border-top",
|
|
14
15
|
right: "fo:border-right",
|
|
@@ -107,6 +108,51 @@ function internTableColumnWidth(pkg, widthPt) {
|
|
|
107
108
|
}, [require_xml_fragment.el("style:table-column-properties", { "style:column-width": formatted })]));
|
|
108
109
|
return name;
|
|
109
110
|
}
|
|
111
|
+
function currentRowPropertiesElement(pkg, rowElement) {
|
|
112
|
+
const styleName = (0, ooxml_js.attr)(rowElement, "table:style-name");
|
|
113
|
+
const styleElement = styleName === void 0 ? void 0 : (0, odf_js.findStyleElement)(styleName, "table-row", pkg);
|
|
114
|
+
return styleElement === void 0 ? void 0 : styleElement.children.find((c) => c.type === "element" && c.tag === "style:table-row-properties");
|
|
115
|
+
}
|
|
116
|
+
function cloneCurrentRowProperties(pkg, rowElement) {
|
|
117
|
+
const props = currentRowPropertiesElement(pkg, rowElement);
|
|
118
|
+
return props === void 0 ? require_xml_fragment.el("style:table-row-properties") : structuredClone(props);
|
|
119
|
+
}
|
|
120
|
+
function xmlNodesEqual(a, b) {
|
|
121
|
+
if (a.type === "element" && b.type === "element") return xmlElementsEqual(a, b);
|
|
122
|
+
if (a.type === "text" && b.type === "text") return a.value === b.value;
|
|
123
|
+
if (a.type === "cdata" && b.type === "cdata") return a.value === b.value;
|
|
124
|
+
if (a.type === "comment" && b.type === "comment") return a.value === b.value;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
function xmlElementsEqual(a, b) {
|
|
128
|
+
if (a.tag !== b.tag || a.attributes.length !== b.attributes.length) return false;
|
|
129
|
+
if (!a.attributes.every((candidate) => (0, ooxml_js.attr)(b, candidate.name) === candidate.value)) return false;
|
|
130
|
+
if (a.children.length !== b.children.length) return false;
|
|
131
|
+
for (let index = 0; index < a.children.length; index++) {
|
|
132
|
+
const childA = a.children[index];
|
|
133
|
+
const childB = b.children[index];
|
|
134
|
+
if (childA === void 0 || childB === void 0) return false;
|
|
135
|
+
if (!xmlNodesEqual(childA, childB)) return false;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
function internTableRowProperties(pkg, properties) {
|
|
140
|
+
const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
|
|
141
|
+
for (const child of automaticStyles.children) {
|
|
142
|
+
if (child.type !== "element" || child.tag !== "style:style" || (0, ooxml_js.attr)(child, "style:family") !== "table-row") continue;
|
|
143
|
+
const props = child.children.find((c) => c.type === "element" && c.tag === "style:table-row-properties");
|
|
144
|
+
if (props !== void 0 && xmlElementsEqual(props, properties)) {
|
|
145
|
+
const existingName = (0, ooxml_js.attr)(child, "style:name");
|
|
146
|
+
if (existingName !== void 0) return existingName;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const name = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", TABLE_ROW_STYLE_PREFIX);
|
|
150
|
+
automaticStyles.children.push(require_xml_fragment.el("style:style", {
|
|
151
|
+
"style:name": name,
|
|
152
|
+
"style:family": "table-row"
|
|
153
|
+
}, [properties]));
|
|
154
|
+
return name;
|
|
155
|
+
}
|
|
110
156
|
var OdtTableCell = class {
|
|
111
157
|
node;
|
|
112
158
|
pkg;
|
|
@@ -184,6 +230,24 @@ var OdtTableRow = class {
|
|
|
184
230
|
for (const child of this.node.children) if (child.type === "element" && child.tag === "table:table-cell") out.push(new OdtTableCell(child, this.pkg));
|
|
185
231
|
return out;
|
|
186
232
|
}
|
|
233
|
+
get heightPt() {
|
|
234
|
+
const props = currentRowPropertiesElement(this.pkg, this.node);
|
|
235
|
+
const raw = props === void 0 ? void 0 : (0, ooxml_js.attr)(props, "style:row-height");
|
|
236
|
+
return raw === void 0 ? void 0 : (0, odf_js.parseOdfLength)(raw);
|
|
237
|
+
}
|
|
238
|
+
set heightPt(value) {
|
|
239
|
+
const props = cloneCurrentRowProperties(this.pkg, this.node);
|
|
240
|
+
if (value === void 0) require_xml_edit.removeAttr(props, "style:row-height");
|
|
241
|
+
else {
|
|
242
|
+
require_xml_edit.setAttr(props, "style:row-height", (0, odf_js.formatOdfLength)(value, "pt"));
|
|
243
|
+
if ((0, ooxml_js.attr)(props, "style:use-optimal-row-height") === "true") require_xml_edit.setAttr(props, "style:use-optimal-row-height", "false");
|
|
244
|
+
}
|
|
245
|
+
if (props.attributes.length === 0 && props.children.length === 0) {
|
|
246
|
+
require_xml_edit.removeAttr(this.node, "table:style-name");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
require_xml_edit.setAttr(this.node, "table:style-name", internTableRowProperties(this.pkg, props));
|
|
250
|
+
}
|
|
187
251
|
appendCell() {
|
|
188
252
|
const cellElement = buildCell(this.pkg);
|
|
189
253
|
this.node.children.push(cellElement);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-
|
|
1
|
+
import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-COmzfIOe.cjs";
|
|
2
2
|
export { CellDecoration, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
|
package/dist/edit/odt/table.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-
|
|
1
|
+
import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-BmMyqRML.js";
|
|
2
2
|
export { CellDecoration, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
|
package/dist/edit/odt/table.js
CHANGED
|
@@ -3,11 +3,12 @@ import { removeAttr, removeChild, setAttr } from "../../xml/edit.js";
|
|
|
3
3
|
import { ensureAutomaticStyles, nextStyleName } from "./automatic-styles.js";
|
|
4
4
|
import { OdtParagraph, buildParagraph } from "./paragraph.js";
|
|
5
5
|
import { attr } from "ooxml.js";
|
|
6
|
-
import { formatOdfColor, formatOdfLength, parseOdfColor, parseOdfLength } from "odf.js";
|
|
6
|
+
import { findStyleElement, formatOdfColor, formatOdfLength, parseOdfColor, parseOdfLength } from "odf.js";
|
|
7
7
|
//#region src/edit/odt/table.ts
|
|
8
8
|
const DEFAULT_TABLE_WIDTH_PT = 468;
|
|
9
9
|
const TABLE_COLUMN_STYLE_PREFIX = "OdtCol";
|
|
10
10
|
const TABLE_CELL_STYLE_PREFIX = "OdtCell";
|
|
11
|
+
const TABLE_ROW_STYLE_PREFIX = "OdtRow";
|
|
11
12
|
const BORDER_EDGE_ATTRS = {
|
|
12
13
|
top: "fo:border-top",
|
|
13
14
|
right: "fo:border-right",
|
|
@@ -106,6 +107,51 @@ function internTableColumnWidth(pkg, widthPt) {
|
|
|
106
107
|
}, [el("style:table-column-properties", { "style:column-width": formatted })]));
|
|
107
108
|
return name;
|
|
108
109
|
}
|
|
110
|
+
function currentRowPropertiesElement(pkg, rowElement) {
|
|
111
|
+
const styleName = attr(rowElement, "table:style-name");
|
|
112
|
+
const styleElement = styleName === void 0 ? void 0 : findStyleElement(styleName, "table-row", pkg);
|
|
113
|
+
return styleElement === void 0 ? void 0 : styleElement.children.find((c) => c.type === "element" && c.tag === "style:table-row-properties");
|
|
114
|
+
}
|
|
115
|
+
function cloneCurrentRowProperties(pkg, rowElement) {
|
|
116
|
+
const props = currentRowPropertiesElement(pkg, rowElement);
|
|
117
|
+
return props === void 0 ? el("style:table-row-properties") : structuredClone(props);
|
|
118
|
+
}
|
|
119
|
+
function xmlNodesEqual(a, b) {
|
|
120
|
+
if (a.type === "element" && b.type === "element") return xmlElementsEqual(a, b);
|
|
121
|
+
if (a.type === "text" && b.type === "text") return a.value === b.value;
|
|
122
|
+
if (a.type === "cdata" && b.type === "cdata") return a.value === b.value;
|
|
123
|
+
if (a.type === "comment" && b.type === "comment") return a.value === b.value;
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
function xmlElementsEqual(a, b) {
|
|
127
|
+
if (a.tag !== b.tag || a.attributes.length !== b.attributes.length) return false;
|
|
128
|
+
if (!a.attributes.every((candidate) => attr(b, candidate.name) === candidate.value)) return false;
|
|
129
|
+
if (a.children.length !== b.children.length) return false;
|
|
130
|
+
for (let index = 0; index < a.children.length; index++) {
|
|
131
|
+
const childA = a.children[index];
|
|
132
|
+
const childB = b.children[index];
|
|
133
|
+
if (childA === void 0 || childB === void 0) return false;
|
|
134
|
+
if (!xmlNodesEqual(childA, childB)) return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
function internTableRowProperties(pkg, properties) {
|
|
139
|
+
const automaticStyles = ensureAutomaticStyles(pkg);
|
|
140
|
+
for (const child of automaticStyles.children) {
|
|
141
|
+
if (child.type !== "element" || child.tag !== "style:style" || attr(child, "style:family") !== "table-row") continue;
|
|
142
|
+
const props = child.children.find((c) => c.type === "element" && c.tag === "style:table-row-properties");
|
|
143
|
+
if (props !== void 0 && xmlElementsEqual(props, properties)) {
|
|
144
|
+
const existingName = attr(child, "style:name");
|
|
145
|
+
if (existingName !== void 0) return existingName;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const name = nextStyleName(automaticStyles, "style:style", TABLE_ROW_STYLE_PREFIX);
|
|
149
|
+
automaticStyles.children.push(el("style:style", {
|
|
150
|
+
"style:name": name,
|
|
151
|
+
"style:family": "table-row"
|
|
152
|
+
}, [properties]));
|
|
153
|
+
return name;
|
|
154
|
+
}
|
|
109
155
|
var OdtTableCell = class {
|
|
110
156
|
node;
|
|
111
157
|
pkg;
|
|
@@ -183,6 +229,24 @@ var OdtTableRow = class {
|
|
|
183
229
|
for (const child of this.node.children) if (child.type === "element" && child.tag === "table:table-cell") out.push(new OdtTableCell(child, this.pkg));
|
|
184
230
|
return out;
|
|
185
231
|
}
|
|
232
|
+
get heightPt() {
|
|
233
|
+
const props = currentRowPropertiesElement(this.pkg, this.node);
|
|
234
|
+
const raw = props === void 0 ? void 0 : attr(props, "style:row-height");
|
|
235
|
+
return raw === void 0 ? void 0 : parseOdfLength(raw);
|
|
236
|
+
}
|
|
237
|
+
set heightPt(value) {
|
|
238
|
+
const props = cloneCurrentRowProperties(this.pkg, this.node);
|
|
239
|
+
if (value === void 0) removeAttr(props, "style:row-height");
|
|
240
|
+
else {
|
|
241
|
+
setAttr(props, "style:row-height", formatOdfLength(value, "pt"));
|
|
242
|
+
if (attr(props, "style:use-optimal-row-height") === "true") setAttr(props, "style:use-optimal-row-height", "false");
|
|
243
|
+
}
|
|
244
|
+
if (props.attributes.length === 0 && props.children.length === 0) {
|
|
245
|
+
removeAttr(this.node, "table:style-name");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
setAttr(this.node, "table:style-name", internTableRowProperties(this.pkg, props));
|
|
249
|
+
}
|
|
186
250
|
appendCell() {
|
|
187
251
|
const cellElement = buildCell(this.pkg);
|
|
188
252
|
this.node.children.push(cellElement);
|
|
@@ -6,6 +6,7 @@ const require_model_formula = require("../../model/formula.cjs");
|
|
|
6
6
|
const require_edit_pptx_scaffold = require("./scaffold.cjs");
|
|
7
7
|
const require_edit_pptx_editor = require("./editor.cjs");
|
|
8
8
|
let ooxml_js = require("ooxml.js");
|
|
9
|
+
let document_schema_js = require("document-schema.js");
|
|
9
10
|
//#region src/edit/pptx/content.ts
|
|
10
11
|
function buildPptxPackage(content, options) {
|
|
11
12
|
if (content.kind !== "presentation") throw new Error("buildPptxPackage requires a presentation ContentDocument");
|
|
@@ -140,7 +141,7 @@ function populatePptxTable(table, block, resolveHyperlinkRId) {
|
|
|
140
141
|
tableCell.rowSpan = cell.rowSpan;
|
|
141
142
|
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
142
143
|
}
|
|
143
|
-
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
144
|
+
if (cell.background !== void 0) tableCell.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
144
145
|
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
145
146
|
populateCellParagraphs(tableCell, cell.blocks, resolveHyperlinkRId);
|
|
146
147
|
});
|
|
@@ -5,6 +5,7 @@ import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
|
5
5
|
import { createEmptyPptxPackage } from "./scaffold.js";
|
|
6
6
|
import { PptxEditor } from "./editor.js";
|
|
7
7
|
import { base64ToBytes, encodePackage } from "ooxml.js";
|
|
8
|
+
import { resolveCellFillColor } from "document-schema.js";
|
|
8
9
|
//#region src/edit/pptx/content.ts
|
|
9
10
|
function buildPptxPackage(content, options) {
|
|
10
11
|
if (content.kind !== "presentation") throw new Error("buildPptxPackage requires a presentation ContentDocument");
|
|
@@ -139,7 +140,7 @@ function populatePptxTable(table, block, resolveHyperlinkRId) {
|
|
|
139
140
|
tableCell.rowSpan = cell.rowSpan;
|
|
140
141
|
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
141
142
|
}
|
|
142
|
-
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
143
|
+
if (cell.background !== void 0) tableCell.background = resolveCellFillColor(cell.background);
|
|
143
144
|
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
144
145
|
populateCellParagraphs(tableCell, cell.blocks, resolveHyperlinkRId);
|
|
145
146
|
});
|
package/dist/edit/pptx/table.cjs
CHANGED
|
@@ -112,13 +112,15 @@ var PptxTableCell = class {
|
|
|
112
112
|
if (lnElement === void 0) return;
|
|
113
113
|
const w = (0, ooxml_js.attr)(lnElement, "w");
|
|
114
114
|
if (w === void 0) return;
|
|
115
|
+
const widthPt = require_model_units.emuToPt(Number(w));
|
|
116
|
+
if (!Number.isFinite(widthPt) || widthPt <= 0) return;
|
|
115
117
|
const solidFill = require_xml_edit.directChildElement(lnElement, "a:solidFill");
|
|
116
118
|
const srgbClr = solidFill === void 0 ? void 0 : require_xml_edit.directChildElement(solidFill, "a:srgbClr");
|
|
117
119
|
const hex = srgbClr === void 0 ? void 0 : (0, ooxml_js.attr)(srgbClr, "val");
|
|
118
120
|
if (hex === void 0) return;
|
|
119
121
|
return {
|
|
120
122
|
color: (0, document_schema_js.rgbHexToColor)(hex),
|
|
121
|
-
widthPt
|
|
123
|
+
widthPt
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
setParagraphs(paragraphs) {
|
package/dist/edit/pptx/table.js
CHANGED
|
@@ -111,13 +111,15 @@ var PptxTableCell = class {
|
|
|
111
111
|
if (lnElement === void 0) return;
|
|
112
112
|
const w = attr(lnElement, "w");
|
|
113
113
|
if (w === void 0) return;
|
|
114
|
+
const widthPt = emuToPt(Number(w));
|
|
115
|
+
if (!Number.isFinite(widthPt) || widthPt <= 0) return;
|
|
114
116
|
const solidFill = directChildElement(lnElement, "a:solidFill");
|
|
115
117
|
const srgbClr = solidFill === void 0 ? void 0 : directChildElement(solidFill, "a:srgbClr");
|
|
116
118
|
const hex = srgbClr === void 0 ? void 0 : attr(srgbClr, "val");
|
|
117
119
|
if (hex === void 0) return;
|
|
118
120
|
return {
|
|
119
121
|
color: rgbHexToColor(hex),
|
|
120
|
-
widthPt
|
|
122
|
+
widthPt
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
setParagraphs(paragraphs) {
|
package/dist/index.cjs
CHANGED
|
@@ -670,6 +670,7 @@ Object.defineProperty(exports, "childrenWithTag", {
|
|
|
670
670
|
return ooxml_js.childrenWithTag;
|
|
671
671
|
}
|
|
672
672
|
});
|
|
673
|
+
exports.collectDocumentFormulas = require_model_formula.collectDocumentFormulas;
|
|
673
674
|
exports.collectOfficeMathElements = require_omml_read.collectOfficeMathElements;
|
|
674
675
|
Object.defineProperty(exports, "columnIndexToLetters", {
|
|
675
676
|
enumerable: true,
|
|
@@ -963,6 +964,7 @@ Object.defineProperty(exports, "parseXml", {
|
|
|
963
964
|
return ooxml_js.parseXml;
|
|
964
965
|
}
|
|
965
966
|
});
|
|
967
|
+
exports.patchDocxMetadata = require_metadata_write.patchDocxMetadata;
|
|
966
968
|
Object.defineProperty(exports, "pdfCodec", {
|
|
967
969
|
enumerable: true,
|
|
968
970
|
get: function() {
|