js.documents 14.2.0 → 14.3.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/dist/diagnostics-C2-C2uUI.d.cts +17 -0
- package/dist/diagnostics-C2-C2uUI.d.ts +17 -0
- package/dist/edit/docx/content.cjs +13 -2
- package/dist/edit/docx/content.d.cts +2 -0
- package/dist/edit/docx/content.d.ts +2 -0
- package/dist/edit/docx/content.js +13 -2
- package/dist/edit/docx/diagnostics.cjs +7 -0
- package/dist/edit/docx/diagnostics.d.cts +2 -0
- package/dist/edit/docx/diagnostics.d.ts +2 -0
- package/dist/edit/docx/diagnostics.js +5 -0
- package/dist/edit/pptx/content.cjs +2 -1
- package/dist/edit/pptx/content.js +2 -1
- package/dist/edit/pptx/slide.d.cts +1 -1
- package/dist/edit/pptx/slide.d.ts +1 -1
- package/dist/edit/pptx/table.cjs +29 -3
- package/dist/edit/pptx/table.d.cts +1 -1
- package/dist/edit/pptx/table.d.ts +1 -1
- package/dist/edit/pptx/table.js +29 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{table-BuNLtwgL.d.ts → table-B1uKqI0r.d.ts} +2 -0
- package/dist/{table-ukpjK2hS.d.cts → table-CxLN4l90.d.cts} +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/edit/docx/diagnostics.d.ts
|
|
2
|
+
type DocxWriteDiagnosticSeverity = "info" | "warning";
|
|
3
|
+
declare const DocxWriteDiagnosticCodes: {
|
|
4
|
+
readonly TABLE_HEADER_COLUMN_DROPPED: "docx-write/table-header-column-dropped";
|
|
5
|
+
};
|
|
6
|
+
type DocxWriteDiagnosticCode = (typeof DocxWriteDiagnosticCodes)[keyof typeof DocxWriteDiagnosticCodes];
|
|
7
|
+
interface DocxWriteDiagnostic {
|
|
8
|
+
readonly code: DocxWriteDiagnosticCode;
|
|
9
|
+
readonly severity: DocxWriteDiagnosticSeverity;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
12
|
+
type DocxWriteDiagnosticSink = (diagnostic: DocxWriteDiagnostic, context: {
|
|
13
|
+
readonly sourcePath?: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
declare const NOOP_DOCX_WRITE_DIAGNOSTIC_SINK: DocxWriteDiagnosticSink;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DocxWriteDiagnosticSink as a, DocxWriteDiagnosticSeverity as i, DocxWriteDiagnosticCode as n, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK as o, DocxWriteDiagnosticCodes as r, DocxWriteDiagnostic as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/edit/docx/diagnostics.d.ts
|
|
2
|
+
type DocxWriteDiagnosticSeverity = "info" | "warning";
|
|
3
|
+
declare const DocxWriteDiagnosticCodes: {
|
|
4
|
+
readonly TABLE_HEADER_COLUMN_DROPPED: "docx-write/table-header-column-dropped";
|
|
5
|
+
};
|
|
6
|
+
type DocxWriteDiagnosticCode = (typeof DocxWriteDiagnosticCodes)[keyof typeof DocxWriteDiagnosticCodes];
|
|
7
|
+
interface DocxWriteDiagnostic {
|
|
8
|
+
readonly code: DocxWriteDiagnosticCode;
|
|
9
|
+
readonly severity: DocxWriteDiagnosticSeverity;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
12
|
+
type DocxWriteDiagnosticSink = (diagnostic: DocxWriteDiagnostic, context: {
|
|
13
|
+
readonly sourcePath?: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
declare const NOOP_DOCX_WRITE_DIAGNOSTIC_SINK: DocxWriteDiagnosticSink;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DocxWriteDiagnosticSink as a, DocxWriteDiagnosticSeverity as i, DocxWriteDiagnosticCode as n, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK as o, DocxWriteDiagnosticCodes as r, DocxWriteDiagnostic as t };
|
|
@@ -10,6 +10,7 @@ const require_edit_table_grid = require("../table-grid.cjs");
|
|
|
10
10
|
const require_edit_docx_editor = require("./editor.cjs");
|
|
11
11
|
const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs");
|
|
12
12
|
const require_model_formula = require("../../model/formula.cjs");
|
|
13
|
+
const require_edit_docx_diagnostics = require("./diagnostics.cjs");
|
|
13
14
|
const require_edit_docx_numbering = require("./numbering.cjs");
|
|
14
15
|
let ooxml_js = require("ooxml.js");
|
|
15
16
|
let document_schema_js = require("document-schema.js");
|
|
@@ -208,8 +209,18 @@ function docxRowCells(positions, positionsByRow) {
|
|
|
208
209
|
return [];
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
|
-
function
|
|
212
|
+
function reportDroppedHeaderColumns(block, onDiagnostic) {
|
|
213
|
+
block.columns.forEach((column, columnIndex) => {
|
|
214
|
+
if (column.isHeader === true) onDiagnostic({
|
|
215
|
+
code: require_edit_docx_diagnostics.DocxWriteDiagnosticCodes.TABLE_HEADER_COLUMN_DROPPED,
|
|
216
|
+
severity: "warning",
|
|
217
|
+
message: `buildDocxPackage: table column ${String(columnIndex)} is a header column, and that is dropped; w:tblGrid has no header-column marker, so the column is written exactly as any other`
|
|
218
|
+
}, { sourcePath: block.sourcePath });
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function appendTable(body, block, options) {
|
|
212
222
|
require_edit_table_grid.assertTableObeysGridRule(block, "buildDocxPackage");
|
|
223
|
+
reportDroppedHeaderColumns(block, options?.onDiagnostic ?? require_edit_docx_diagnostics.NOOP_DOCX_WRITE_DIAGNOSTIC_SINK);
|
|
213
224
|
if (block.rows.length === 0) throw new Error("buildDocxPackage: table has no rows, and a table with no rows cannot be written in every word-processing format (ODF requires at least one table:table-row)");
|
|
214
225
|
const table = body.appendTable({
|
|
215
226
|
rows: 0,
|
|
@@ -250,7 +261,7 @@ function appendBlock(body, block, options, markers) {
|
|
|
250
261
|
altText: block.altText
|
|
251
262
|
});
|
|
252
263
|
} else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
253
|
-
else if (block.kind === "table") appendTable(body, block);
|
|
264
|
+
else if (block.kind === "table") appendTable(body, block, options);
|
|
254
265
|
else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
|
|
255
266
|
else if (block.kind === "constructStart") markers.openConstruct(body, block);
|
|
256
267
|
else markers.closeConstruct(body);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
|
|
2
2
|
import { t as OmmlDiagnostic } from "../../shared-c0Lp3_iY.cjs";
|
|
3
|
+
import { a as DocxWriteDiagnosticSink } from "../../diagnostics-C2-C2uUI.cjs";
|
|
3
4
|
import { ContentDocument } from "document-schema.js";
|
|
4
5
|
import { Package } from "ooxml.js";
|
|
5
6
|
//#region src/edit/docx/content.d.ts
|
|
@@ -8,6 +9,7 @@ interface BuildDocxPackageOptions {
|
|
|
8
9
|
readonly sourcePath?: string;
|
|
9
10
|
}) => void;
|
|
10
11
|
readonly clock?: ClockPort;
|
|
12
|
+
readonly onDiagnostic?: DocxWriteDiagnosticSink;
|
|
11
13
|
}
|
|
12
14
|
declare function buildDocxPackage(content: ContentDocument, options?: BuildDocxPackageOptions): Package;
|
|
13
15
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.js";
|
|
2
2
|
import { t as OmmlDiagnostic } from "../../shared-DHu5jDJf.js";
|
|
3
|
+
import { a as DocxWriteDiagnosticSink } from "../../diagnostics-C2-C2uUI.js";
|
|
3
4
|
import { Package } from "ooxml.js";
|
|
4
5
|
import { ContentDocument } from "document-schema.js";
|
|
5
6
|
//#region src/edit/docx/content.d.ts
|
|
@@ -8,6 +9,7 @@ interface BuildDocxPackageOptions {
|
|
|
8
9
|
readonly sourcePath?: string;
|
|
9
10
|
}) => void;
|
|
10
11
|
readonly clock?: ClockPort;
|
|
12
|
+
readonly onDiagnostic?: DocxWriteDiagnosticSink;
|
|
11
13
|
}
|
|
12
14
|
declare function buildDocxPackage(content: ContentDocument, options?: BuildDocxPackageOptions): Package;
|
|
13
15
|
//#endregion
|
|
@@ -9,6 +9,7 @@ import { assertTableObeysGridRule } from "../table-grid.js";
|
|
|
9
9
|
import { DocxEditor } from "./editor.js";
|
|
10
10
|
import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from "../../model/embedded-drawing.js";
|
|
11
11
|
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
12
|
+
import { DocxWriteDiagnosticCodes, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK } from "./diagnostics.js";
|
|
12
13
|
import { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingRoot, declaration } from "./numbering.js";
|
|
13
14
|
import { base64ToBytes } from "ooxml.js";
|
|
14
15
|
import { resolveCellFillColor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "document-schema.js";
|
|
@@ -207,8 +208,18 @@ function docxRowCells(positions, positionsByRow) {
|
|
|
207
208
|
return [];
|
|
208
209
|
});
|
|
209
210
|
}
|
|
210
|
-
function
|
|
211
|
+
function reportDroppedHeaderColumns(block, onDiagnostic) {
|
|
212
|
+
block.columns.forEach((column, columnIndex) => {
|
|
213
|
+
if (column.isHeader === true) onDiagnostic({
|
|
214
|
+
code: DocxWriteDiagnosticCodes.TABLE_HEADER_COLUMN_DROPPED,
|
|
215
|
+
severity: "warning",
|
|
216
|
+
message: `buildDocxPackage: table column ${String(columnIndex)} is a header column, and that is dropped; w:tblGrid has no header-column marker, so the column is written exactly as any other`
|
|
217
|
+
}, { sourcePath: block.sourcePath });
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function appendTable(body, block, options) {
|
|
211
221
|
assertTableObeysGridRule(block, "buildDocxPackage");
|
|
222
|
+
reportDroppedHeaderColumns(block, options?.onDiagnostic ?? NOOP_DOCX_WRITE_DIAGNOSTIC_SINK);
|
|
212
223
|
if (block.rows.length === 0) throw new Error("buildDocxPackage: table has no rows, and a table with no rows cannot be written in every word-processing format (ODF requires at least one table:table-row)");
|
|
213
224
|
const table = body.appendTable({
|
|
214
225
|
rows: 0,
|
|
@@ -249,7 +260,7 @@ function appendBlock(body, block, options, markers) {
|
|
|
249
260
|
altText: block.altText
|
|
250
261
|
});
|
|
251
262
|
} else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
252
|
-
else if (block.kind === "table") appendTable(body, block);
|
|
263
|
+
else if (block.kind === "table") appendTable(body, block, options);
|
|
253
264
|
else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
|
|
254
265
|
else if (block.kind === "constructStart") markers.openConstruct(body, block);
|
|
255
266
|
else markers.closeConstruct(body);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/edit/docx/diagnostics.ts
|
|
3
|
+
const DocxWriteDiagnosticCodes = { TABLE_HEADER_COLUMN_DROPPED: "docx-write/table-header-column-dropped" };
|
|
4
|
+
const NOOP_DOCX_WRITE_DIAGNOSTIC_SINK = () => {};
|
|
5
|
+
//#endregion
|
|
6
|
+
exports.DocxWriteDiagnosticCodes = DocxWriteDiagnosticCodes;
|
|
7
|
+
exports.NOOP_DOCX_WRITE_DIAGNOSTIC_SINK = NOOP_DOCX_WRITE_DIAGNOSTIC_SINK;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DocxWriteDiagnosticSink, i as DocxWriteDiagnosticSeverity, n as DocxWriteDiagnosticCode, o as NOOP_DOCX_WRITE_DIAGNOSTIC_SINK, r as DocxWriteDiagnosticCodes, t as DocxWriteDiagnostic } from "../../diagnostics-C2-C2uUI.cjs";
|
|
2
|
+
export { DocxWriteDiagnostic, DocxWriteDiagnosticCode, DocxWriteDiagnosticCodes, DocxWriteDiagnosticSeverity, DocxWriteDiagnosticSink, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DocxWriteDiagnosticSink, i as DocxWriteDiagnosticSeverity, n as DocxWriteDiagnosticCode, o as NOOP_DOCX_WRITE_DIAGNOSTIC_SINK, r as DocxWriteDiagnosticCodes, t as DocxWriteDiagnostic } from "../../diagnostics-C2-C2uUI.js";
|
|
2
|
+
export { DocxWriteDiagnostic, DocxWriteDiagnosticCode, DocxWriteDiagnosticCodes, DocxWriteDiagnosticSeverity, DocxWriteDiagnosticSink, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/edit/docx/diagnostics.ts
|
|
2
|
+
const DocxWriteDiagnosticCodes = { TABLE_HEADER_COLUMN_DROPPED: "docx-write/table-header-column-dropped" };
|
|
3
|
+
const NOOP_DOCX_WRITE_DIAGNOSTIC_SINK = () => {};
|
|
4
|
+
//#endregion
|
|
5
|
+
export { DocxWriteDiagnosticCodes, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK };
|
|
@@ -64,7 +64,8 @@ function appendShape(slide, shape, options) {
|
|
|
64
64
|
table: {
|
|
65
65
|
rows: onlyBlock.rows.length,
|
|
66
66
|
columns: (0, document_schema_js.tableGridColumnCount)(onlyBlock),
|
|
67
|
-
columnWidthsPt: onlyBlock.columns.map((c) => c.widthPt)
|
|
67
|
+
columnWidthsPt: onlyBlock.columns.map((c) => c.widthPt),
|
|
68
|
+
rowHeightsPt: onlyBlock.rows.map((r) => r.heightPt)
|
|
68
69
|
}
|
|
69
70
|
}), onlyBlock, options?.onDiagnostic ?? require_edit_pptx_diagnostics.NOOP_PPTX_WRITE_DIAGNOSTIC_SINK, (url) => slide.registerHyperlink(url));
|
|
70
71
|
return;
|
|
@@ -63,7 +63,8 @@ function appendShape(slide, shape, options) {
|
|
|
63
63
|
table: {
|
|
64
64
|
rows: onlyBlock.rows.length,
|
|
65
65
|
columns: tableGridColumnCount(onlyBlock),
|
|
66
|
-
columnWidthsPt: onlyBlock.columns.map((c) => c.widthPt)
|
|
66
|
+
columnWidthsPt: onlyBlock.columns.map((c) => c.widthPt),
|
|
67
|
+
rowHeightsPt: onlyBlock.rows.map((r) => r.heightPt)
|
|
67
68
|
}
|
|
68
69
|
}), onlyBlock, options?.onDiagnostic ?? NOOP_PPTX_WRITE_DIAGNOSTIC_SINK, (url) => slide.registerHyperlink(url));
|
|
69
70
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-C3L2cCLQ.cjs";
|
|
2
2
|
import { r as PptxShape } from "../../shape-C2ef6uwC.cjs";
|
|
3
|
-
import { r as PptxTableInit, t as PptxTable } from "../../table-
|
|
3
|
+
import { r as PptxTableInit, t as PptxTable } from "../../table-CxLN4l90.cjs";
|
|
4
4
|
import { Box, ContentVector } from "document-schema.js";
|
|
5
5
|
import { Package, XmlElement, XmlNode } from "ooxml.js";
|
|
6
6
|
//#region src/edit/pptx/slide.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-CAeD6ZbR.js";
|
|
2
2
|
import { r as PptxShape } from "../../shape-DwZouh8R.js";
|
|
3
|
-
import { r as PptxTableInit, t as PptxTable } from "../../table-
|
|
3
|
+
import { r as PptxTableInit, t as PptxTable } from "../../table-B1uKqI0r.js";
|
|
4
4
|
import { Package, XmlElement, XmlNode } from "ooxml.js";
|
|
5
5
|
import { Box, ContentVector } from "document-schema.js";
|
|
6
6
|
//#region src/edit/pptx/slide.d.ts
|
package/dist/edit/pptx/table.cjs
CHANGED
|
@@ -15,6 +15,17 @@ const PPTX_TABLE_CELL_VERTICAL_ALIGN_ANCHOR = {
|
|
|
15
15
|
center: "ctr",
|
|
16
16
|
bottom: "b"
|
|
17
17
|
};
|
|
18
|
+
const PPTX_BORDER_STYLE_TO_DASH_VAL = {
|
|
19
|
+
solid: "solid",
|
|
20
|
+
dashed: "dash",
|
|
21
|
+
dotted: "sysDot"
|
|
22
|
+
};
|
|
23
|
+
const DASH_VAL_TO_PPTX_BORDER_STYLE = /* @__PURE__ */ new Map([
|
|
24
|
+
["solid", "solid"],
|
|
25
|
+
["dash", "dashed"],
|
|
26
|
+
["sysDot", "dotted"]
|
|
27
|
+
]);
|
|
28
|
+
const PPTX_BORDER_CMPD_DOUBLE = "dbl";
|
|
18
29
|
const ANCHOR_TABLE_CELL_VERTICAL_ALIGN = /* @__PURE__ */ new Map([
|
|
19
30
|
["t", "top"],
|
|
20
31
|
["ctr", "center"],
|
|
@@ -115,7 +126,12 @@ var PptxTableCell = class {
|
|
|
115
126
|
]) {
|
|
116
127
|
const border = value[key];
|
|
117
128
|
if (border === void 0) continue;
|
|
118
|
-
|
|
129
|
+
const lineChildren = [require_xml_fragment.el("a:solidFill", {}, [require_xml_fragment.el("a:srgbClr", { val: require_edit_drawingml_vector.drawingMlColorHex(border.color) })])];
|
|
130
|
+
const dashVal = border.style === void 0 ? void 0 : PPTX_BORDER_STYLE_TO_DASH_VAL[border.style];
|
|
131
|
+
if (dashVal !== void 0) lineChildren.push(require_xml_fragment.el("a:prstDash", { val: dashVal }));
|
|
132
|
+
const lineAttrs = { w: String(require_model_units.ptToEmu(border.widthPt)) };
|
|
133
|
+
if (border.style === "double") lineAttrs.cmpd = PPTX_BORDER_CMPD_DOUBLE;
|
|
134
|
+
tcPr.children.push(require_xml_fragment.el(tag, lineAttrs, lineChildren));
|
|
119
135
|
}
|
|
120
136
|
}
|
|
121
137
|
get verticalAlign() {
|
|
@@ -143,11 +159,20 @@ var PptxTableCell = class {
|
|
|
143
159
|
const srgbClr = solidFill === void 0 ? void 0 : require_xml_edit.directChildElement(solidFill, "a:srgbClr");
|
|
144
160
|
const hex = srgbClr === void 0 ? void 0 : (0, ooxml_js.attr)(srgbClr, "val");
|
|
145
161
|
if (hex === void 0) return;
|
|
162
|
+
const style = this.readBorderStyle(lnElement);
|
|
146
163
|
return {
|
|
147
164
|
color: (0, document_schema_js.rgbHexToColor)(hex),
|
|
148
|
-
widthPt
|
|
165
|
+
widthPt,
|
|
166
|
+
...style === void 0 ? {} : { style }
|
|
149
167
|
};
|
|
150
168
|
}
|
|
169
|
+
readBorderStyle(lnElement) {
|
|
170
|
+
if ((0, ooxml_js.attr)(lnElement, "cmpd") === PPTX_BORDER_CMPD_DOUBLE) return "double";
|
|
171
|
+
const prstDash = require_xml_edit.directChildElement(lnElement, "a:prstDash");
|
|
172
|
+
const dashVal = prstDash === void 0 ? void 0 : (0, ooxml_js.attr)(prstDash, "val");
|
|
173
|
+
if (dashVal === void 0) return;
|
|
174
|
+
return DASH_VAL_TO_PPTX_BORDER_STYLE.get(dashVal) ?? "solid";
|
|
175
|
+
}
|
|
151
176
|
setParagraphs(paragraphs) {
|
|
152
177
|
const txBody = require_xml_edit.directChildElement(this.node, "a:txBody");
|
|
153
178
|
if (txBody === void 0) return;
|
|
@@ -204,7 +229,8 @@ function buildDrawingTable(init) {
|
|
|
204
229
|
for (let r = 0; r < init.rows; r++) {
|
|
205
230
|
const cells = [];
|
|
206
231
|
for (let c = 0; c < init.columns; c++) cells.push(buildTableCellElement());
|
|
207
|
-
|
|
232
|
+
const heightPt = init.rowHeightsPt?.[r] ?? DEFAULT_ROW_HEIGHT_PT;
|
|
233
|
+
rows.push(require_xml_fragment.el("a:tr", { h: String(require_model_units.ptToEmu(heightPt)) }, cells));
|
|
208
234
|
}
|
|
209
235
|
return require_xml_fragment.el("a:tbl", {}, [
|
|
210
236
|
require_xml_fragment.el("a:tblPr"),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-
|
|
1
|
+
import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-CxLN4l90.cjs";
|
|
2
2
|
export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-
|
|
1
|
+
import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-B1uKqI0r.js";
|
|
2
2
|
export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable };
|
package/dist/edit/pptx/table.js
CHANGED
|
@@ -14,6 +14,17 @@ const PPTX_TABLE_CELL_VERTICAL_ALIGN_ANCHOR = {
|
|
|
14
14
|
center: "ctr",
|
|
15
15
|
bottom: "b"
|
|
16
16
|
};
|
|
17
|
+
const PPTX_BORDER_STYLE_TO_DASH_VAL = {
|
|
18
|
+
solid: "solid",
|
|
19
|
+
dashed: "dash",
|
|
20
|
+
dotted: "sysDot"
|
|
21
|
+
};
|
|
22
|
+
const DASH_VAL_TO_PPTX_BORDER_STYLE = /* @__PURE__ */ new Map([
|
|
23
|
+
["solid", "solid"],
|
|
24
|
+
["dash", "dashed"],
|
|
25
|
+
["sysDot", "dotted"]
|
|
26
|
+
]);
|
|
27
|
+
const PPTX_BORDER_CMPD_DOUBLE = "dbl";
|
|
17
28
|
const ANCHOR_TABLE_CELL_VERTICAL_ALIGN = /* @__PURE__ */ new Map([
|
|
18
29
|
["t", "top"],
|
|
19
30
|
["ctr", "center"],
|
|
@@ -114,7 +125,12 @@ var PptxTableCell = class {
|
|
|
114
125
|
]) {
|
|
115
126
|
const border = value[key];
|
|
116
127
|
if (border === void 0) continue;
|
|
117
|
-
|
|
128
|
+
const lineChildren = [el("a:solidFill", {}, [el("a:srgbClr", { val: drawingMlColorHex(border.color) })])];
|
|
129
|
+
const dashVal = border.style === void 0 ? void 0 : PPTX_BORDER_STYLE_TO_DASH_VAL[border.style];
|
|
130
|
+
if (dashVal !== void 0) lineChildren.push(el("a:prstDash", { val: dashVal }));
|
|
131
|
+
const lineAttrs = { w: String(ptToEmu(border.widthPt)) };
|
|
132
|
+
if (border.style === "double") lineAttrs.cmpd = PPTX_BORDER_CMPD_DOUBLE;
|
|
133
|
+
tcPr.children.push(el(tag, lineAttrs, lineChildren));
|
|
118
134
|
}
|
|
119
135
|
}
|
|
120
136
|
get verticalAlign() {
|
|
@@ -142,11 +158,20 @@ var PptxTableCell = class {
|
|
|
142
158
|
const srgbClr = solidFill === void 0 ? void 0 : directChildElement(solidFill, "a:srgbClr");
|
|
143
159
|
const hex = srgbClr === void 0 ? void 0 : attr(srgbClr, "val");
|
|
144
160
|
if (hex === void 0) return;
|
|
161
|
+
const style = this.readBorderStyle(lnElement);
|
|
145
162
|
return {
|
|
146
163
|
color: rgbHexToColor(hex),
|
|
147
|
-
widthPt
|
|
164
|
+
widthPt,
|
|
165
|
+
...style === void 0 ? {} : { style }
|
|
148
166
|
};
|
|
149
167
|
}
|
|
168
|
+
readBorderStyle(lnElement) {
|
|
169
|
+
if (attr(lnElement, "cmpd") === PPTX_BORDER_CMPD_DOUBLE) return "double";
|
|
170
|
+
const prstDash = directChildElement(lnElement, "a:prstDash");
|
|
171
|
+
const dashVal = prstDash === void 0 ? void 0 : attr(prstDash, "val");
|
|
172
|
+
if (dashVal === void 0) return;
|
|
173
|
+
return DASH_VAL_TO_PPTX_BORDER_STYLE.get(dashVal) ?? "solid";
|
|
174
|
+
}
|
|
150
175
|
setParagraphs(paragraphs) {
|
|
151
176
|
const txBody = directChildElement(this.node, "a:txBody");
|
|
152
177
|
if (txBody === void 0) return;
|
|
@@ -203,7 +228,8 @@ function buildDrawingTable(init) {
|
|
|
203
228
|
for (let r = 0; r < init.rows; r++) {
|
|
204
229
|
const cells = [];
|
|
205
230
|
for (let c = 0; c < init.columns; c++) cells.push(buildTableCellElement());
|
|
206
|
-
|
|
231
|
+
const heightPt = init.rowHeightsPt?.[r] ?? DEFAULT_ROW_HEIGHT_PT;
|
|
232
|
+
rows.push(el("a:tr", { h: String(ptToEmu(heightPt)) }, cells));
|
|
207
233
|
}
|
|
208
234
|
return el("a:tbl", {}, [
|
|
209
235
|
el("a:tblPr"),
|
package/dist/index.d.cts
CHANGED
|
@@ -66,7 +66,7 @@ import { PptShape, PptSlide } from "./edit/ppt/slide.cjs";
|
|
|
66
66
|
import { CreatePptOptions, PptEditor, createPpt, openPpt } from "./edit/ppt/editor.cjs";
|
|
67
67
|
import { BuildPptxPackageOptions, buildPptxPackage, embeddedPresentationSerialiser } from "./edit/pptx/content.cjs";
|
|
68
68
|
import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-C2ef6uwC.cjs";
|
|
69
|
-
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-
|
|
69
|
+
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-CxLN4l90.cjs";
|
|
70
70
|
import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.cjs";
|
|
71
71
|
import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.cjs";
|
|
72
72
|
import { CreateEmptyPptxPackageOptions } from "./edit/pptx/scaffold.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ import { PptShape, PptSlide } from "./edit/ppt/slide.js";
|
|
|
66
66
|
import { CreatePptOptions, PptEditor, createPpt, openPpt } from "./edit/ppt/editor.js";
|
|
67
67
|
import { BuildPptxPackageOptions, buildPptxPackage, embeddedPresentationSerialiser } from "./edit/pptx/content.js";
|
|
68
68
|
import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-DwZouh8R.js";
|
|
69
|
-
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-
|
|
69
|
+
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-B1uKqI0r.js";
|
|
70
70
|
import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.js";
|
|
71
71
|
import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.js";
|
|
72
72
|
import { CreateEmptyPptxPackageOptions } from "./edit/pptx/scaffold.js";
|
|
@@ -6,6 +6,7 @@ interface PptxTableInit {
|
|
|
6
6
|
readonly rows: number;
|
|
7
7
|
readonly columns: number;
|
|
8
8
|
readonly columnWidthsPt?: readonly number[];
|
|
9
|
+
readonly rowHeightsPt?: readonly (number | undefined)[];
|
|
9
10
|
}
|
|
10
11
|
declare class PptxTableCell {
|
|
11
12
|
private readonly node;
|
|
@@ -25,6 +26,7 @@ declare class PptxTableCell {
|
|
|
25
26
|
get verticalAlign(): ContentTableCell["verticalAlign"];
|
|
26
27
|
set verticalAlign(value: ContentTableCell["verticalAlign"]);
|
|
27
28
|
private readBorder;
|
|
29
|
+
private readBorderStyle;
|
|
28
30
|
setParagraphs(paragraphs: readonly DrawingParagraphInit[]): void;
|
|
29
31
|
}
|
|
30
32
|
declare class PptxTableRow {
|
|
@@ -6,6 +6,7 @@ interface PptxTableInit {
|
|
|
6
6
|
readonly rows: number;
|
|
7
7
|
readonly columns: number;
|
|
8
8
|
readonly columnWidthsPt?: readonly number[];
|
|
9
|
+
readonly rowHeightsPt?: readonly (number | undefined)[];
|
|
9
10
|
}
|
|
10
11
|
declare class PptxTableCell {
|
|
11
12
|
private readonly node;
|
|
@@ -25,6 +26,7 @@ declare class PptxTableCell {
|
|
|
25
26
|
get verticalAlign(): ContentTableCell["verticalAlign"];
|
|
26
27
|
set verticalAlign(value: ContentTableCell["verticalAlign"]);
|
|
27
28
|
private readBorder;
|
|
29
|
+
private readBorderStyle;
|
|
28
30
|
setParagraphs(paragraphs: readonly DrawingParagraphInit[]): void;
|
|
29
31
|
}
|
|
30
32
|
declare class PptxTableRow {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.3.0",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -79,13 +79,13 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"archive-codec": "1.11.12",
|
|
81
81
|
"byte-codec": "1.8.1",
|
|
82
|
-
"doc-codec": "6.0
|
|
82
|
+
"doc-codec": "6.1.0",
|
|
83
83
|
"document-schema.js": "7.15.0",
|
|
84
84
|
"epub-codec": "5.1.0",
|
|
85
85
|
"fflate": "0.8.3",
|
|
86
86
|
"markdown-codec": "11.1.0",
|
|
87
87
|
"odf.js": "11.1.0",
|
|
88
|
-
"ooxml.js": "12.0
|
|
88
|
+
"ooxml.js": "12.1.0",
|
|
89
89
|
"pdf-codec": "5.2.6",
|
|
90
90
|
"ppt-codec": "2.2.0",
|
|
91
91
|
"rtf-codec": "8.1.0",
|