@file-viewer/renderer-spreadsheet 2.0.11 → 2.1.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.
@@ -20,6 +20,23 @@ const toErrorResponse = (error, payload = {}) => ({
20
20
  message: error instanceof Error ? error.message : String(error),
21
21
  },
22
22
  });
23
+ const getDrawingBounds = (worksheet) => {
24
+ var _a;
25
+ const images = ((_a = worksheet === null || worksheet === void 0 ? void 0 : worksheet['!drawings']) === null || _a === void 0 ? void 0 : _a.images) || [];
26
+ return images.reduce((bounds, image) => {
27
+ var _a, _b, _c, _d, _e, _f;
28
+ const anchor = image.anchor;
29
+ const row = Number((_b = (_a = anchor === null || anchor === void 0 ? void 0 : anchor.to) === null || _a === void 0 ? void 0 : _a.row) !== null && _b !== void 0 ? _b : (_c = anchor === null || anchor === void 0 ? void 0 : anchor.from) === null || _c === void 0 ? void 0 : _c.row);
30
+ const col = Number((_e = (_d = anchor === null || anchor === void 0 ? void 0 : anchor.to) === null || _d === void 0 ? void 0 : _d.col) !== null && _e !== void 0 ? _e : (_f = anchor === null || anchor === void 0 ? void 0 : anchor.from) === null || _f === void 0 ? void 0 : _f.col);
31
+ return {
32
+ rowCount: Number.isFinite(row) ? Math.max(bounds.rowCount, row + 1) : bounds.rowCount,
33
+ colCount: Number.isFinite(col) ? Math.max(bounds.colCount, col + 1) : bounds.colCount,
34
+ };
35
+ }, {
36
+ rowCount: 0,
37
+ colCount: 0,
38
+ });
39
+ };
23
40
  const parseSheets = (context) => {
24
41
  var _a;
25
42
  const workbook = context.workbook;
@@ -31,16 +48,17 @@ const parseSheets = (context) => {
31
48
  var _a;
32
49
  const worksheet = workbook.Sheets[name];
33
50
  const ref = worksheet === null || worksheet === void 0 ? void 0 : worksheet['!ref'];
34
- if (!ref) {
51
+ const drawingBounds = getDrawingBounds(worksheet);
52
+ if (!ref && !drawingBounds.rowCount && !drawingBounds.colCount) {
35
53
  return result;
36
54
  }
37
- const range = utils.decode_range(ref);
55
+ const range = ref ? utils.decode_range(ref) : utils.decode_range('A1');
38
56
  result.push({
39
57
  id: result.length,
40
58
  name,
41
59
  hidden: !!((_a = workbookSheets[sourceIndex]) === null || _a === void 0 ? void 0 : _a.Hidden),
42
- rowCount: range.e.r + 1,
43
- colCount: range.e.c + 1,
60
+ rowCount: Math.max(range.e.r + 1, drawingBounds.rowCount),
61
+ colCount: Math.max(range.e.c + 1, drawingBounds.colCount),
44
62
  });
45
63
  return result;
46
64
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/renderer-spreadsheet",
3
- "version": "2.0.11",
3
+ "version": "2.1.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Standalone spreadsheet renderer plugin for Flyfish File Viewer powered by styled-exceljs and e-virt-table.",
@@ -68,7 +68,7 @@
68
68
  "LICENSE"
69
69
  ],
70
70
  "dependencies": {
71
- "@file-viewer/core": "^2.0.11",
71
+ "@file-viewer/core": "^2.1.1",
72
72
  "e-virt-table": "^1.3.26",
73
73
  "styled-exceljs": "0.21.1",
74
74
  "tinycolor2": "^1.6.0"