ooxml.js 2.7.0 → 2.8.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.
@@ -266,10 +266,18 @@ function readRawCell(tc, context, rels, pkg) {
266
266
  blocks: readBodyBlocks(tc.children, context, rels, pkg)
267
267
  };
268
268
  }
269
+ function readRowHeightPt(tr) {
270
+ const trPr = require_typed_util.childrenWithTag(tr, "w:trPr")[0];
271
+ if (trPr === void 0) return;
272
+ const trHeight = require_typed_util.childrenWithTag(trPr, "w:trHeight")[0];
273
+ const val = trHeight === void 0 ? void 0 : require_typed_util.attr(trHeight, "w:val");
274
+ return val === void 0 ? void 0 : require_typed_shared_units.twipsToPt(Number(val));
275
+ }
269
276
  function readTable(tbl, context, rels, pkg) {
270
277
  const tblGrid = require_typed_util.childrenWithTag(tbl, "w:tblGrid")[0];
271
278
  const columnWidthsPt = tblGrid === void 0 ? [] : require_typed_util.childrenWithTag(tblGrid, "w:gridCol").map((col) => require_typed_shared_units.twipsToPt(Number(require_typed_util.attr(col, "w:w") ?? "0")));
272
- const rawRows = require_typed_util.childrenWithTag(tbl, "w:tr").map((tr) => require_typed_util.childrenWithTag(tr, "w:tc").map((tc) => readRawCell(tc, context, rels, pkg)));
279
+ const trs = require_typed_util.childrenWithTag(tbl, "w:tr");
280
+ const rawRows = trs.map((tr) => require_typed_util.childrenWithTag(tr, "w:tc").map((tc) => readRawCell(tc, context, rels, pkg)));
273
281
  const rowColumnIndices = rawRows.map((row) => {
274
282
  const indices = [];
275
283
  let col = 0;
@@ -282,23 +290,26 @@ function readTable(tbl, context, rels, pkg) {
282
290
  return {
283
291
  kind: "table",
284
292
  columnWidthsPt,
285
- rows: rawRows.map((row, rowIndex) => ({ cells: row.map((cell, cellIndex) => {
286
- if (cell.isVMergeContinuation) return { blocks: [] };
287
- const colIndex = rowColumnIndices[rowIndex][cellIndex];
288
- let rowSpan = 1;
289
- for (let r = rowIndex + 1; r < rawRows.length; r++) {
290
- const matchIndex = rowColumnIndices[r].indexOf(colIndex);
291
- if (!(matchIndex === -1 ? void 0 : rawRows[r][matchIndex])?.isVMergeContinuation) break;
292
- rowSpan++;
293
- }
294
- return {
295
- blocks: cell.blocks,
296
- colSpan: cell.gridSpan > 1 ? cell.gridSpan : void 0,
297
- rowSpan: rowSpan > 1 ? rowSpan : void 0,
298
- background: cell.background,
299
- borders: cell.borders
300
- };
301
- }) }))
293
+ rows: rawRows.map((row, rowIndex) => ({
294
+ heightPt: readRowHeightPt(trs[rowIndex]),
295
+ cells: row.map((cell, cellIndex) => {
296
+ if (cell.isVMergeContinuation) return { blocks: [] };
297
+ const colIndex = rowColumnIndices[rowIndex][cellIndex];
298
+ let rowSpan = 1;
299
+ for (let r = rowIndex + 1; r < rawRows.length; r++) {
300
+ const matchIndex = rowColumnIndices[r].indexOf(colIndex);
301
+ if (!(matchIndex === -1 ? void 0 : rawRows[r][matchIndex])?.isVMergeContinuation) break;
302
+ rowSpan++;
303
+ }
304
+ return {
305
+ blocks: cell.blocks,
306
+ colSpan: cell.gridSpan > 1 ? cell.gridSpan : void 0,
307
+ rowSpan: rowSpan > 1 ? rowSpan : void 0,
308
+ background: cell.background,
309
+ borders: cell.borders
310
+ };
311
+ })
312
+ }))
302
313
  };
303
314
  }
304
315
  function readBodyBlocks(nodes, context, rels, pkg) {
@@ -265,10 +265,18 @@ function readRawCell(tc, context, rels, pkg) {
265
265
  blocks: readBodyBlocks(tc.children, context, rels, pkg)
266
266
  };
267
267
  }
268
+ function readRowHeightPt(tr) {
269
+ const trPr = childrenWithTag(tr, "w:trPr")[0];
270
+ if (trPr === void 0) return;
271
+ const trHeight = childrenWithTag(trPr, "w:trHeight")[0];
272
+ const val = trHeight === void 0 ? void 0 : attr(trHeight, "w:val");
273
+ return val === void 0 ? void 0 : twipsToPt(Number(val));
274
+ }
268
275
  function readTable(tbl, context, rels, pkg) {
269
276
  const tblGrid = childrenWithTag(tbl, "w:tblGrid")[0];
270
277
  const columnWidthsPt = tblGrid === void 0 ? [] : childrenWithTag(tblGrid, "w:gridCol").map((col) => twipsToPt(Number(attr(col, "w:w") ?? "0")));
271
- const rawRows = childrenWithTag(tbl, "w:tr").map((tr) => childrenWithTag(tr, "w:tc").map((tc) => readRawCell(tc, context, rels, pkg)));
278
+ const trs = childrenWithTag(tbl, "w:tr");
279
+ const rawRows = trs.map((tr) => childrenWithTag(tr, "w:tc").map((tc) => readRawCell(tc, context, rels, pkg)));
272
280
  const rowColumnIndices = rawRows.map((row) => {
273
281
  const indices = [];
274
282
  let col = 0;
@@ -281,23 +289,26 @@ function readTable(tbl, context, rels, pkg) {
281
289
  return {
282
290
  kind: "table",
283
291
  columnWidthsPt,
284
- rows: rawRows.map((row, rowIndex) => ({ cells: row.map((cell, cellIndex) => {
285
- if (cell.isVMergeContinuation) return { blocks: [] };
286
- const colIndex = rowColumnIndices[rowIndex][cellIndex];
287
- let rowSpan = 1;
288
- for (let r = rowIndex + 1; r < rawRows.length; r++) {
289
- const matchIndex = rowColumnIndices[r].indexOf(colIndex);
290
- if (!(matchIndex === -1 ? void 0 : rawRows[r][matchIndex])?.isVMergeContinuation) break;
291
- rowSpan++;
292
- }
293
- return {
294
- blocks: cell.blocks,
295
- colSpan: cell.gridSpan > 1 ? cell.gridSpan : void 0,
296
- rowSpan: rowSpan > 1 ? rowSpan : void 0,
297
- background: cell.background,
298
- borders: cell.borders
299
- };
300
- }) }))
292
+ rows: rawRows.map((row, rowIndex) => ({
293
+ heightPt: readRowHeightPt(trs[rowIndex]),
294
+ cells: row.map((cell, cellIndex) => {
295
+ if (cell.isVMergeContinuation) return { blocks: [] };
296
+ const colIndex = rowColumnIndices[rowIndex][cellIndex];
297
+ let rowSpan = 1;
298
+ for (let r = rowIndex + 1; r < rawRows.length; r++) {
299
+ const matchIndex = rowColumnIndices[r].indexOf(colIndex);
300
+ if (!(matchIndex === -1 ? void 0 : rawRows[r][matchIndex])?.isVMergeContinuation) break;
301
+ rowSpan++;
302
+ }
303
+ return {
304
+ blocks: cell.blocks,
305
+ colSpan: cell.gridSpan > 1 ? cell.gridSpan : void 0,
306
+ rowSpan: rowSpan > 1 ? rowSpan : void 0,
307
+ background: cell.background,
308
+ borders: cell.borders
309
+ };
310
+ })
311
+ }))
301
312
  };
302
313
  }
303
314
  function readBodyBlocks(nodes, context, rels, pkg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml.js",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Type-safe, lossless round-trip conversion between OOXML packages (docx, pptx, xlsx) and JSON, built on Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {