js.documents 14.1.1 → 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.
Files changed (65) hide show
  1. package/dist/convert/variant-bridges.cjs +2 -2
  2. package/dist/convert/variant-bridges.js +2 -2
  3. package/dist/diagnostics-C2-C2uUI.d.cts +17 -0
  4. package/dist/diagnostics-C2-C2uUI.d.ts +17 -0
  5. package/dist/{diagnostics-9twvwLNY.d.cts → diagnostics-CGWySzd-.d.cts} +1 -0
  6. package/dist/{diagnostics-9twvwLNY.d.ts → diagnostics-CGWySzd-.d.ts} +1 -0
  7. package/dist/edit/doc/table.cjs +3 -3
  8. package/dist/edit/doc/table.js +3 -3
  9. package/dist/edit/docx/content.cjs +14 -3
  10. package/dist/edit/docx/content.d.cts +2 -0
  11. package/dist/edit/docx/content.d.ts +2 -0
  12. package/dist/edit/docx/content.js +14 -3
  13. package/dist/edit/docx/diagnostics.cjs +7 -0
  14. package/dist/edit/docx/diagnostics.d.cts +2 -0
  15. package/dist/edit/docx/diagnostics.d.ts +2 -0
  16. package/dist/edit/docx/diagnostics.js +5 -0
  17. package/dist/edit/markdown/table.cjs +3 -3
  18. package/dist/edit/markdown/table.js +3 -3
  19. package/dist/edit/odp/slide.d.cts +1 -1
  20. package/dist/edit/odp/slide.d.ts +1 -1
  21. package/dist/edit/odt/content.cjs +4 -2
  22. package/dist/edit/odt/content.d.cts +2 -2
  23. package/dist/edit/odt/content.d.ts +2 -2
  24. package/dist/edit/odt/content.js +4 -2
  25. package/dist/edit/odt/editor.d.cts +1 -1
  26. package/dist/edit/odt/editor.d.ts +1 -1
  27. package/dist/edit/odt/table.cjs +59 -4
  28. package/dist/edit/odt/table.d.cts +1 -1
  29. package/dist/edit/odt/table.d.ts +1 -1
  30. package/dist/edit/odt/table.js +59 -4
  31. package/dist/edit/pptx/content.cjs +12 -1
  32. package/dist/edit/pptx/content.d.cts +1 -1
  33. package/dist/edit/pptx/content.d.ts +1 -1
  34. package/dist/edit/pptx/content.js +12 -1
  35. package/dist/edit/pptx/diagnostics.cjs +4 -1
  36. package/dist/edit/pptx/diagnostics.d.cts +1 -1
  37. package/dist/edit/pptx/diagnostics.d.ts +1 -1
  38. package/dist/edit/pptx/diagnostics.js +4 -1
  39. package/dist/edit/pptx/slide.d.cts +1 -1
  40. package/dist/edit/pptx/slide.d.ts +1 -1
  41. package/dist/edit/pptx/table.cjs +29 -3
  42. package/dist/edit/pptx/table.d.cts +1 -1
  43. package/dist/edit/pptx/table.d.ts +1 -1
  44. package/dist/edit/pptx/table.js +29 -3
  45. package/dist/edit/table-grid.cjs +2 -2
  46. package/dist/edit/table-grid.js +2 -2
  47. package/dist/index.d.cts +2 -2
  48. package/dist/index.d.ts +2 -2
  49. package/dist/layout/engine.cjs +1 -1
  50. package/dist/layout/engine.js +1 -1
  51. package/dist/layout/reconstruct.cjs +6 -6
  52. package/dist/layout/reconstruct.js +6 -6
  53. package/dist/layout/shared.cjs +3 -2
  54. package/dist/layout/shared.js +3 -2
  55. package/dist/layout/slides.cjs +1 -1
  56. package/dist/layout/slides.js +1 -1
  57. package/dist/markdown/render.cjs +3 -3
  58. package/dist/markdown/render.js +3 -3
  59. package/dist/odb/report/render.cjs +1 -1
  60. package/dist/odb/report/render.js +1 -1
  61. package/dist/{table-BuNLtwgL.d.ts → table-B1uKqI0r.d.ts} +2 -0
  62. package/dist/{table-Cou5rKOo.d.ts → table-B5htMG3g.d.ts} +2 -0
  63. package/dist/{table-ukpjK2hS.d.cts → table-CxLN4l90.d.cts} +2 -0
  64. package/dist/{table-Bt9ahRyh.d.cts → table-DrE6jEWv.d.cts} +2 -0
  65. package/package.json +13 -13
@@ -120,11 +120,11 @@ function sheetToTableBlock(sheet) {
120
120
  const visibleColumns = [];
121
121
  for (let column = 0; column <= maxColumn; column += 1) if (!hiddenColumns.has(column)) visibleColumns.push(column);
122
122
  const columnWidthByIndex = new Map(sheet.columns.map((column) => [column.index, column.widthPt]));
123
- const columnWidthsPt = visibleColumns.map((column) => columnWidthByIndex.get(column) ?? 72);
123
+ const columns = visibleColumns.map((column) => ({ widthPt: columnWidthByIndex.get(column) ?? 72 }));
124
124
  return {
125
125
  kind: "table",
126
126
  rows: visibleRows.map((row) => ({ cells: visibleColumns.map((column) => spreadsheetCellToTableCell(cellByPosition.get(`${String(row)}:${String(column)}`))) })),
127
- columnWidthsPt
127
+ columns
128
128
  };
129
129
  }
130
130
  function spreadsheetToWordprocessing(doc) {
@@ -119,11 +119,11 @@ function sheetToTableBlock(sheet) {
119
119
  const visibleColumns = [];
120
120
  for (let column = 0; column <= maxColumn; column += 1) if (!hiddenColumns.has(column)) visibleColumns.push(column);
121
121
  const columnWidthByIndex = new Map(sheet.columns.map((column) => [column.index, column.widthPt]));
122
- const columnWidthsPt = visibleColumns.map((column) => columnWidthByIndex.get(column) ?? 72);
122
+ const columns = visibleColumns.map((column) => ({ widthPt: columnWidthByIndex.get(column) ?? 72 }));
123
123
  return {
124
124
  kind: "table",
125
125
  rows: visibleRows.map((row) => ({ cells: visibleColumns.map((column) => spreadsheetCellToTableCell(cellByPosition.get(`${String(row)}:${String(column)}`))) })),
126
- columnWidthsPt
126
+ columns
127
127
  };
128
128
  }
129
129
  function spreadsheetToWordprocessing(doc) {
@@ -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 };
@@ -2,6 +2,7 @@
2
2
  type PptxWriteDiagnosticSeverity = "info" | "warning";
3
3
  declare const PptxWriteDiagnosticCodes: {
4
4
  readonly TABLE_HEADER_ROW_DROPPED: "pptx-write/table-header-row-dropped";
5
+ readonly TABLE_HEADER_COLUMN_DROPPED: "pptx-write/table-header-column-dropped";
5
6
  };
6
7
  type PptxWriteDiagnosticCode = (typeof PptxWriteDiagnosticCodes)[keyof typeof PptxWriteDiagnosticCodes];
7
8
  interface PptxWriteDiagnostic {
@@ -2,6 +2,7 @@
2
2
  type PptxWriteDiagnosticSeverity = "info" | "warning";
3
3
  declare const PptxWriteDiagnosticCodes: {
4
4
  readonly TABLE_HEADER_ROW_DROPPED: "pptx-write/table-header-row-dropped";
5
+ readonly TABLE_HEADER_COLUMN_DROPPED: "pptx-write/table-header-column-dropped";
5
6
  };
6
7
  type PptxWriteDiagnosticCode = (typeof PptxWriteDiagnosticCodes)[keyof typeof PptxWriteDiagnosticCodes];
7
8
  interface PptxWriteDiagnostic {
@@ -81,7 +81,7 @@ var DocTable = class {
81
81
  }
82
82
  appendRow() {
83
83
  const node = this.live();
84
- const row = buildRow(node.columnWidthsPt.length);
84
+ const row = buildRow(node.columns.length);
85
85
  node.rows.push(row);
86
86
  return new DocTableRow(row);
87
87
  }
@@ -115,13 +115,13 @@ var DocTable = class {
115
115
  }
116
116
  };
117
117
  function buildTable(init) {
118
- const columnWidthsPt = Array.from({ length: init.columns }, () => DEFAULT_TABLE_WIDTH_PT / init.columns);
118
+ const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
119
119
  const rows = [];
120
120
  for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
121
121
  return {
122
122
  kind: "table",
123
123
  rows,
124
- columnWidthsPt
124
+ columns
125
125
  };
126
126
  }
127
127
  //#endregion
@@ -80,7 +80,7 @@ var DocTable = class {
80
80
  }
81
81
  appendRow() {
82
82
  const node = this.live();
83
- const row = buildRow(node.columnWidthsPt.length);
83
+ const row = buildRow(node.columns.length);
84
84
  node.rows.push(row);
85
85
  return new DocTableRow(row);
86
86
  }
@@ -114,13 +114,13 @@ var DocTable = class {
114
114
  }
115
115
  };
116
116
  function buildTable(init) {
117
- const columnWidthsPt = Array.from({ length: init.columns }, () => DEFAULT_TABLE_WIDTH_PT / init.columns);
117
+ const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
118
118
  const rows = [];
119
119
  for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
120
120
  return {
121
121
  kind: "table",
122
122
  rows,
123
- columnWidthsPt
123
+ columns
124
124
  };
125
125
  }
126
126
  //#endregion
@@ -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,13 +209,23 @@ function docxRowCells(positions, positionsByRow) {
208
209
  return [];
209
210
  });
210
211
  }
211
- function appendTable(body, block) {
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,
216
227
  columns: (0, document_schema_js.tableGridColumnCount)(block),
217
- columnWidthsTwips: block.columnWidthsPt.map(require_model_units.ptToTwips)
228
+ columnWidthsTwips: block.columns.map((c) => require_model_units.ptToTwips(c.widthPt))
218
229
  });
219
230
  const positionsByRow = (0, document_schema_js.walkTableGrid)(block);
220
231
  block.rows.forEach((row, rowIndex) => {
@@ -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,13 +208,23 @@ function docxRowCells(positions, positionsByRow) {
207
208
  return [];
208
209
  });
209
210
  }
210
- function appendTable(body, block) {
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,
215
226
  columns: tableGridColumnCount(block),
216
- columnWidthsTwips: block.columnWidthsPt.map(ptToTwips)
227
+ columnWidthsTwips: block.columns.map((c) => ptToTwips(c.widthPt))
217
228
  });
218
229
  const positionsByRow = walkTableGrid(block);
219
230
  block.rows.forEach((row, rowIndex) => {
@@ -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 };
@@ -66,7 +66,7 @@ var MarkdownTable = class {
66
66
  }
67
67
  appendRow() {
68
68
  const node = this.live();
69
- const row = buildRow(node.columnWidthsPt.length);
69
+ const row = buildRow(node.columns.length);
70
70
  node.rows.push(row);
71
71
  return new MarkdownTableRow(row);
72
72
  }
@@ -78,13 +78,13 @@ var MarkdownTable = class {
78
78
  }
79
79
  };
80
80
  function buildTable(init) {
81
- const columnWidthsPt = Array.from({ length: init.columns }, () => DEFAULT_TABLE_WIDTH_PT / init.columns);
81
+ const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
82
82
  const rows = [];
83
83
  for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
84
84
  return {
85
85
  kind: "table",
86
86
  rows,
87
- columnWidthsPt
87
+ columns
88
88
  };
89
89
  }
90
90
  //#endregion
@@ -65,7 +65,7 @@ var MarkdownTable = class {
65
65
  }
66
66
  appendRow() {
67
67
  const node = this.live();
68
- const row = buildRow(node.columnWidthsPt.length);
68
+ const row = buildRow(node.columns.length);
69
69
  node.rows.push(row);
70
70
  return new MarkdownTableRow(row);
71
71
  }
@@ -77,13 +77,13 @@ var MarkdownTable = class {
77
77
  }
78
78
  };
79
79
  function buildTable(init) {
80
- const columnWidthsPt = Array.from({ length: init.columns }, () => DEFAULT_TABLE_WIDTH_PT / init.columns);
80
+ const columns = Array.from({ length: init.columns }, () => ({ widthPt: DEFAULT_TABLE_WIDTH_PT / init.columns }));
81
81
  const rows = [];
82
82
  for (let r = 0; r < init.rows; r++) rows.push(buildRow(init.columns));
83
83
  return {
84
84
  kind: "table",
85
85
  rows,
86
- columnWidthsPt
86
+ columns
87
87
  };
88
88
  }
89
89
  //#endregion
@@ -1,7 +1,7 @@
1
1
  import { t as ImageInit } from "../../image-D1z0T9Za.cjs";
2
2
  import { t as OdpShape } from "../../shape-Kmmxib5z.cjs";
3
3
  import { s as OdgVector } from "../../vector-DDP7hgvm.cjs";
4
- import { o as TableInit, r as OdtTable } from "../../table-Bt9ahRyh.cjs";
4
+ import { o as TableInit, r as OdtTable } from "../../table-DrE6jEWv.cjs";
5
5
  import { Box, ContentFormula, ContentVector } from "document-schema.js";
6
6
  import { Package, XmlElement, XmlNode } from "odf.js";
7
7
  //#region src/edit/odp/slide.d.ts
@@ -1,7 +1,7 @@
1
1
  import { t as ImageInit } from "../../image-D1z0T9Za.js";
2
2
  import { t as OdpShape } from "../../shape-ZAfNsCC5.js";
3
3
  import { s as OdgVector } from "../../vector-DDP7hgvm.js";
4
- import { o as TableInit, r as OdtTable } from "../../table-Cou5rKOo.js";
4
+ import { o as TableInit, r as OdtTable } from "../../table-B5htMG3g.js";
5
5
  import { Box, ContentFormula, ContentVector } from "document-schema.js";
6
6
  import { Package, XmlElement, XmlNode } from "odf.js";
7
7
  //#region src/edit/odp/slide.d.ts
@@ -136,6 +136,7 @@ function populateOdtTable(table, block) {
136
136
  require_edit_table_grid.assertTableObeysGridRule(block, "populateOdtTable");
137
137
  const gridPositions = (0, document_schema_js.walkTableGrid)(block);
138
138
  const headerFlags = block.rows.map((row) => row.isHeader === true);
139
+ const columnHeaderFlags = block.columns.map((column) => column.isHeader === true);
139
140
  block.rows.forEach((row, rowIndex) => {
140
141
  const tableRow = table.appendEmptyRow();
141
142
  tableRow.heightPt = row.heightPt;
@@ -155,6 +156,7 @@ function populateOdtTable(table, block) {
155
156
  });
156
157
  });
157
158
  table.setHeaderRows(headerFlags);
159
+ table.setHeaderColumns(columnHeaderFlags);
158
160
  }
159
161
  function applyCellDecoration(target, cell) {
160
162
  if (cell.background !== void 0) target.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
@@ -163,7 +165,7 @@ function applyCellDecoration(target, cell) {
163
165
  /**
164
166
  * The arguments that create the empty `table:table` a ContentTable is written into: no rows, since populateOdtTable appends one per ContentTableRow, and as many columns as the table's grid is wide.
165
167
  *
166
- * The grid width is what the rows and `columnWidthsPt` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. `columnWidthsPt` is passed through untouched, so a width the table does state is always written.
168
+ * The grid width is what the rows and `columns` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. Each column's own `widthPt` is passed through untouched, so a width the table does state is always written; `isHeader` is not part of this init at all, since populateOdtTable states it afterwards via OdtTable.setHeaderColumns, the identical two-step `setHeaderRows` already needs for the same reason on the row axis.
167
169
  *
168
170
  * Throws when the table has no rows: ODF requires a `table:table` to hold at least one `table:table-row`, so no faithful spelling exists, and dropping the table would lose it without a trace. `entryPoint` names the caller in the message. A table that breaks the grid rule is refused by populateOdtTable before it writes anything, and a table with no rows has no grid fault to report, so the two checks never compete.
169
171
  */
@@ -172,7 +174,7 @@ function odtTableInit(block, entryPoint) {
172
174
  return {
173
175
  rows: 0,
174
176
  columns: (0, document_schema_js.tableGridColumnCount)(block),
175
- columnWidthsPt: block.columnWidthsPt
177
+ columnWidthsPt: block.columns.map((column) => column.widthPt)
176
178
  };
177
179
  }
178
180
  function appendTable(body, block) {
@@ -1,6 +1,6 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
2
2
  import { t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
3
- import { o as TableInit, r as OdtTable } from "../../table-Bt9ahRyh.cjs";
3
+ import { o as TableInit, r as OdtTable } from "../../table-DrE6jEWv.cjs";
4
4
  import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
5
5
  import { Package } from "odf.js";
6
6
  //#region src/edit/odt/content.d.ts
@@ -16,7 +16,7 @@ declare function populateOdtTable(table: OdtTable, block: ContentTable): void;
16
16
  /**
17
17
  * The arguments that create the empty `table:table` a ContentTable is written into: no rows, since populateOdtTable appends one per ContentTableRow, and as many columns as the table's grid is wide.
18
18
  *
19
- * The grid width is what the rows and `columnWidthsPt` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. `columnWidthsPt` is passed through untouched, so a width the table does state is always written.
19
+ * The grid width is what the rows and `columns` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. Each column's own `widthPt` is passed through untouched, so a width the table does state is always written; `isHeader` is not part of this init at all, since populateOdtTable states it afterwards via OdtTable.setHeaderColumns, the identical two-step `setHeaderRows` already needs for the same reason on the row axis.
20
20
  *
21
21
  * Throws when the table has no rows: ODF requires a `table:table` to hold at least one `table:table-row`, so no faithful spelling exists, and dropping the table would lose it without a trace. `entryPoint` names the caller in the message. A table that breaks the grid rule is refused by populateOdtTable before it writes anything, and a table with no rows has no grid fault to report, so the two checks never compete.
22
22
  */
@@ -1,6 +1,6 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.js";
2
2
  import { t as OdtParagraph } from "../../paragraph-D4f705GG.js";
3
- import { o as TableInit, r as OdtTable } from "../../table-Cou5rKOo.js";
3
+ import { o as TableInit, r as OdtTable } from "../../table-B5htMG3g.js";
4
4
  import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
5
5
  import { Package } from "odf.js";
6
6
  //#region src/edit/odt/content.d.ts
@@ -16,7 +16,7 @@ declare function populateOdtTable(table: OdtTable, block: ContentTable): void;
16
16
  /**
17
17
  * The arguments that create the empty `table:table` a ContentTable is written into: no rows, since populateOdtTable appends one per ContentTableRow, and as many columns as the table's grid is wide.
18
18
  *
19
- * The grid width is what the rows and `columnWidthsPt` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. `columnWidthsPt` is passed through untouched, so a width the table does state is always written.
19
+ * The grid width is what the rows and `columns` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. Each column's own `widthPt` is passed through untouched, so a width the table does state is always written; `isHeader` is not part of this init at all, since populateOdtTable states it afterwards via OdtTable.setHeaderColumns, the identical two-step `setHeaderRows` already needs for the same reason on the row axis.
20
20
  *
21
21
  * Throws when the table has no rows: ODF requires a `table:table` to hold at least one `table:table-row`, so no faithful spelling exists, and dropping the table would lose it without a trace. `entryPoint` names the caller in the message. A table that breaks the grid rule is refused by populateOdtTable before it writes anything, and a table with no rows has no grid fault to report, so the two checks never compete.
22
22
  */
@@ -135,6 +135,7 @@ function populateOdtTable(table, block) {
135
135
  assertTableObeysGridRule(block, "populateOdtTable");
136
136
  const gridPositions = walkTableGrid(block);
137
137
  const headerFlags = block.rows.map((row) => row.isHeader === true);
138
+ const columnHeaderFlags = block.columns.map((column) => column.isHeader === true);
138
139
  block.rows.forEach((row, rowIndex) => {
139
140
  const tableRow = table.appendEmptyRow();
140
141
  tableRow.heightPt = row.heightPt;
@@ -154,6 +155,7 @@ function populateOdtTable(table, block) {
154
155
  });
155
156
  });
156
157
  table.setHeaderRows(headerFlags);
158
+ table.setHeaderColumns(columnHeaderFlags);
157
159
  }
158
160
  function applyCellDecoration(target, cell) {
159
161
  if (cell.background !== void 0) target.background = resolveCellFillColor(cell.background);
@@ -162,7 +164,7 @@ function applyCellDecoration(target, cell) {
162
164
  /**
163
165
  * The arguments that create the empty `table:table` a ContentTable is written into: no rows, since populateOdtTable appends one per ContentTableRow, and as many columns as the table's grid is wide.
164
166
  *
165
- * The grid width is what the rows and `columnWidthsPt` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. `columnWidthsPt` is passed through untouched, so a width the table does state is always written.
167
+ * The grid width is what the rows and `columns` together state (tableGridColumnCount), so a table whose rows carry cells but which states no column widths still gets one `table:table-column` per grid column; a column with no stated width takes an equal share of the default table width, the same as any column created without one. Each column's own `widthPt` is passed through untouched, so a width the table does state is always written; `isHeader` is not part of this init at all, since populateOdtTable states it afterwards via OdtTable.setHeaderColumns, the identical two-step `setHeaderRows` already needs for the same reason on the row axis.
166
168
  *
167
169
  * Throws when the table has no rows: ODF requires a `table:table` to hold at least one `table:table-row`, so no faithful spelling exists, and dropping the table would lose it without a trace. `entryPoint` names the caller in the message. A table that breaks the grid rule is refused by populateOdtTable before it writes anything, and a table with no rows has no grid fault to report, so the two checks never compete.
168
170
  */
@@ -171,7 +173,7 @@ function odtTableInit(block, entryPoint) {
171
173
  return {
172
174
  rows: 0,
173
175
  columns: tableGridColumnCount(block),
174
- columnWidthsPt: block.columnWidthsPt
176
+ columnWidthsPt: block.columns.map((column) => column.widthPt)
175
177
  };
176
178
  }
177
179
  function appendTable(body, block) {
@@ -1,7 +1,7 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
2
2
  import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
3
3
  import { t as OdtList } from "../../list-C_UPIZWM.cjs";
4
- import { o as TableInit, r as OdtTable } from "../../table-Bt9ahRyh.cjs";
4
+ import { o as TableInit, r as OdtTable } from "../../table-DrE6jEWv.cjs";
5
5
  import { Box, ContentControlDescriptor, ContentFormula, ContentVector, DivisionDescriptor, LayoutMetadata } from "document-schema.js";
6
6
  import { Package } from "odf.js";
7
7
  //#region src/edit/odt/editor.d.ts
@@ -1,7 +1,7 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.js";
2
2
  import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-D4f705GG.js";
3
3
  import { t as OdtList } from "../../list-C2GWIe6E.js";
4
- import { o as TableInit, r as OdtTable } from "../../table-Cou5rKOo.js";
4
+ import { o as TableInit, r as OdtTable } from "../../table-B5htMG3g.js";
5
5
  import { Box, ContentControlDescriptor, ContentFormula, ContentVector, DivisionDescriptor, LayoutMetadata } from "document-schema.js";
6
6
  import { Package } from "odf.js";
7
7
  //#region src/edit/odt/editor.d.ts
@@ -299,10 +299,7 @@ function placedCells(row, pkg) {
299
299
  function resolveOdtGrid(table, pkg) {
300
300
  const placedRows = [];
301
301
  let declaredColumns = 0;
302
- for (const child of table.children) {
303
- if (child.type !== "element") continue;
304
- if (child.tag === "table:table-column") declaredColumns += require_edit_odf_repeated_runs.readRunRepeatCount(child, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR);
305
- }
302
+ for (const column of tableColumnElements(table)) declaredColumns += require_edit_odf_repeated_runs.readRunRepeatCount(column, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR);
306
303
  for (const row of tableRowElements(table)) placedRows.push(placedCells(row, pkg));
307
304
  return require_edit_table_grid.resolveLiveTableGrid(placedRows, declaredColumns);
308
305
  }
@@ -403,6 +400,26 @@ function tableRowEntries(parent, insideHeader = false) {
403
400
  }
404
401
  return entries;
405
402
  }
403
+ const COLUMN_WRAPPER_TAGS = /* @__PURE__ */ new Set([
404
+ "table:table-columns",
405
+ "table:table-header-columns",
406
+ "table:table-column-group"
407
+ ]);
408
+ function tableColumnEntries(parent, insideHeader = false) {
409
+ const entries = [];
410
+ for (const child of parent.children) {
411
+ if (child.type !== "element") continue;
412
+ if (child.tag === "table:table-column") entries.push({
413
+ element: child,
414
+ insideHeader
415
+ });
416
+ else if (COLUMN_WRAPPER_TAGS.has(child.tag)) entries.push(...tableColumnEntries(child, insideHeader || child.tag === "table:table-header-columns"));
417
+ }
418
+ return entries;
419
+ }
420
+ function tableColumnElements(table) {
421
+ return tableColumnEntries(table).map((entry) => entry.element);
422
+ }
406
423
  var OdtTableRow = class {
407
424
  node;
408
425
  pkg;
@@ -529,6 +546,44 @@ var OdtTable = class {
529
546
  if (!placed) rest.push(...regrouped);
530
547
  table.children = rest;
531
548
  }
549
+ headerColumns() {
550
+ return tableColumnEntries(this.live()).map((entry) => entry.insideHeader);
551
+ }
552
+ setHeaderColumns(flags) {
553
+ const table = this.live();
554
+ const columns = tableColumnElements(table);
555
+ const regrouped = [];
556
+ let run = [];
557
+ const closeRun = () => {
558
+ if (run.length > 0) {
559
+ regrouped.push(require_xml_fragment.el("table:table-header-columns", {}, run));
560
+ run = [];
561
+ }
562
+ };
563
+ columns.forEach((column, index) => {
564
+ if (flags[index] === true) {
565
+ run.push(column);
566
+ return;
567
+ }
568
+ closeRun();
569
+ regrouped.push(column);
570
+ });
571
+ closeRun();
572
+ const rest = [];
573
+ let placed = false;
574
+ for (const child of table.children) {
575
+ if (!(child.type === "element" && (child.tag === "table:table-column" || COLUMN_WRAPPER_TAGS.has(child.tag)))) {
576
+ rest.push(child);
577
+ continue;
578
+ }
579
+ if (!placed) {
580
+ rest.push(...regrouped);
581
+ placed = true;
582
+ }
583
+ }
584
+ if (!placed) rest.push(...regrouped);
585
+ table.children = rest;
586
+ }
532
587
  gridRows() {
533
588
  return this.grid().rows;
534
589
  }
@@ -1,2 +1,2 @@
1
- import { a as OdtTableRow, c as buildTable, i as OdtTableCell, l as readCellDecoration, n as OdtCoveredTableCell, o as TableInit, r as OdtTable, s as buildCellStyle, t as CellDecoration } from "../../table-Bt9ahRyh.cjs";
1
+ import { a as OdtTableRow, c as buildTable, i as OdtTableCell, l as readCellDecoration, n as OdtCoveredTableCell, o as TableInit, r as OdtTable, s as buildCellStyle, t as CellDecoration } from "../../table-DrE6jEWv.cjs";
2
2
  export { CellDecoration, OdtCoveredTableCell, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
@@ -1,2 +1,2 @@
1
- import { a as OdtTableRow, c as buildTable, i as OdtTableCell, l as readCellDecoration, n as OdtCoveredTableCell, o as TableInit, r as OdtTable, s as buildCellStyle, t as CellDecoration } from "../../table-Cou5rKOo.js";
1
+ import { a as OdtTableRow, c as buildTable, i as OdtTableCell, l as readCellDecoration, n as OdtCoveredTableCell, o as TableInit, r as OdtTable, s as buildCellStyle, t as CellDecoration } from "../../table-B5htMG3g.js";
2
2
  export { CellDecoration, OdtCoveredTableCell, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };