js.documents 6.3.2 → 6.3.4

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.
@@ -181,10 +181,18 @@ function findCellRegions(rowLines, columnLines) {
181
181
  if (cellsByRoot.size <= 1) return;
182
182
  const regions = [];
183
183
  for (const cells of cellsByRoot.values()) {
184
- const rowStart = Math.min(...cells.map((c) => c.row));
185
- const rowEnd = Math.max(...cells.map((c) => c.row)) + 1;
186
- const colStart = Math.min(...cells.map((c) => c.col));
187
- const colEnd = Math.max(...cells.map((c) => c.col)) + 1;
184
+ let rowStart = cells[0].row;
185
+ let rowEnd = cells[0].row;
186
+ let colStart = cells[0].col;
187
+ let colEnd = cells[0].col;
188
+ for (const cell of cells) {
189
+ rowStart = Math.min(rowStart, cell.row);
190
+ rowEnd = Math.max(rowEnd, cell.row);
191
+ colStart = Math.min(colStart, cell.col);
192
+ colEnd = Math.max(colEnd, cell.col);
193
+ }
194
+ rowEnd += 1;
195
+ colEnd += 1;
188
196
  if (cells.length !== (rowEnd - rowStart) * (colEnd - colStart)) return;
189
197
  regions.push({
190
198
  rowStart,
@@ -235,5 +243,6 @@ function findColumnIndex(columnBoundariesAscPt, xPt) {
235
243
  //#endregion
236
244
  exports.detectGridLattice = detectGridLattice;
237
245
  exports.extractLineCandidates = extractLineCandidates;
246
+ exports.findCellRegions = findCellRegions;
238
247
  exports.findColumnIndex = findColumnIndex;
239
248
  exports.findRowIndex = findRowIndex;
@@ -8,12 +8,22 @@ interface LineSegment {
8
8
  readonly y2Pt: number;
9
9
  }
10
10
  declare function extractLineCandidates(items: readonly LayoutItem[]): LineSegment[];
11
+ interface Range {
12
+ readonly startPt: number;
13
+ readonly endPt: number;
14
+ }
15
+ interface AxisLine {
16
+ readonly position: number;
17
+ readonly ranges: readonly Range[];
18
+ readonly items: readonly LayoutItem[];
19
+ }
11
20
  interface TableRegion {
12
21
  readonly rowStart: number;
13
22
  readonly rowEnd: number;
14
23
  readonly colStart: number;
15
24
  readonly colEnd: number;
16
25
  }
26
+ declare function findCellRegions(rowLines: readonly AxisLine[], columnLines: readonly AxisLine[]): TableRegion[] | undefined;
17
27
  interface GridLattice {
18
28
  readonly rowBoundariesDescPt: readonly number[];
19
29
  readonly columnBoundariesAscPt: readonly number[];
@@ -24,4 +34,4 @@ declare function detectGridLattice(items: readonly LayoutItem[]): GridLattice |
24
34
  declare function findRowIndex(rowBoundariesDescPt: readonly number[], yPt: number): number | undefined;
25
35
  declare function findColumnIndex(columnBoundariesAscPt: readonly number[], xPt: number): number | undefined;
26
36
  //#endregion
27
- export { GridLattice, LineSegment, TableRegion, detectGridLattice, extractLineCandidates, findColumnIndex, findRowIndex };
37
+ export { GridLattice, LineSegment, TableRegion, detectGridLattice, extractLineCandidates, findCellRegions, findColumnIndex, findRowIndex };
@@ -8,12 +8,22 @@ interface LineSegment {
8
8
  readonly y2Pt: number;
9
9
  }
10
10
  declare function extractLineCandidates(items: readonly LayoutItem[]): LineSegment[];
11
+ interface Range {
12
+ readonly startPt: number;
13
+ readonly endPt: number;
14
+ }
15
+ interface AxisLine {
16
+ readonly position: number;
17
+ readonly ranges: readonly Range[];
18
+ readonly items: readonly LayoutItem[];
19
+ }
11
20
  interface TableRegion {
12
21
  readonly rowStart: number;
13
22
  readonly rowEnd: number;
14
23
  readonly colStart: number;
15
24
  readonly colEnd: number;
16
25
  }
26
+ declare function findCellRegions(rowLines: readonly AxisLine[], columnLines: readonly AxisLine[]): TableRegion[] | undefined;
17
27
  interface GridLattice {
18
28
  readonly rowBoundariesDescPt: readonly number[];
19
29
  readonly columnBoundariesAscPt: readonly number[];
@@ -24,4 +34,4 @@ declare function detectGridLattice(items: readonly LayoutItem[]): GridLattice |
24
34
  declare function findRowIndex(rowBoundariesDescPt: readonly number[], yPt: number): number | undefined;
25
35
  declare function findColumnIndex(columnBoundariesAscPt: readonly number[], xPt: number): number | undefined;
26
36
  //#endregion
27
- export { GridLattice, LineSegment, TableRegion, detectGridLattice, extractLineCandidates, findColumnIndex, findRowIndex };
37
+ export { GridLattice, LineSegment, TableRegion, detectGridLattice, extractLineCandidates, findCellRegions, findColumnIndex, findRowIndex };
@@ -180,10 +180,18 @@ function findCellRegions(rowLines, columnLines) {
180
180
  if (cellsByRoot.size <= 1) return;
181
181
  const regions = [];
182
182
  for (const cells of cellsByRoot.values()) {
183
- const rowStart = Math.min(...cells.map((c) => c.row));
184
- const rowEnd = Math.max(...cells.map((c) => c.row)) + 1;
185
- const colStart = Math.min(...cells.map((c) => c.col));
186
- const colEnd = Math.max(...cells.map((c) => c.col)) + 1;
183
+ let rowStart = cells[0].row;
184
+ let rowEnd = cells[0].row;
185
+ let colStart = cells[0].col;
186
+ let colEnd = cells[0].col;
187
+ for (const cell of cells) {
188
+ rowStart = Math.min(rowStart, cell.row);
189
+ rowEnd = Math.max(rowEnd, cell.row);
190
+ colStart = Math.min(colStart, cell.col);
191
+ colEnd = Math.max(colEnd, cell.col);
192
+ }
193
+ rowEnd += 1;
194
+ colEnd += 1;
187
195
  if (cells.length !== (rowEnd - rowStart) * (colEnd - colStart)) return;
188
196
  regions.push({
189
197
  rowStart,
@@ -232,4 +240,4 @@ function findColumnIndex(columnBoundariesAscPt, xPt) {
232
240
  return lastIndex - 1;
233
241
  }
234
242
  //#endregion
235
- export { detectGridLattice, extractLineCandidates, findColumnIndex, findRowIndex };
243
+ export { detectGridLattice, extractLineCandidates, findCellRegions, findColumnIndex, findRowIndex };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "6.3.2",
3
+ "version": "6.3.4",
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": {
@@ -82,7 +82,7 @@
82
82
  "fflate": "^0.8.3",
83
83
  "markdown-codec": "^6.1.3",
84
84
  "odf.js": "^6.2.0",
85
- "ooxml.js": "^6.3.1",
85
+ "ooxml.js": "^6.3.2",
86
86
  "pdf-codec": "^3.6.1",
87
87
  "rtf-codec": "^1.0.0",
88
88
  "temml": "0.13.4",