ooxml.js 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,16 +12,19 @@ graph TD
12
12
  ooxml("ooxml.js")
13
13
  odf("odf.js")
14
14
  pdfcodec("pdf-codec")
15
+ mdcodec("markdown-codec")
15
16
  documents("documents.js")
16
17
  cli("document-cli")
17
18
 
18
19
  schema --> ooxml
19
20
  schema --> odf
20
21
  schema --> pdfcodec
22
+ schema --> mdcodec
21
23
  schema --> documents
22
24
  ooxml --> documents
23
25
  odf --> documents
24
26
  pdfcodec --> documents
27
+ mdcodec --> documents
25
28
  documents --> cli
26
29
  odf --> cli
27
30
 
@@ -29,6 +32,7 @@ graph TD
29
32
  click ooxml "https://github.com/ExaDev/ooxml.js" "ooxml.js"
30
33
  click odf "https://github.com/ExaDev/odf.js" "odf.js"
31
34
  click pdfcodec "https://github.com/ExaDev/pdf-codec" "pdf-codec"
35
+ click mdcodec "https://github.com/ExaDev/markdown-codec" "markdown-codec"
32
36
  click documents "https://github.com/ExaDev/documents.js" "documents.js"
33
37
  click cli "https://github.com/ExaDev/document-cli" "document-cli"
34
38
 
@@ -32,6 +32,7 @@ declare const PptxDocumentSchema: z.ZodObject<{
32
32
  insetBottomPt: z.ZodNumber;
33
33
  fontScale: z.ZodOptional<z.ZodNumber>;
34
34
  lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
35
+ paintOrder: z.ZodOptional<z.ZodNumber>;
35
36
  sourcePath: z.ZodOptional<z.ZodString>;
36
37
  blocks: z.ZodArray<z.ZodCustom<ContentBlock, ContentBlock>>;
37
38
  }, z.core.$strip>>;
@@ -32,6 +32,7 @@ declare const PptxDocumentSchema: z.ZodObject<{
32
32
  insetBottomPt: z.ZodNumber;
33
33
  fontScale: z.ZodOptional<z.ZodNumber>;
34
34
  lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
35
+ paintOrder: z.ZodOptional<z.ZodNumber>;
35
36
  sourcePath: z.ZodOptional<z.ZodString>;
36
37
  blocks: z.ZodArray<z.ZodCustom<ContentBlock, ContentBlock>>;
37
38
  }, z.core.$strip>>;
@@ -260,10 +260,12 @@ function buildColsElement(columns) {
260
260
  return require_xml_fragment.el("cols", {}, columns.map((column) => {
261
261
  const attrs = {
262
262
  min: String(column.index + 1),
263
- max: String(column.index + 1),
264
- width: require_typed_xlsx_units.ptToColumnWidthChars(column.widthPt).toFixed(2),
265
- customWidth: "true"
263
+ max: String(column.index + 1)
266
264
  };
265
+ if (column.widthPt !== void 0) {
266
+ attrs.width = require_typed_xlsx_units.ptToColumnWidthChars(column.widthPt).toFixed(2);
267
+ attrs.customWidth = "true";
268
+ }
267
269
  if (column.hidden === true) attrs.hidden = "true";
268
270
  return require_xml_fragment.el("col", attrs);
269
271
  }));
@@ -287,7 +289,8 @@ function renderCellValue(value, isFormulaResult, sharedStrings) {
287
289
  content: value.value ? "1" : "0"
288
290
  };
289
291
  case "date":
290
- case "time": return {
292
+ case "time":
293
+ case "dateTime": return {
291
294
  type: "d",
292
295
  content: require_xml_entities.encodeXmlText(value.value)
293
296
  };
@@ -326,8 +329,10 @@ function buildSheetDataElement(sheet, sharedStrings) {
326
329
  const rowInfo = rowInfoByIndex.get(rowIndex);
327
330
  const attrs = { r: String(rowIndex + 1) };
328
331
  if (rowInfo !== void 0) {
329
- attrs.ht = String(rowInfo.heightPt);
330
- attrs.customHeight = "true";
332
+ if (rowInfo.heightPt !== void 0) {
333
+ attrs.ht = String(rowInfo.heightPt);
334
+ attrs.customHeight = "true";
335
+ }
331
336
  if (rowInfo.hidden === true) attrs.hidden = "true";
332
337
  }
333
338
  return require_xml_fragment.el("row", attrs, cells.map((cell) => buildCellElement(cell, sharedStrings)));
@@ -379,7 +384,7 @@ function buildPageSetupElement(settings) {
379
384
  attrs.paperWidth = require_typed_xlsx_util.ptToUniversalMeasure(settings.pageSize.widthPt);
380
385
  attrs.paperHeight = require_typed_xlsx_util.ptToUniversalMeasure(settings.pageSize.heightPt);
381
386
  }
382
- attrs.scale = String(settings.scale ?? 100);
387
+ attrs.scale = String(settings.scalePercent ?? 100);
383
388
  attrs.fitToWidth = String(settings.fitToPages?.width ?? 1);
384
389
  attrs.fitToHeight = String(settings.fitToPages?.height ?? 1);
385
390
  attrs.pageOrder = settings.pageOrder;
@@ -259,10 +259,12 @@ function buildColsElement(columns) {
259
259
  return el("cols", {}, columns.map((column) => {
260
260
  const attrs = {
261
261
  min: String(column.index + 1),
262
- max: String(column.index + 1),
263
- width: ptToColumnWidthChars(column.widthPt).toFixed(2),
264
- customWidth: "true"
262
+ max: String(column.index + 1)
265
263
  };
264
+ if (column.widthPt !== void 0) {
265
+ attrs.width = ptToColumnWidthChars(column.widthPt).toFixed(2);
266
+ attrs.customWidth = "true";
267
+ }
266
268
  if (column.hidden === true) attrs.hidden = "true";
267
269
  return el("col", attrs);
268
270
  }));
@@ -286,7 +288,8 @@ function renderCellValue(value, isFormulaResult, sharedStrings) {
286
288
  content: value.value ? "1" : "0"
287
289
  };
288
290
  case "date":
289
- case "time": return {
291
+ case "time":
292
+ case "dateTime": return {
290
293
  type: "d",
291
294
  content: encodeXmlText(value.value)
292
295
  };
@@ -325,8 +328,10 @@ function buildSheetDataElement(sheet, sharedStrings) {
325
328
  const rowInfo = rowInfoByIndex.get(rowIndex);
326
329
  const attrs = { r: String(rowIndex + 1) };
327
330
  if (rowInfo !== void 0) {
328
- attrs.ht = String(rowInfo.heightPt);
329
- attrs.customHeight = "true";
331
+ if (rowInfo.heightPt !== void 0) {
332
+ attrs.ht = String(rowInfo.heightPt);
333
+ attrs.customHeight = "true";
334
+ }
330
335
  if (rowInfo.hidden === true) attrs.hidden = "true";
331
336
  }
332
337
  return el("row", attrs, cells.map((cell) => buildCellElement(cell, sharedStrings)));
@@ -378,7 +383,7 @@ function buildPageSetupElement(settings) {
378
383
  attrs.paperWidth = ptToUniversalMeasure(settings.pageSize.widthPt);
379
384
  attrs.paperHeight = ptToUniversalMeasure(settings.pageSize.heightPt);
380
385
  }
381
- attrs.scale = String(settings.scale ?? 100);
386
+ attrs.scale = String(settings.scalePercent ?? 100);
382
387
  attrs.fitToWidth = String(settings.fitToPages?.width ?? 1);
383
388
  attrs.fitToHeight = String(settings.fitToPages?.height ?? 1);
384
389
  attrs.pageOrder = settings.pageOrder;
@@ -43,12 +43,12 @@ function readColumns(worksheet) {
43
43
  const minRaw = require_typed_util.attr(col, "min");
44
44
  const min = minRaw === void 0 ? void 0 : Number.parseInt(minRaw, 10);
45
45
  if (min === void 0 || !Number.isInteger(min) || min < 1) continue;
46
+ const column = { index: min - 1 };
46
47
  const widthRaw = require_typed_util.attr(col, "width");
47
- const widthPt = widthRaw === void 0 ? 0 : require_typed_xlsx_units.columnWidthCharsToPt(Number(widthRaw));
48
- const column = {
49
- index: min - 1,
50
- widthPt: Number.isFinite(widthPt) ? widthPt : 0
51
- };
48
+ if (widthRaw !== void 0) {
49
+ const widthPt = require_typed_xlsx_units.columnWidthCharsToPt(Number(widthRaw));
50
+ if (Number.isFinite(widthPt)) column.widthPt = widthPt;
51
+ }
52
52
  if (require_typed_xlsx_util.readXmlBool(require_typed_util.attr(col, "hidden"))) column.hidden = true;
53
53
  columns.push(column);
54
54
  }
@@ -86,7 +86,8 @@ function deriveDisplayText(value) {
86
86
  case "string":
87
87
  case "error":
88
88
  case "date":
89
- case "time": return value.value;
89
+ case "time":
90
+ case "dateTime": return value.value;
90
91
  case "percentage":
91
92
  case "currency": return String(value.value);
92
93
  case "empty": return "";
@@ -145,7 +146,7 @@ function readCellValue(cell, sharedStrings) {
145
146
  };
146
147
  if (type === "d") return {
147
148
  value: {
148
- kind: "date",
149
+ kind: "dateTime",
149
150
  value: raw
150
151
  },
151
152
  displayText: raw
@@ -42,12 +42,12 @@ function readColumns(worksheet) {
42
42
  const minRaw = attr(col, "min");
43
43
  const min = minRaw === void 0 ? void 0 : Number.parseInt(minRaw, 10);
44
44
  if (min === void 0 || !Number.isInteger(min) || min < 1) continue;
45
+ const column = { index: min - 1 };
45
46
  const widthRaw = attr(col, "width");
46
- const widthPt = widthRaw === void 0 ? 0 : columnWidthCharsToPt(Number(widthRaw));
47
- const column = {
48
- index: min - 1,
49
- widthPt: Number.isFinite(widthPt) ? widthPt : 0
50
- };
47
+ if (widthRaw !== void 0) {
48
+ const widthPt = columnWidthCharsToPt(Number(widthRaw));
49
+ if (Number.isFinite(widthPt)) column.widthPt = widthPt;
50
+ }
51
51
  if (readXmlBool(attr(col, "hidden"))) column.hidden = true;
52
52
  columns.push(column);
53
53
  }
@@ -85,7 +85,8 @@ function deriveDisplayText(value) {
85
85
  case "string":
86
86
  case "error":
87
87
  case "date":
88
- case "time": return value.value;
88
+ case "time":
89
+ case "dateTime": return value.value;
89
90
  case "percentage":
90
91
  case "currency": return String(value.value);
91
92
  case "empty": return "";
@@ -144,7 +145,7 @@ function readCellValue(cell, sharedStrings) {
144
145
  };
145
146
  if (type === "d") return {
146
147
  value: {
147
- kind: "date",
148
+ kind: "dateTime",
148
149
  value: raw
149
150
  },
150
151
  displayText: raw
@@ -96,7 +96,7 @@ function readPrintSettings(worksheet, sheetIndex, definedNamesBySheet) {
96
96
  const scaleRaw = pageSetup === void 0 ? void 0 : require_typed_util.attr(pageSetup, "scale");
97
97
  if (scaleRaw !== void 0) {
98
98
  const scale = Number(scaleRaw);
99
- if (Number.isFinite(scale)) settings.scale = scale;
99
+ if (Number.isFinite(scale)) settings.scalePercent = scale;
100
100
  }
101
101
  }
102
102
  if (manualBreaks !== void 0) settings.manualBreaks = manualBreaks;
@@ -95,7 +95,7 @@ function readPrintSettings(worksheet, sheetIndex, definedNamesBySheet) {
95
95
  const scaleRaw = pageSetup === void 0 ? void 0 : attr(pageSetup, "scale");
96
96
  if (scaleRaw !== void 0) {
97
97
  const scale = Number(scaleRaw);
98
- if (Number.isFinite(scale)) settings.scale = scale;
98
+ if (Number.isFinite(scale)) settings.scalePercent = scale;
99
99
  }
100
100
  }
101
101
  if (manualBreaks !== void 0) settings.manualBreaks = manualBreaks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml.js",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
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": {
@@ -69,7 +69,7 @@
69
69
  "license": "MIT",
70
70
  "packageManager": "pnpm@11.6.0",
71
71
  "dependencies": {
72
- "document-schema.js": "^1.5.3",
72
+ "document-schema.js": "^2.0.0",
73
73
  "fast-xml-parser": "^5.10.1",
74
74
  "fflate": "^0.8.3",
75
75
  "zod": "^4.4.3"