js.documents 14.2.0 → 14.3.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.
@@ -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");
@@ -57,7 +58,6 @@ function buildDocxPackage(content, options) {
57
58
  const remap = /* @__PURE__ */ new Map();
58
59
  if (numIdLevels.size > 0) {
59
60
  const entries = [];
60
- let abstractNumId = 0;
61
61
  let numId = 1;
62
62
  for (const [sourceNumId, levels] of numIdLevels) {
63
63
  const remapped = String(numId);
@@ -65,22 +65,22 @@ function buildDocxPackage(content, options) {
65
65
  entries.push({
66
66
  sourceNumId,
67
67
  remappedNumId: remapped,
68
- abstractNumId: String(abstractNumId),
69
- levels: [...levels].sort((a, b) => a - b)
68
+ levels
70
69
  });
71
- abstractNumId += 1;
72
70
  numId += 1;
73
71
  }
74
- const numberingRoot = require_edit_docx_numbering.buildNumberingRoot(entries);
75
- pkg.parts[require_edit_docx_numbering.NUMBERING_PART_PATH] = {
76
- kind: "xml",
77
- nodes: [require_edit_docx_numbering.declaration(), numberingRoot]
78
- };
79
- require_opc_content_types.ensureContentTypeOverride(pkg, require_edit_docx_numbering.NUMBERING_PART_PATH, require_edit_docx_numbering.NUMBERING_CONTENT_TYPE);
80
- require_opc_rels.addRelationship(pkg, "word/document.xml", {
81
- type: require_edit_docx_numbering.NUMBERING_REL_TYPE,
82
- target: "numbering.xml"
83
- });
72
+ const numberingRoot = (0, ooxml_js.buildNumberingElement)(require_edit_docx_numbering.buildNumberingDefinitions(entries));
73
+ if (numberingRoot !== void 0) {
74
+ pkg.parts[require_edit_docx_numbering.NUMBERING_PART_PATH] = {
75
+ kind: "xml",
76
+ nodes: [require_edit_docx_numbering.declaration(), numberingRoot]
77
+ };
78
+ require_opc_content_types.ensureContentTypeOverride(pkg, require_edit_docx_numbering.NUMBERING_PART_PATH, require_edit_docx_numbering.NUMBERING_CONTENT_TYPE);
79
+ require_opc_rels.addRelationship(pkg, "word/document.xml", {
80
+ type: require_edit_docx_numbering.NUMBERING_REL_TYPE,
81
+ target: "numbering.xml"
82
+ });
83
+ }
84
84
  }
85
85
  const editor = new require_edit_docx_editor.DocxEditor(pkg);
86
86
  const markers = new ConstructMarkerState();
@@ -100,10 +100,10 @@ function collectListNumIds(blocks, out) {
100
100
  for (const block of blocks) if (block.kind === "paragraph" && block.list !== void 0) {
101
101
  let levels = out.get(block.list.numId);
102
102
  if (levels === void 0) {
103
- levels = /* @__PURE__ */ new Set();
103
+ levels = /* @__PURE__ */ new Map();
104
104
  out.set(block.list.numId, levels);
105
105
  }
106
- levels.add(block.list.level);
106
+ if (!levels.has(block.list.level)) levels.set(block.list.level, block.list.format);
107
107
  } else if (block.kind === "table") for (const row of block.rows) for (const cell of row.cells) collectListNumIds(cell.blocks, out);
108
108
  }
109
109
  function remapListNumIds(blocks, numIdMap) {
@@ -114,8 +114,8 @@ function remapListNumIds(blocks, numIdMap) {
114
114
  return remapped === void 0 ? block : {
115
115
  ...block,
116
116
  list: {
117
- numId: remapped,
118
- level: block.list.level
117
+ ...block.list,
118
+ numId: remapped
119
119
  }
120
120
  };
121
121
  }
@@ -208,8 +208,18 @@ function docxRowCells(positions, positionsByRow) {
208
208
  return [];
209
209
  });
210
210
  }
211
- function appendTable(body, block) {
211
+ function reportDroppedHeaderColumns(block, onDiagnostic) {
212
+ block.columns.forEach((column, columnIndex) => {
213
+ if (column.isHeader === true) onDiagnostic({
214
+ code: require_edit_docx_diagnostics.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) {
212
221
  require_edit_table_grid.assertTableObeysGridRule(block, "buildDocxPackage");
222
+ reportDroppedHeaderColumns(block, options?.onDiagnostic ?? require_edit_docx_diagnostics.NOOP_DOCX_WRITE_DIAGNOSTIC_SINK);
213
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)");
214
224
  const table = body.appendTable({
215
225
  rows: 0,
@@ -250,7 +260,7 @@ function appendBlock(body, block, options, markers) {
250
260
  altText: block.altText
251
261
  });
252
262
  } else if (block.kind === "pageBreak") body.appendPageBreak();
253
- else if (block.kind === "table") appendTable(body, block);
263
+ else if (block.kind === "table") appendTable(body, block, options);
254
264
  else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
255
265
  else if (block.kind === "constructStart") markers.openConstruct(body, block);
256
266
  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,8 +9,9 @@ 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 { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingRoot, declaration } from "./numbering.js";
13
- import { base64ToBytes } from "ooxml.js";
12
+ import { DocxWriteDiagnosticCodes, NOOP_DOCX_WRITE_DIAGNOSTIC_SINK } from "./diagnostics.js";
13
+ import { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingDefinitions, declaration } from "./numbering.js";
14
+ import { base64ToBytes, buildNumberingElement } from "ooxml.js";
14
15
  import { resolveCellFillColor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "document-schema.js";
15
16
  //#region src/edit/docx/content.ts
16
17
  var ConstructMarkerState = class {
@@ -56,7 +57,6 @@ function buildDocxPackage(content, options) {
56
57
  const remap = /* @__PURE__ */ new Map();
57
58
  if (numIdLevels.size > 0) {
58
59
  const entries = [];
59
- let abstractNumId = 0;
60
60
  let numId = 1;
61
61
  for (const [sourceNumId, levels] of numIdLevels) {
62
62
  const remapped = String(numId);
@@ -64,22 +64,22 @@ function buildDocxPackage(content, options) {
64
64
  entries.push({
65
65
  sourceNumId,
66
66
  remappedNumId: remapped,
67
- abstractNumId: String(abstractNumId),
68
- levels: [...levels].sort((a, b) => a - b)
67
+ levels
69
68
  });
70
- abstractNumId += 1;
71
69
  numId += 1;
72
70
  }
73
- const numberingRoot = buildNumberingRoot(entries);
74
- pkg.parts[NUMBERING_PART_PATH] = {
75
- kind: "xml",
76
- nodes: [declaration(), numberingRoot]
77
- };
78
- ensureContentTypeOverride(pkg, NUMBERING_PART_PATH, NUMBERING_CONTENT_TYPE);
79
- addRelationship(pkg, "word/document.xml", {
80
- type: NUMBERING_REL_TYPE,
81
- target: "numbering.xml"
82
- });
71
+ const numberingRoot = buildNumberingElement(buildNumberingDefinitions(entries));
72
+ if (numberingRoot !== void 0) {
73
+ pkg.parts[NUMBERING_PART_PATH] = {
74
+ kind: "xml",
75
+ nodes: [declaration(), numberingRoot]
76
+ };
77
+ ensureContentTypeOverride(pkg, NUMBERING_PART_PATH, NUMBERING_CONTENT_TYPE);
78
+ addRelationship(pkg, "word/document.xml", {
79
+ type: NUMBERING_REL_TYPE,
80
+ target: "numbering.xml"
81
+ });
82
+ }
83
83
  }
84
84
  const editor = new DocxEditor(pkg);
85
85
  const markers = new ConstructMarkerState();
@@ -99,10 +99,10 @@ function collectListNumIds(blocks, out) {
99
99
  for (const block of blocks) if (block.kind === "paragraph" && block.list !== void 0) {
100
100
  let levels = out.get(block.list.numId);
101
101
  if (levels === void 0) {
102
- levels = /* @__PURE__ */ new Set();
102
+ levels = /* @__PURE__ */ new Map();
103
103
  out.set(block.list.numId, levels);
104
104
  }
105
- levels.add(block.list.level);
105
+ if (!levels.has(block.list.level)) levels.set(block.list.level, block.list.format);
106
106
  } else if (block.kind === "table") for (const row of block.rows) for (const cell of row.cells) collectListNumIds(cell.blocks, out);
107
107
  }
108
108
  function remapListNumIds(blocks, numIdMap) {
@@ -113,8 +113,8 @@ function remapListNumIds(blocks, numIdMap) {
113
113
  return remapped === void 0 ? block : {
114
114
  ...block,
115
115
  list: {
116
- numId: remapped,
117
- level: block.list.level
116
+ ...block.list,
117
+ numId: remapped
118
118
  }
119
119
  };
120
120
  }
@@ -207,8 +207,18 @@ function docxRowCells(positions, positionsByRow) {
207
207
  return [];
208
208
  });
209
209
  }
210
- function appendTable(body, block) {
210
+ function reportDroppedHeaderColumns(block, onDiagnostic) {
211
+ block.columns.forEach((column, columnIndex) => {
212
+ if (column.isHeader === true) onDiagnostic({
213
+ code: DocxWriteDiagnosticCodes.TABLE_HEADER_COLUMN_DROPPED,
214
+ severity: "warning",
215
+ 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`
216
+ }, { sourcePath: block.sourcePath });
217
+ });
218
+ }
219
+ function appendTable(body, block, options) {
211
220
  assertTableObeysGridRule(block, "buildDocxPackage");
221
+ reportDroppedHeaderColumns(block, options?.onDiagnostic ?? NOOP_DOCX_WRITE_DIAGNOSTIC_SINK);
212
222
  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
223
  const table = body.appendTable({
214
224
  rows: 0,
@@ -249,7 +259,7 @@ function appendBlock(body, block, options, markers) {
249
259
  altText: block.altText
250
260
  });
251
261
  } else if (block.kind === "pageBreak") body.appendPageBreak();
252
- else if (block.kind === "table") appendTable(body, block);
262
+ else if (block.kind === "table") appendTable(body, block, options);
253
263
  else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
254
264
  else if (block.kind === "constructStart") markers.openConstruct(body, block);
255
265
  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 };
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_xml_fragment = require("../../xml/fragment.cjs");
3
2
  //#region src/edit/docx/numbering.ts
4
3
  const NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
5
4
  const NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
@@ -23,23 +22,25 @@ function declaration() {
23
22
  ]
24
23
  };
25
24
  }
26
- function buildNumberingRoot(entries) {
27
- const W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
28
- const abstractNums = entries.map((entry) => require_xml_fragment.el("w:abstractNum", { "w:abstractNumId": entry.abstractNumId }, entry.levels.map((level) => require_xml_fragment.el("w:lvl", {
29
- "w:ilvl": String(level),
30
- "w:tentative": "1"
31
- }, [
32
- require_xml_fragment.el("w:start", { "w:val": "1" }),
33
- require_xml_fragment.el("w:numFmt", { "w:val": "bullet" }),
34
- require_xml_fragment.el("w:lvlText", { "w:val": "•" }),
35
- require_xml_fragment.el("w:lvlJc", { "w:val": "left" })
36
- ]))));
37
- const nums = entries.map((entry) => require_xml_fragment.el("w:num", { "w:numId": entry.remappedNumId }, [require_xml_fragment.el("w:abstractNumId", { "w:val": entry.abstractNumId })]));
38
- return require_xml_fragment.el("w:numbering", { "xmlns:w": W }, [...abstractNums, ...nums]);
25
+ function lvlText(format, level) {
26
+ return format === void 0 || format === "bullet" ? "•" : `%${level + 1}.`;
27
+ }
28
+ function buildNumberingDefinitions(entries) {
29
+ const definitions = {};
30
+ for (const entry of entries) {
31
+ const levels = {};
32
+ for (const [level, format] of entry.levels) levels[String(level)] = {
33
+ format: format ?? "bullet",
34
+ text: lvlText(format, level),
35
+ startAt: 1
36
+ };
37
+ definitions[entry.remappedNumId] = { levels };
38
+ }
39
+ return definitions;
39
40
  }
40
41
  //#endregion
41
42
  exports.NUMBERING_CONTENT_TYPE = NUMBERING_CONTENT_TYPE;
42
43
  exports.NUMBERING_PART_PATH = NUMBERING_PART_PATH;
43
44
  exports.NUMBERING_REL_TYPE = NUMBERING_REL_TYPE;
44
- exports.buildNumberingRoot = buildNumberingRoot;
45
+ exports.buildNumberingDefinitions = buildNumberingDefinitions;
45
46
  exports.declaration = declaration;
@@ -1,4 +1,5 @@
1
- import { XmlElement, XmlNode } from "ooxml.js";
1
+ import { ContentListMembership } from "document-schema.js";
2
+ import { NumberingDefinitions, XmlNode } from "ooxml.js";
2
3
  //#region src/edit/docx/numbering.d.ts
3
4
  declare const NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
4
5
  declare const NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
@@ -7,9 +8,8 @@ declare function declaration(): XmlNode;
7
8
  interface NumberingEntry {
8
9
  readonly sourceNumId: string | undefined;
9
10
  readonly remappedNumId: string;
10
- readonly abstractNumId: string;
11
- readonly levels: readonly number[];
11
+ readonly levels: ReadonlyMap<number, ContentListMembership["format"]>;
12
12
  }
13
- declare function buildNumberingRoot(entries: readonly NumberingEntry[]): XmlElement;
13
+ declare function buildNumberingDefinitions(entries: readonly NumberingEntry[]): NumberingDefinitions;
14
14
  //#endregion
15
- export { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, NumberingEntry, buildNumberingRoot, declaration };
15
+ export { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, NumberingEntry, buildNumberingDefinitions, declaration };
@@ -1,4 +1,5 @@
1
- import { XmlElement, XmlNode } from "ooxml.js";
1
+ import { NumberingDefinitions, XmlNode } from "ooxml.js";
2
+ import { ContentListMembership } from "document-schema.js";
2
3
  //#region src/edit/docx/numbering.d.ts
3
4
  declare const NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
4
5
  declare const NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
@@ -7,9 +8,8 @@ declare function declaration(): XmlNode;
7
8
  interface NumberingEntry {
8
9
  readonly sourceNumId: string | undefined;
9
10
  readonly remappedNumId: string;
10
- readonly abstractNumId: string;
11
- readonly levels: readonly number[];
11
+ readonly levels: ReadonlyMap<number, ContentListMembership["format"]>;
12
12
  }
13
- declare function buildNumberingRoot(entries: readonly NumberingEntry[]): XmlElement;
13
+ declare function buildNumberingDefinitions(entries: readonly NumberingEntry[]): NumberingDefinitions;
14
14
  //#endregion
15
- export { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, NumberingEntry, buildNumberingRoot, declaration };
15
+ export { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, NumberingEntry, buildNumberingDefinitions, declaration };
@@ -1,4 +1,3 @@
1
- import { el } from "../../xml/fragment.js";
2
1
  //#region src/edit/docx/numbering.ts
3
2
  const NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
4
3
  const NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
@@ -22,19 +21,21 @@ function declaration() {
22
21
  ]
23
22
  };
24
23
  }
25
- function buildNumberingRoot(entries) {
26
- const W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
27
- const abstractNums = entries.map((entry) => el("w:abstractNum", { "w:abstractNumId": entry.abstractNumId }, entry.levels.map((level) => el("w:lvl", {
28
- "w:ilvl": String(level),
29
- "w:tentative": "1"
30
- }, [
31
- el("w:start", { "w:val": "1" }),
32
- el("w:numFmt", { "w:val": "bullet" }),
33
- el("w:lvlText", { "w:val": "•" }),
34
- el("w:lvlJc", { "w:val": "left" })
35
- ]))));
36
- const nums = entries.map((entry) => el("w:num", { "w:numId": entry.remappedNumId }, [el("w:abstractNumId", { "w:val": entry.abstractNumId })]));
37
- return el("w:numbering", { "xmlns:w": W }, [...abstractNums, ...nums]);
24
+ function lvlText(format, level) {
25
+ return format === void 0 || format === "bullet" ? "•" : `%${level + 1}.`;
26
+ }
27
+ function buildNumberingDefinitions(entries) {
28
+ const definitions = {};
29
+ for (const entry of entries) {
30
+ const levels = {};
31
+ for (const [level, format] of entry.levels) levels[String(level)] = {
32
+ format: format ?? "bullet",
33
+ text: lvlText(format, level),
34
+ startAt: 1
35
+ };
36
+ definitions[entry.remappedNumId] = { levels };
37
+ }
38
+ return definitions;
38
39
  }
39
40
  //#endregion
40
- export { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingRoot, declaration };
41
+ export { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingDefinitions, declaration };
@@ -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-ukpjK2hS.cjs";
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-BuNLtwgL.js";
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
@@ -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
- tcPr.children.push(require_xml_fragment.el(tag, { w: String(require_model_units.ptToEmu(border.widthPt)) }, [require_xml_fragment.el("a:solidFill", {}, [require_xml_fragment.el("a:srgbClr", { val: require_edit_drawingml_vector.drawingMlColorHex(border.color) })])]));
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
- rows.push(require_xml_fragment.el("a:tr", { h: String(require_model_units.ptToEmu(DEFAULT_ROW_HEIGHT_PT)) }, cells));
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-ukpjK2hS.cjs";
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-BuNLtwgL.js";
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 };
@@ -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
- tcPr.children.push(el(tag, { w: String(ptToEmu(border.widthPt)) }, [el("a:solidFill", {}, [el("a:srgbClr", { val: drawingMlColorHex(border.color) })])]));
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
- rows.push(el("a:tr", { h: String(ptToEmu(DEFAULT_ROW_HEIGHT_PT)) }, cells));
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-ukpjK2hS.cjs";
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-BuNLtwgL.js";
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.2.0",
3
+ "version": "14.3.1",
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.3",
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.2",
88
+ "ooxml.js": "12.2.0",
89
89
  "pdf-codec": "5.2.6",
90
90
  "ppt-codec": "2.2.0",
91
91
  "rtf-codec": "8.1.0",