js.documents 1.60.2 → 1.60.3

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.
@@ -129,6 +129,11 @@ var OdsCell = class {
129
129
  require_xml_edit.setAttr(this.node, DATE_VALUE_ATTR, value.value);
130
130
  this.displayText = value.value;
131
131
  break;
132
+ case "dateTime":
133
+ require_xml_edit.setAttr(this.node, VALUE_TYPE_ATTR, "date");
134
+ require_xml_edit.setAttr(this.node, DATE_VALUE_ATTR, value.value);
135
+ this.displayText = value.value;
136
+ break;
132
137
  case "time":
133
138
  require_xml_edit.setAttr(this.node, VALUE_TYPE_ATTR, "time");
134
139
  require_xml_edit.setAttr(this.node, TIME_VALUE_ATTR, value.value);
@@ -128,6 +128,11 @@ var OdsCell = class {
128
128
  setAttr(this.node, DATE_VALUE_ATTR, value.value);
129
129
  this.displayText = value.value;
130
130
  break;
131
+ case "dateTime":
132
+ setAttr(this.node, VALUE_TYPE_ATTR, "date");
133
+ setAttr(this.node, DATE_VALUE_ATTR, value.value);
134
+ this.displayText = value.value;
135
+ break;
131
136
  case "time":
132
137
  setAttr(this.node, VALUE_TYPE_ATTR, "time");
133
138
  setAttr(this.node, TIME_VALUE_ATTR, value.value);
@@ -9,8 +9,8 @@ function buildOdsPackage(content) {
9
9
  const odsSheet = editor.addSheet(sheet.name);
10
10
  odsSheet.printSettings = sheet.printSettings;
11
11
  for (const cell of sheet.cells) appendCell(odsSheet, cell);
12
- for (const column of sheet.columns) odsSheet.setColumnWidth(column.index, column.widthPt);
13
- for (const row of sheet.rows) odsSheet.setRowHeight(row.index, row.heightPt);
12
+ for (const column of sheet.columns) if (column.widthPt !== void 0) odsSheet.setColumnWidth(column.index, column.widthPt);
13
+ for (const row of sheet.rows) if (row.heightPt !== void 0) odsSheet.setRowHeight(row.index, row.heightPt);
14
14
  }
15
15
  return editor.toPackage();
16
16
  }
@@ -8,8 +8,8 @@ function buildOdsPackage(content) {
8
8
  const odsSheet = editor.addSheet(sheet.name);
9
9
  odsSheet.printSettings = sheet.printSettings;
10
10
  for (const cell of sheet.cells) appendCell(odsSheet, cell);
11
- for (const column of sheet.columns) odsSheet.setColumnWidth(column.index, column.widthPt);
12
- for (const row of sheet.rows) odsSheet.setRowHeight(row.index, row.heightPt);
11
+ for (const column of sheet.columns) if (column.widthPt !== void 0) odsSheet.setColumnWidth(column.index, column.widthPt);
12
+ for (const row of sheet.rows) if (row.heightPt !== void 0) odsSheet.setRowHeight(row.index, row.heightPt);
13
13
  }
14
14
  return editor.toPackage();
15
15
  }
@@ -20,6 +20,7 @@ function displayTextFor(value) {
20
20
  case "boolean": return value.value ? "TRUE" : "FALSE";
21
21
  case "date":
22
22
  case "time":
23
+ case "dateTime":
23
24
  case "string":
24
25
  case "error": return value.value;
25
26
  case "empty": return "";
@@ -19,6 +19,7 @@ function displayTextFor(value) {
19
19
  case "boolean": return value.value ? "TRUE" : "FALSE";
20
20
  case "date":
21
21
  case "time":
22
+ case "dateTime":
22
23
  case "string":
23
24
  case "error": return value.value;
24
25
  case "empty": return "";
@@ -53,7 +53,7 @@ function resolveAxis(entries, start, end, defaultSizePt) {
53
53
  let currentHidden = false;
54
54
  for (let index = start; index <= end; index++) {
55
55
  while (pointer < sorted.length && sorted[pointer].index <= index) {
56
- currentSizePt = sorted[pointer].sizePt;
56
+ currentSizePt = sorted[pointer].sizePt ?? defaultSizePt;
57
57
  currentHidden = sorted[pointer].hidden ?? false;
58
58
  pointer++;
59
59
  }
@@ -77,7 +77,7 @@ function computeHeaderGutter(printSettings, range, measurer) {
77
77
  };
78
78
  }
79
79
  function resolveScale(printSettings, availableWidthPt, availableHeightPt, totalContentWidthPt, totalContentHeightPt) {
80
- if (printSettings.scale !== void 0) return Math.max(printSettings.scale / 100, MINIMUM_SCALE);
80
+ if (printSettings.scalePercent !== void 0) return Math.max(printSettings.scalePercent / 100, MINIMUM_SCALE);
81
81
  if (printSettings.fitToPages !== void 0) {
82
82
  const budgetWidthPt = availableWidthPt * printSettings.fitToPages.width;
83
83
  const budgetHeightPt = availableHeightPt * printSettings.fitToPages.height;
@@ -125,7 +125,7 @@ function cellStyledRuns(cell) {
125
125
  }];
126
126
  }
127
127
  function isNumericLikeValue(kind) {
128
- return kind === "number" || kind === "percentage" || kind === "currency" || kind === "date" || kind === "time";
128
+ return kind === "number" || kind === "percentage" || kind === "currency" || kind === "date" || kind === "time" || kind === "dateTime";
129
129
  }
130
130
  function defaultAlignmentForValue(kind) {
131
131
  if (isNumericLikeValue(kind)) return "right";
@@ -54,7 +54,7 @@ function resolveAxis(entries, start, end, defaultSizePt) {
54
54
  let currentHidden = false;
55
55
  for (let index = start; index <= end; index++) {
56
56
  while (pointer < sorted.length && sorted[pointer].index <= index) {
57
- currentSizePt = sorted[pointer].sizePt;
57
+ currentSizePt = sorted[pointer].sizePt ?? defaultSizePt;
58
58
  currentHidden = sorted[pointer].hidden ?? false;
59
59
  pointer++;
60
60
  }
@@ -78,7 +78,7 @@ function computeHeaderGutter(printSettings, range, measurer) {
78
78
  };
79
79
  }
80
80
  function resolveScale(printSettings, availableWidthPt, availableHeightPt, totalContentWidthPt, totalContentHeightPt) {
81
- if (printSettings.scale !== void 0) return Math.max(printSettings.scale / 100, MINIMUM_SCALE);
81
+ if (printSettings.scalePercent !== void 0) return Math.max(printSettings.scalePercent / 100, MINIMUM_SCALE);
82
82
  if (printSettings.fitToPages !== void 0) {
83
83
  const budgetWidthPt = availableWidthPt * printSettings.fitToPages.width;
84
84
  const budgetHeightPt = availableHeightPt * printSettings.fitToPages.height;
@@ -126,7 +126,7 @@ function cellStyledRuns(cell) {
126
126
  }];
127
127
  }
128
128
  function isNumericLikeValue(kind) {
129
- return kind === "number" || kind === "percentage" || kind === "currency" || kind === "date" || kind === "time";
129
+ return kind === "number" || kind === "percentage" || kind === "currency" || kind === "date" || kind === "time" || kind === "dateTime";
130
130
  }
131
131
  function defaultAlignmentForValue(kind) {
132
132
  if (isNumericLikeValue(kind)) return "right";
@@ -1,10 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let document_schema_js = require("document-schema.js");
2
3
  let markdown_codec = require("markdown-codec");
3
4
  //#region src/markdown/read.ts
4
5
  function readMarkdownContent(text, options) {
5
6
  const { document } = (0, markdown_codec.readMarkdown)(text, options);
6
7
  if (document.kind !== "wordprocessing") throw new Error("readMarkdown returned a non-wordprocessing ContentDocument");
7
- return document;
8
+ return document_schema_js.ContentDocumentSchema.parse({
9
+ ...document,
10
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION
11
+ });
8
12
  }
9
13
  //#endregion
10
14
  exports.readMarkdownContent = readMarkdownContent;
@@ -1,9 +1,13 @@
1
+ import { CONTENT_FORMAT_VERSION, ContentDocumentSchema } from "document-schema.js";
1
2
  import { readMarkdown } from "markdown-codec";
2
3
  //#region src/markdown/read.ts
3
4
  function readMarkdownContent(text, options) {
4
5
  const { document } = readMarkdown(text, options);
5
6
  if (document.kind !== "wordprocessing") throw new Error("readMarkdown returned a non-wordprocessing ContentDocument");
6
- return document;
7
+ return ContentDocumentSchema.parse({
8
+ ...document,
9
+ formatVersion: CONTENT_FORMAT_VERSION
10
+ });
7
11
  }
8
12
  //#endregion
9
13
  export { readMarkdownContent };
@@ -1,8 +1,41 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let markdown_codec = require("markdown-codec");
3
3
  //#region src/markdown/write.ts
4
+ function toLegacyEmbeddedDocument(document) {
5
+ if (document.kind !== "wordprocessing") throw new markdown_codec.MarkdownUnsupportedDocumentKindError(document.kind);
6
+ return toLegacyWordprocessingDocument(document);
7
+ }
8
+ function toLegacyBlock(block) {
9
+ if (block.kind === "table") return {
10
+ ...block,
11
+ rows: block.rows.map((row) => ({
12
+ ...row,
13
+ cells: row.cells.map((cell) => ({
14
+ ...cell,
15
+ blocks: cell.blocks.map(toLegacyBlock)
16
+ }))
17
+ }))
18
+ };
19
+ if (block.kind === "embeddedObject") return {
20
+ ...block,
21
+ document: toLegacyEmbeddedDocument(block.document)
22
+ };
23
+ return block;
24
+ }
25
+ function toLegacyWordprocessingDocument(document) {
26
+ return {
27
+ kind: "wordprocessing",
28
+ formatVersion: 1,
29
+ metadata: document.metadata,
30
+ sections: document.sections.map((section) => ({
31
+ ...section,
32
+ blocks: section.blocks.map(toLegacyBlock)
33
+ }))
34
+ };
35
+ }
4
36
  function buildMarkdownText(document, options) {
5
- return (0, markdown_codec.writeMarkdown)(document, options);
37
+ if (document.kind !== "wordprocessing") throw new markdown_codec.MarkdownUnsupportedDocumentKindError(document.kind);
38
+ return (0, markdown_codec.writeMarkdown)(toLegacyWordprocessingDocument(document), options);
6
39
  }
7
40
  //#endregion
8
41
  exports.buildMarkdownText = buildMarkdownText;
@@ -1,7 +1,40 @@
1
- import { writeMarkdown } from "markdown-codec";
1
+ import { MarkdownUnsupportedDocumentKindError, writeMarkdown } from "markdown-codec";
2
2
  //#region src/markdown/write.ts
3
+ function toLegacyEmbeddedDocument(document) {
4
+ if (document.kind !== "wordprocessing") throw new MarkdownUnsupportedDocumentKindError(document.kind);
5
+ return toLegacyWordprocessingDocument(document);
6
+ }
7
+ function toLegacyBlock(block) {
8
+ if (block.kind === "table") return {
9
+ ...block,
10
+ rows: block.rows.map((row) => ({
11
+ ...row,
12
+ cells: row.cells.map((cell) => ({
13
+ ...cell,
14
+ blocks: cell.blocks.map(toLegacyBlock)
15
+ }))
16
+ }))
17
+ };
18
+ if (block.kind === "embeddedObject") return {
19
+ ...block,
20
+ document: toLegacyEmbeddedDocument(block.document)
21
+ };
22
+ return block;
23
+ }
24
+ function toLegacyWordprocessingDocument(document) {
25
+ return {
26
+ kind: "wordprocessing",
27
+ formatVersion: 1,
28
+ metadata: document.metadata,
29
+ sections: document.sections.map((section) => ({
30
+ ...section,
31
+ blocks: section.blocks.map(toLegacyBlock)
32
+ }))
33
+ };
34
+ }
3
35
  function buildMarkdownText(document, options) {
4
- return writeMarkdown(document, options);
36
+ if (document.kind !== "wordprocessing") throw new MarkdownUnsupportedDocumentKindError(document.kind);
37
+ return writeMarkdown(toLegacyWordprocessingDocument(document), options);
5
38
  }
6
39
  //#endregion
7
40
  export { buildMarkdownText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "1.60.2",
3
+ "version": "1.60.3",
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": {
@@ -58,12 +58,12 @@
58
58
  ],
59
59
  "license": "MIT",
60
60
  "dependencies": {
61
- "document-schema.js": "^1.7.0",
61
+ "document-schema.js": "^2.0.0",
62
62
  "fflate": "^0.8.3",
63
63
  "markdown-codec": "github:ExaDev/markdown-codec#beda0a89d92fffd153d5dcd05d767b404b721cda",
64
- "odf.js": "^1.10.3",
65
- "ooxml.js": "^2.2.3",
66
- "pdf-codec": "^1.1.3",
64
+ "odf.js": "^1.13.2",
65
+ "ooxml.js": "^2.5.2",
66
+ "pdf-codec": "^1.4.2",
67
67
  "zod": "^4.4.3"
68
68
  },
69
69
  "devDependencies": {