js.documents 1.71.0 → 1.73.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.
@@ -74,6 +74,21 @@ var DocxTableRow = class {
74
74
  for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") out.push(new DocxTableCell(child));
75
75
  return out;
76
76
  }
77
+ mergeCellsHorizontally(startColumnIndex, colSpan) {
78
+ if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
79
+ const cellElements = [];
80
+ for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") cellElements.push(child);
81
+ const anchorElement = cellElements[startColumnIndex];
82
+ if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
83
+ if (startColumnIndex + colSpan > cellElements.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${cellElements.length} columns`);
84
+ for (let i = 1; i < colSpan; i++) {
85
+ const consumedElement = cellElements[startColumnIndex + i];
86
+ if (consumedElement !== void 0) require_xml_edit.removeChild(this.node.children, consumedElement);
87
+ }
88
+ const anchor = new DocxTableCell(anchorElement);
89
+ anchor.colSpan = colSpan;
90
+ return anchor;
91
+ }
77
92
  };
78
93
  function buildCell() {
79
94
  return require_xml_fragment.el("w:tc", {}, [require_edit_docx_paragraph.buildParagraph()]);
@@ -110,6 +125,23 @@ var DocxTable = class {
110
125
  node.children.push(row);
111
126
  return new DocxTableRow(row);
112
127
  }
128
+ mergeCells(startRow, startColumn, rowSpan, colSpan) {
129
+ if (!Number.isInteger(rowSpan) || rowSpan < 1 || !Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCells: rowSpan and colSpan must be positive integers, got rowSpan=${rowSpan}, colSpan=${colSpan}`);
130
+ const rows = this.rows();
131
+ const anchorRow = rows[startRow];
132
+ if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
133
+ const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
134
+ if (rowSpan > 1) {
135
+ anchor.verticalMerge = "restart";
136
+ for (let r = 1; r < rowSpan; r++) {
137
+ const coveredRow = rows[startRow + r];
138
+ if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
139
+ const coveredAnchor = coveredRow.mergeCellsHorizontally(startColumn, colSpan);
140
+ coveredAnchor.verticalMerge = "continue";
141
+ }
142
+ }
143
+ return anchor;
144
+ }
113
145
  remove() {
114
146
  require_xml_edit.removeChild(this.container, this.live());
115
147
  this.removed = true;
@@ -23,6 +23,7 @@ declare class DocxTableRow {
23
23
  private readonly node;
24
24
  constructor(node: XmlElement);
25
25
  cells(): DocxTableCell[];
26
+ mergeCellsHorizontally(startColumnIndex: number, colSpan: number): DocxTableCell;
26
27
  }
27
28
  declare class DocxTable {
28
29
  private readonly container;
@@ -33,6 +34,7 @@ declare class DocxTable {
33
34
  rows(): DocxTableRow[];
34
35
  cell(rowIndex: number, columnIndex: number): DocxTableCell;
35
36
  appendRow(columnCount: number): DocxTableRow;
37
+ mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): DocxTableCell;
36
38
  remove(): void;
37
39
  }
38
40
  declare function buildTable(init: TableInit): XmlElement;
@@ -23,6 +23,7 @@ declare class DocxTableRow {
23
23
  private readonly node;
24
24
  constructor(node: XmlElement);
25
25
  cells(): DocxTableCell[];
26
+ mergeCellsHorizontally(startColumnIndex: number, colSpan: number): DocxTableCell;
26
27
  }
27
28
  declare class DocxTable {
28
29
  private readonly container;
@@ -33,6 +34,7 @@ declare class DocxTable {
33
34
  rows(): DocxTableRow[];
34
35
  cell(rowIndex: number, columnIndex: number): DocxTableCell;
35
36
  appendRow(columnCount: number): DocxTableRow;
37
+ mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): DocxTableCell;
36
38
  remove(): void;
37
39
  }
38
40
  declare function buildTable(init: TableInit): XmlElement;
@@ -73,6 +73,21 @@ var DocxTableRow = class {
73
73
  for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") out.push(new DocxTableCell(child));
74
74
  return out;
75
75
  }
76
+ mergeCellsHorizontally(startColumnIndex, colSpan) {
77
+ if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
78
+ const cellElements = [];
79
+ for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") cellElements.push(child);
80
+ const anchorElement = cellElements[startColumnIndex];
81
+ if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
82
+ if (startColumnIndex + colSpan > cellElements.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${cellElements.length} columns`);
83
+ for (let i = 1; i < colSpan; i++) {
84
+ const consumedElement = cellElements[startColumnIndex + i];
85
+ if (consumedElement !== void 0) removeChild(this.node.children, consumedElement);
86
+ }
87
+ const anchor = new DocxTableCell(anchorElement);
88
+ anchor.colSpan = colSpan;
89
+ return anchor;
90
+ }
76
91
  };
77
92
  function buildCell() {
78
93
  return el("w:tc", {}, [buildParagraph()]);
@@ -109,6 +124,23 @@ var DocxTable = class {
109
124
  node.children.push(row);
110
125
  return new DocxTableRow(row);
111
126
  }
127
+ mergeCells(startRow, startColumn, rowSpan, colSpan) {
128
+ if (!Number.isInteger(rowSpan) || rowSpan < 1 || !Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCells: rowSpan and colSpan must be positive integers, got rowSpan=${rowSpan}, colSpan=${colSpan}`);
129
+ const rows = this.rows();
130
+ const anchorRow = rows[startRow];
131
+ if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
132
+ const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
133
+ if (rowSpan > 1) {
134
+ anchor.verticalMerge = "restart";
135
+ for (let r = 1; r < rowSpan; r++) {
136
+ const coveredRow = rows[startRow + r];
137
+ if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
138
+ const coveredAnchor = coveredRow.mergeCellsHorizontally(startColumn, colSpan);
139
+ coveredAnchor.verticalMerge = "continue";
140
+ }
141
+ }
142
+ return anchor;
143
+ }
112
144
  remove() {
113
145
  removeChild(this.container, this.live());
114
146
  this.removed = true;
@@ -45,7 +45,7 @@ var OdpSlide = class {
45
45
  shapes() {
46
46
  const node = this.live();
47
47
  const out = [];
48
- for (const child of node.children) if (child.type === "element" && child.tag === "draw:frame") out.push(new require_edit_odp_shape.OdpShape(node.children, child, this.context.pkg));
48
+ for (const child of node.children) if (child.type === "element" && child.tag === "draw:frame" && directChild(child, "table:table") === void 0) out.push(new require_edit_odp_shape.OdpShape(node.children, child, this.context.pkg));
49
49
  return out;
50
50
  }
51
51
  addTextBox(init) {
@@ -71,6 +71,20 @@ var OdpSlide = class {
71
71
  table: new require_edit_odt_table.OdtTable(frameElement.children, tableElement, this.context.pkg)
72
72
  };
73
73
  }
74
+ tables() {
75
+ const node = this.live();
76
+ const out = [];
77
+ for (const child of node.children) {
78
+ if (child.type !== "element" || child.tag !== "draw:frame") continue;
79
+ const tableElement = directChild(child, "table:table");
80
+ if (tableElement === void 0) continue;
81
+ out.push({
82
+ shape: new require_edit_odp_shape.OdpShape(node.children, child, this.context.pkg),
83
+ table: new require_edit_odt_table.OdtTable(child.children, tableElement, this.context.pkg)
84
+ });
85
+ }
86
+ return out;
87
+ }
74
88
  addVector(vector) {
75
89
  return require_edit_odg_vector.appendVectorTo(this.live().children, this.context.pkg, vector);
76
90
  }
@@ -2,7 +2,7 @@ import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
2
2
  import { t as ImageInit } from "../../image-M5SezZVI.cjs";
3
3
  import { t as OdpShape } from "../../shape-BR8GL8XC.cjs";
4
4
  import { s as OdgVector } from "../../vector-D03KX8Ux.cjs";
5
- import { i as TableInit, t as OdtTable } from "../../table-sEo1Jf8c.cjs";
5
+ import { i as TableInit, t as OdtTable } from "../../table-DSFcqJ7C.cjs";
6
6
  import { ContentVector } from "document-schema.js";
7
7
  import { Package, XmlElement, XmlNode } from "odf.js";
8
8
  //#region src/edit/odp/slide.d.ts
@@ -35,6 +35,7 @@ declare class OdpSlide {
35
35
  addTextBox(init: TextBoxInit): OdpShape;
36
36
  addImage(init: SlideImageInit): OdpShape;
37
37
  addTable(init: SlideTableInit): OdpTableShape;
38
+ tables(): OdpTableShape[];
38
39
  addVector(vector: ContentVector): OdgVector;
39
40
  get notes(): string;
40
41
  set notes(value: string);
@@ -2,7 +2,7 @@ import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
2
2
  import { t as ImageInit } from "../../image-DHcA9kaK.js";
3
3
  import { t as OdpShape } from "../../shape-DeP-P4Nh.js";
4
4
  import { s as OdgVector } from "../../vector-D03KX8Ux.js";
5
- import { i as TableInit, t as OdtTable } from "../../table-kvclAXS5.js";
5
+ import { i as TableInit, t as OdtTable } from "../../table-AT4t4VUy.js";
6
6
  import { ContentVector } from "document-schema.js";
7
7
  import { Package, XmlElement, XmlNode } from "odf.js";
8
8
  //#region src/edit/odp/slide.d.ts
@@ -35,6 +35,7 @@ declare class OdpSlide {
35
35
  addTextBox(init: TextBoxInit): OdpShape;
36
36
  addImage(init: SlideImageInit): OdpShape;
37
37
  addTable(init: SlideTableInit): OdpTableShape;
38
+ tables(): OdpTableShape[];
38
39
  addVector(vector: ContentVector): OdgVector;
39
40
  get notes(): string;
40
41
  set notes(value: string);
@@ -44,7 +44,7 @@ var OdpSlide = class {
44
44
  shapes() {
45
45
  const node = this.live();
46
46
  const out = [];
47
- for (const child of node.children) if (child.type === "element" && child.tag === "draw:frame") out.push(new OdpShape(node.children, child, this.context.pkg));
47
+ for (const child of node.children) if (child.type === "element" && child.tag === "draw:frame" && directChild(child, "table:table") === void 0) out.push(new OdpShape(node.children, child, this.context.pkg));
48
48
  return out;
49
49
  }
50
50
  addTextBox(init) {
@@ -70,6 +70,20 @@ var OdpSlide = class {
70
70
  table: new OdtTable(frameElement.children, tableElement, this.context.pkg)
71
71
  };
72
72
  }
73
+ tables() {
74
+ const node = this.live();
75
+ const out = [];
76
+ for (const child of node.children) {
77
+ if (child.type !== "element" || child.tag !== "draw:frame") continue;
78
+ const tableElement = directChild(child, "table:table");
79
+ if (tableElement === void 0) continue;
80
+ out.push({
81
+ shape: new OdpShape(node.children, child, this.context.pkg),
82
+ table: new OdtTable(child.children, tableElement, this.context.pkg)
83
+ });
84
+ }
85
+ return out;
86
+ }
73
87
  addVector(vector) {
74
88
  return appendVectorTo(this.live().children, this.context.pkg, vector);
75
89
  }
@@ -1,6 +1,6 @@
1
1
  import { ClockPort } from "../../ports/clock.cjs";
2
2
  import { t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
3
- import { t as OdtTable } from "../../table-sEo1Jf8c.cjs";
3
+ import { t as OdtTable } from "../../table-DSFcqJ7C.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
@@ -1,6 +1,6 @@
1
1
  import { ClockPort } from "../../ports/clock.js";
2
2
  import { t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
3
- import { t as OdtTable } from "../../table-kvclAXS5.js";
3
+ import { t as OdtTable } from "../../table-AT4t4VUy.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
@@ -2,7 +2,7 @@ import { ClockPort } from "../../ports/clock.cjs";
2
2
  import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
3
3
  import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
4
4
  import { t as OdtList } from "../../list-DXRaCcT1.cjs";
5
- import { i as TableInit, t as OdtTable } from "../../table-sEo1Jf8c.cjs";
5
+ import { i as TableInit, t as OdtTable } from "../../table-DSFcqJ7C.cjs";
6
6
  import { ContentFormula, ContentVector } from "document-schema.js";
7
7
  import { Package } from "odf.js";
8
8
  //#region src/edit/odt/editor.d.ts
@@ -2,7 +2,7 @@ import { ClockPort } from "../../ports/clock.js";
2
2
  import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
3
3
  import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
4
4
  import { t as OdtList } from "../../list-7hZydHAV.js";
5
- import { i as TableInit, t as OdtTable } from "../../table-kvclAXS5.js";
5
+ import { i as TableInit, t as OdtTable } from "../../table-AT4t4VUy.js";
6
6
  import { ContentFormula, ContentVector } from "document-schema.js";
7
7
  import { Package } from "odf.js";
8
8
  //#region src/edit/odt/editor.d.ts
@@ -89,6 +89,37 @@ var OdtTableRow = class {
89
89
  appendCoveredCell() {
90
90
  this.node.children.push(require_xml_fragment.el("table:covered-table-cell"));
91
91
  }
92
+ gridCells() {
93
+ const out = [];
94
+ for (const child of this.node.children) if (child.type === "element" && (child.tag === "table:table-cell" || child.tag === "table:covered-table-cell")) out.push(child);
95
+ return out;
96
+ }
97
+ mergeCellsHorizontally(startColumnIndex, colSpan) {
98
+ if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
99
+ const gridCells = this.gridCells();
100
+ const anchorElement = gridCells[startColumnIndex];
101
+ if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
102
+ if (anchorElement.tag === "table:covered-table-cell") throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} is already covered by another merge -- address that merge's own anchor cell instead`);
103
+ if (startColumnIndex + colSpan > gridCells.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${gridCells.length} grid columns`);
104
+ for (let i = 1; i < colSpan; i++) {
105
+ const consumedElement = gridCells[startColumnIndex + i];
106
+ if (consumedElement !== void 0) {
107
+ consumedElement.tag = "table:covered-table-cell";
108
+ consumedElement.attributes = [];
109
+ consumedElement.children = [];
110
+ }
111
+ }
112
+ const anchor = new OdtTableCell(anchorElement, this.pkg);
113
+ anchor.colSpan = colSpan;
114
+ return anchor;
115
+ }
116
+ markCellCovered(columnIndex) {
117
+ const element = this.gridCells()[columnIndex];
118
+ if (element === void 0) throw new Error(`markCellCovered: column ${columnIndex} does not exist in this row`);
119
+ element.tag = "table:covered-table-cell";
120
+ element.attributes = [];
121
+ element.children = [];
122
+ }
92
123
  };
93
124
  function buildCell(pkg) {
94
125
  return require_xml_fragment.el("table:table-cell", {}, [require_edit_odt_paragraph.buildParagraph(pkg)]);
@@ -136,6 +167,22 @@ var OdtTable = class {
136
167
  node.children.push(row);
137
168
  return new OdtTableRow(row, this.pkg);
138
169
  }
170
+ mergeCells(startRow, startColumn, rowSpan, colSpan) {
171
+ if (!Number.isInteger(rowSpan) || rowSpan < 1 || !Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCells: rowSpan and colSpan must be positive integers, got rowSpan=${rowSpan}, colSpan=${colSpan}`);
172
+ const rows = this.rows();
173
+ const anchorRow = rows[startRow];
174
+ if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
175
+ const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
176
+ if (rowSpan > 1) {
177
+ anchor.rowSpan = rowSpan;
178
+ for (let r = 1; r < rowSpan; r++) {
179
+ const coveredRow = rows[startRow + r];
180
+ if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
181
+ for (let c = 0; c < colSpan; c++) coveredRow.markCellCovered(startColumn + c);
182
+ }
183
+ }
184
+ return anchor;
185
+ }
139
186
  remove() {
140
187
  require_xml_edit.removeChild(this.container, this.live());
141
188
  this.removed = true;
@@ -1,2 +1,2 @@
1
- import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-sEo1Jf8c.cjs";
1
+ import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-DSFcqJ7C.cjs";
2
2
  export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
@@ -1,2 +1,2 @@
1
- import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-kvclAXS5.js";
1
+ import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-AT4t4VUy.js";
2
2
  export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
@@ -88,6 +88,37 @@ var OdtTableRow = class {
88
88
  appendCoveredCell() {
89
89
  this.node.children.push(el("table:covered-table-cell"));
90
90
  }
91
+ gridCells() {
92
+ const out = [];
93
+ for (const child of this.node.children) if (child.type === "element" && (child.tag === "table:table-cell" || child.tag === "table:covered-table-cell")) out.push(child);
94
+ return out;
95
+ }
96
+ mergeCellsHorizontally(startColumnIndex, colSpan) {
97
+ if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
98
+ const gridCells = this.gridCells();
99
+ const anchorElement = gridCells[startColumnIndex];
100
+ if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
101
+ if (anchorElement.tag === "table:covered-table-cell") throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} is already covered by another merge -- address that merge's own anchor cell instead`);
102
+ if (startColumnIndex + colSpan > gridCells.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${gridCells.length} grid columns`);
103
+ for (let i = 1; i < colSpan; i++) {
104
+ const consumedElement = gridCells[startColumnIndex + i];
105
+ if (consumedElement !== void 0) {
106
+ consumedElement.tag = "table:covered-table-cell";
107
+ consumedElement.attributes = [];
108
+ consumedElement.children = [];
109
+ }
110
+ }
111
+ const anchor = new OdtTableCell(anchorElement, this.pkg);
112
+ anchor.colSpan = colSpan;
113
+ return anchor;
114
+ }
115
+ markCellCovered(columnIndex) {
116
+ const element = this.gridCells()[columnIndex];
117
+ if (element === void 0) throw new Error(`markCellCovered: column ${columnIndex} does not exist in this row`);
118
+ element.tag = "table:covered-table-cell";
119
+ element.attributes = [];
120
+ element.children = [];
121
+ }
91
122
  };
92
123
  function buildCell(pkg) {
93
124
  return el("table:table-cell", {}, [buildParagraph(pkg)]);
@@ -135,6 +166,22 @@ var OdtTable = class {
135
166
  node.children.push(row);
136
167
  return new OdtTableRow(row, this.pkg);
137
168
  }
169
+ mergeCells(startRow, startColumn, rowSpan, colSpan) {
170
+ if (!Number.isInteger(rowSpan) || rowSpan < 1 || !Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCells: rowSpan and colSpan must be positive integers, got rowSpan=${rowSpan}, colSpan=${colSpan}`);
171
+ const rows = this.rows();
172
+ const anchorRow = rows[startRow];
173
+ if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
174
+ const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
175
+ if (rowSpan > 1) {
176
+ anchor.rowSpan = rowSpan;
177
+ for (let r = 1; r < rowSpan; r++) {
178
+ const coveredRow = rows[startRow + r];
179
+ if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
180
+ for (let c = 0; c < colSpan; c++) coveredRow.markCellCovered(startColumn + c);
181
+ }
182
+ }
183
+ return anchor;
184
+ }
138
185
  remove() {
139
186
  removeChild(this.container, this.live());
140
187
  this.removed = true;
@@ -92,6 +92,16 @@ var PptxSlide = class {
92
92
  for (const child of spTree.children) if (child.type === "element" && (child.tag === "p:sp" || child.tag === "p:pic")) out.push(new require_edit_pptx_shape.PptxShape(spTree.children, child));
93
93
  return out;
94
94
  }
95
+ tables() {
96
+ const spTree = findSpTree(this.live());
97
+ const out = [];
98
+ for (const child of spTree.children) {
99
+ if (child.type !== "element" || child.tag !== "p:graphicFrame") continue;
100
+ const tableElement = require_edit_pptx_table.findGraphicFrameTable(child);
101
+ if (tableElement !== void 0) out.push(new require_edit_pptx_table.PptxTable(tableElement));
102
+ }
103
+ return out;
104
+ }
95
105
  addTextBox(init) {
96
106
  const spTree = findSpTree(this.live());
97
107
  const id = nextIdIn(spTree);
@@ -1,7 +1,7 @@
1
1
  import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
2
2
  import { t as ImageInit } from "../../image-7snmKIxn.cjs";
3
3
  import { r as PptxShape } from "../../shape-BhkP6HB8.cjs";
4
- import { r as PptxTableInit, t as PptxTable } from "../../table-C3CPZ--2.cjs";
4
+ import { r as PptxTableInit, t as PptxTable } from "../../table-CfRjVOFN.cjs";
5
5
  import { ContentVector } from "document-schema.js";
6
6
  import { Package, XmlElement, XmlNode } from "ooxml.js";
7
7
  //#region src/edit/pptx/slide.d.ts
@@ -30,6 +30,7 @@ declare class PptxSlide {
30
30
  constructor(container: XmlNode[], node: XmlElement, context: SlideContext);
31
31
  private live;
32
32
  shapes(): PptxShape[];
33
+ tables(): PptxTable[];
33
34
  addTextBox(init: TextBoxInit): PptxShape;
34
35
  addVector(vector: ContentVector): PptxShape;
35
36
  addImage(init: SlideImageInit): PptxShape;
@@ -1,7 +1,7 @@
1
1
  import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
2
2
  import { t as ImageInit } from "../../image-Cs8xF753.js";
3
3
  import { r as PptxShape } from "../../shape-BjX3wlig.js";
4
- import { r as PptxTableInit, t as PptxTable } from "../../table-Db91eorq.js";
4
+ import { r as PptxTableInit, t as PptxTable } from "../../table-L5SxKy8_.js";
5
5
  import { Package, XmlElement, XmlNode } from "ooxml.js";
6
6
  import { ContentVector } from "document-schema.js";
7
7
  //#region src/edit/pptx/slide.d.ts
@@ -30,6 +30,7 @@ declare class PptxSlide {
30
30
  constructor(container: XmlNode[], node: XmlElement, context: SlideContext);
31
31
  private live;
32
32
  shapes(): PptxShape[];
33
+ tables(): PptxTable[];
33
34
  addTextBox(init: TextBoxInit): PptxShape;
34
35
  addVector(vector: ContentVector): PptxShape;
35
36
  addImage(init: SlideImageInit): PptxShape;
@@ -7,7 +7,7 @@ import { ensureContentTypeOverride } from "../../opc/content-types.js";
7
7
  import { DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, buildEmptyGroupSpTree, ensureNotesMaster } from "./scaffold.js";
8
8
  import { PptxShape, buildTextBoxShape } from "./shape.js";
9
9
  import { insertPictureShapeMedia } from "./image.js";
10
- import { PptxTable, buildDrawingTable, buildTableGraphicFrame } from "./table.js";
10
+ import { PptxTable, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable } from "./table.js";
11
11
  import { buildVectorShape } from "./vector.js";
12
12
  import { resolveRelationships, rootElement, textContent } from "ooxml.js";
13
13
  //#region src/edit/pptx/slide.ts
@@ -91,6 +91,16 @@ var PptxSlide = class {
91
91
  for (const child of spTree.children) if (child.type === "element" && (child.tag === "p:sp" || child.tag === "p:pic")) out.push(new PptxShape(spTree.children, child));
92
92
  return out;
93
93
  }
94
+ tables() {
95
+ const spTree = findSpTree(this.live());
96
+ const out = [];
97
+ for (const child of spTree.children) {
98
+ if (child.type !== "element" || child.tag !== "p:graphicFrame") continue;
99
+ const tableElement = findGraphicFrameTable(child);
100
+ if (tableElement !== void 0) out.push(new PptxTable(tableElement));
101
+ }
102
+ return out;
103
+ }
94
104
  addTextBox(init) {
95
105
  const spTree = findSpTree(this.live());
96
106
  const id = nextIdIn(spTree);
@@ -128,9 +128,16 @@ function buildTableGraphicFrame(frame, tableElement, shapeId, rotationDeg) {
128
128
  require_xml_fragment.el("a:graphic", {}, [require_xml_fragment.el("a:graphicData", { uri: TABLE_GRAPHIC_URI }, [tableElement])])
129
129
  ]);
130
130
  }
131
+ function findGraphicFrameTable(graphicFrame) {
132
+ const graphic = require_xml_edit.directChildElement(graphicFrame, "a:graphic");
133
+ const graphicData = graphic === void 0 ? void 0 : require_xml_edit.directChildElement(graphic, "a:graphicData");
134
+ if (graphicData === void 0 || (0, ooxml_js.attr)(graphicData, "uri") !== TABLE_GRAPHIC_URI) return;
135
+ return require_xml_edit.directChildElement(graphicData, "a:tbl");
136
+ }
131
137
  //#endregion
132
138
  exports.PptxTable = PptxTable;
133
139
  exports.PptxTableCell = PptxTableCell;
134
140
  exports.PptxTableRow = PptxTableRow;
135
141
  exports.buildDrawingTable = buildDrawingTable;
136
142
  exports.buildTableGraphicFrame = buildTableGraphicFrame;
143
+ exports.findGraphicFrameTable = findGraphicFrameTable;
@@ -1,2 +1,2 @@
1
- import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, t as PptxTable } from "../../table-C3CPZ--2.cjs";
2
- export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame };
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-CfRjVOFN.cjs";
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, t as PptxTable } from "../../table-Db91eorq.js";
2
- export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame };
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-L5SxKy8_.js";
2
+ export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable };
@@ -127,5 +127,11 @@ function buildTableGraphicFrame(frame, tableElement, shapeId, rotationDeg) {
127
127
  el("a:graphic", {}, [el("a:graphicData", { uri: TABLE_GRAPHIC_URI }, [tableElement])])
128
128
  ]);
129
129
  }
130
+ function findGraphicFrameTable(graphicFrame) {
131
+ const graphic = directChildElement(graphicFrame, "a:graphic");
132
+ const graphicData = graphic === void 0 ? void 0 : directChildElement(graphic, "a:graphicData");
133
+ if (graphicData === void 0 || attr(graphicData, "uri") !== TABLE_GRAPHIC_URI) return;
134
+ return directChildElement(graphicData, "a:tbl");
135
+ }
130
136
  //#endregion
131
- export { PptxTable, PptxTableCell, PptxTableRow, buildDrawingTable, buildTableGraphicFrame };
137
+ export { PptxTable, PptxTableCell, PptxTableRow, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable };
package/dist/index.d.cts CHANGED
@@ -28,7 +28,7 @@ import { OdgPage, PageImageInit, TextBoxInit } from "./edit/odg/page.cjs";
28
28
  import { CreateOdgOptions, OdgEditor, createOdg, openOdg } from "./edit/odg/editor.cjs";
29
29
  import { CreateEmptyOdgPackageOptions } from "./edit/odg/scaffold.cjs";
30
30
  import { BuildOdpPackageOptions, buildOdpPackage } from "./edit/odp/content.cjs";
31
- import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-sEo1Jf8c.cjs";
31
+ import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-DSFcqJ7C.cjs";
32
32
  import { OdpSlide, SlideImageInit, SlideTableInit, TextBoxInit as TextBoxInit$1 } from "./edit/odp/slide.cjs";
33
33
  import { CreateOdpOptions, OdpEditor, createOdp, openOdp } from "./edit/odp/editor.cjs";
34
34
  import { CreateEmptyOdpPackageOptions } from "./edit/odp/scaffold.cjs";
@@ -42,7 +42,7 @@ import { CreateOdtOptions, OdtBody, OdtEditor, createOdt, openOdt } from "./edit
42
42
  import { CreateEmptyOdtPackageOptions } from "./edit/odt/scaffold.cjs";
43
43
  import { BuildPptxPackageOptions, buildPptxPackage } from "./edit/pptx/content.cjs";
44
44
  import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-BhkP6HB8.cjs";
45
- import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-C3CPZ--2.cjs";
45
+ import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-CfRjVOFN.cjs";
46
46
  import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.cjs";
47
47
  import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.cjs";
48
48
  import { CreateEmptyPptxPackageOptions } from "./edit/pptx/scaffold.cjs";
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ import { OdgPage, PageImageInit, TextBoxInit } from "./edit/odg/page.js";
28
28
  import { CreateOdgOptions, OdgEditor, createOdg, openOdg } from "./edit/odg/editor.js";
29
29
  import { CreateEmptyOdgPackageOptions } from "./edit/odg/scaffold.js";
30
30
  import { BuildOdpPackageOptions, buildOdpPackage } from "./edit/odp/content.js";
31
- import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-kvclAXS5.js";
31
+ import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-AT4t4VUy.js";
32
32
  import { OdpSlide, SlideImageInit, SlideTableInit, TextBoxInit as TextBoxInit$1 } from "./edit/odp/slide.js";
33
33
  import { CreateOdpOptions, OdpEditor, createOdp, openOdp } from "./edit/odp/editor.js";
34
34
  import { CreateEmptyOdpPackageOptions } from "./edit/odp/scaffold.js";
@@ -42,7 +42,7 @@ import { CreateOdtOptions, OdtBody, OdtEditor, createOdt, openOdt } from "./edit
42
42
  import { CreateEmptyOdtPackageOptions } from "./edit/odt/scaffold.js";
43
43
  import { BuildPptxPackageOptions, buildPptxPackage } from "./edit/pptx/content.js";
44
44
  import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-BjX3wlig.js";
45
- import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-Db91eorq.js";
45
+ import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-L5SxKy8_.js";
46
46
  import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.js";
47
47
  import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.js";
48
48
  import { CreateEmptyPptxPackageOptions } from "./edit/pptx/scaffold.js";
@@ -25,6 +25,9 @@ declare class OdtTableRow {
25
25
  cells(): OdtTableCell[];
26
26
  appendCell(): OdtTableCell;
27
27
  appendCoveredCell(): void;
28
+ private gridCells;
29
+ mergeCellsHorizontally(startColumnIndex: number, colSpan: number): OdtTableCell;
30
+ markCellCovered(columnIndex: number): void;
28
31
  }
29
32
  declare class OdtTable {
30
33
  private readonly container;
@@ -37,6 +40,7 @@ declare class OdtTable {
37
40
  cell(rowIndex: number, columnIndex: number): OdtTableCell;
38
41
  appendRow(columnCount: number): OdtTableRow;
39
42
  appendEmptyRow(): OdtTableRow;
43
+ mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): OdtTableCell;
40
44
  remove(): void;
41
45
  }
42
46
  declare function buildTable(pkg: Package, init: TableInit): XmlElement;
@@ -31,5 +31,6 @@ declare class PptxTable {
31
31
  }
32
32
  declare function buildDrawingTable(init: PptxTableInit): XmlElement;
33
33
  declare function buildTableGraphicFrame(frame: Box, tableElement: XmlElement, shapeId: number, rotationDeg: number | undefined): XmlElement;
34
+ declare function findGraphicFrameTable(graphicFrame: XmlElement): XmlElement | undefined;
34
35
  //#endregion
35
- export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, PptxTable as t };
36
+ export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, findGraphicFrameTable as s, PptxTable as t };
@@ -25,6 +25,9 @@ declare class OdtTableRow {
25
25
  cells(): OdtTableCell[];
26
26
  appendCell(): OdtTableCell;
27
27
  appendCoveredCell(): void;
28
+ private gridCells;
29
+ mergeCellsHorizontally(startColumnIndex: number, colSpan: number): OdtTableCell;
30
+ markCellCovered(columnIndex: number): void;
28
31
  }
29
32
  declare class OdtTable {
30
33
  private readonly container;
@@ -37,6 +40,7 @@ declare class OdtTable {
37
40
  cell(rowIndex: number, columnIndex: number): OdtTableCell;
38
41
  appendRow(columnCount: number): OdtTableRow;
39
42
  appendEmptyRow(): OdtTableRow;
43
+ mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): OdtTableCell;
40
44
  remove(): void;
41
45
  }
42
46
  declare function buildTable(pkg: Package, init: TableInit): XmlElement;
@@ -31,5 +31,6 @@ declare class PptxTable {
31
31
  }
32
32
  declare function buildDrawingTable(init: PptxTableInit): XmlElement;
33
33
  declare function buildTableGraphicFrame(frame: Box, tableElement: XmlElement, shapeId: number, rotationDeg: number | undefined): XmlElement;
34
+ declare function findGraphicFrameTable(graphicFrame: XmlElement): XmlElement | undefined;
34
35
  //#endregion
35
- export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, PptxTable as t };
36
+ export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, findGraphicFrameTable as s, PptxTable as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "1.71.0",
3
+ "version": "1.73.0",
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": {