@fileverse-dev/fortune-core 1.2.56-patch-3 → 1.2.56-patch-5

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.
@@ -77,19 +77,26 @@ export function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow)
77
77
  var colOffset = destCol - srcCol;
78
78
  var rowOffset = destRow - srcRow;
79
79
  var hadInvalid = false;
80
- var result = formula.replace(/\b(\$?)([A-Z]+)(\$?)(\d+)\b/g, function (__, absCol, colLetters, absRow, rowNum) {
81
- var colIndex = columnLabelIndex(colLetters);
82
- var rowIndex = parseInt(rowNum, 10);
83
- if (!absCol) colIndex += colOffset;
84
- if (!absRow) rowIndex += rowOffset;
85
- if (colIndex < 0 || rowIndex <= 0) {
86
- hadInvalid = true;
87
- var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
88
- var invalidRow = rowIndex.toString();
89
- return "".concat(invalidCol).concat(invalidRow);
90
- }
91
- var newCol = indexToColumnLabel(colIndex);
92
- return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
80
+ var cellRefRegex = /\b(\$?)([A-Z]+)(\$?)(\d+)\b/g;
81
+ var stringOrCellRef = /"(?:\\.|[^"])*"|(?<!\$)([A-Z]+\d+\b)/g;
82
+ var result = formula.replace(stringOrCellRef, function (m, cellRef) {
83
+ if (!cellRef) return m;
84
+ if (cellRef.startsWith("$")) return m;
85
+ console.log(m, "cellRef", cellRef);
86
+ return cellRef.replace(cellRefRegex, function (__, absCol, colLetters, absRow, rowNum) {
87
+ var colIndex = columnLabelIndex(colLetters);
88
+ var rowIndex = parseInt(rowNum, 10);
89
+ if (!absCol) colIndex += colOffset;
90
+ if (!absRow) rowIndex += rowOffset;
91
+ if (colIndex < 0 || rowIndex <= 0) {
92
+ hadInvalid = true;
93
+ var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
94
+ var invalidRow = rowIndex.toString();
95
+ return "".concat(invalidCol).concat(invalidRow);
96
+ }
97
+ var newCol = indexToColumnLabel(colIndex);
98
+ return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
99
+ });
93
100
  });
94
101
  if (hadInvalid) {
95
102
  var brokenFormula = "=".concat(result.replace(/^=/, ""));
@@ -964,6 +971,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
964
971
  var isError = false;
965
972
  try {
966
973
  adjustedFormula = adjustFormulaForPaste(value.f, c_c1, c_r1, c, h);
974
+ console.log("adjustedFormula", adjustedFormula);
967
975
  } catch (error) {
968
976
  isError = true;
969
977
  value.error = {
@@ -1,3 +1,13 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
+ }
7
+ return t;
8
+ };
9
+ return __assign.apply(this, arguments);
10
+ };
1
11
  import _ from "lodash";
2
12
  import dayjs from "dayjs";
3
13
  import { getFlowdata } from "../context";
@@ -1814,6 +1824,13 @@ export function updateDropCell(ctx) {
1814
1824
  var v = formula.execfunction(ctx, f, j, i);
1815
1825
  formula.execFunctionGroup(ctx, j, i, v[1], undefined, d);
1816
1826
  cell.v = v[1], cell.f = v[2];
1827
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
1828
+ if (afterUpdateCell) {
1829
+ afterUpdateCell(j, i, null, __assign(__assign({}, cell), {
1830
+ v: v[1] instanceof Promise ? v[1] : cell.v,
1831
+ m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1832
+ }));
1833
+ }
1817
1834
  if (cell.spl != null) {
1818
1835
  cell.spl = v[3].data;
1819
1836
  } else if (cell.v != null) {
@@ -90,19 +90,26 @@ function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
90
90
  var colOffset = destCol - srcCol;
91
91
  var rowOffset = destRow - srcRow;
92
92
  var hadInvalid = false;
93
- var result = formula.replace(/\b(\$?)([A-Z]+)(\$?)(\d+)\b/g, function (__, absCol, colLetters, absRow, rowNum) {
94
- var colIndex = columnLabelIndex(colLetters);
95
- var rowIndex = parseInt(rowNum, 10);
96
- if (!absCol) colIndex += colOffset;
97
- if (!absRow) rowIndex += rowOffset;
98
- if (colIndex < 0 || rowIndex <= 0) {
99
- hadInvalid = true;
100
- var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
101
- var invalidRow = rowIndex.toString();
102
- return "".concat(invalidCol).concat(invalidRow);
103
- }
104
- var newCol = indexToColumnLabel(colIndex);
105
- return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
93
+ var cellRefRegex = /\b(\$?)([A-Z]+)(\$?)(\d+)\b/g;
94
+ var stringOrCellRef = /"(?:\\.|[^"])*"|(?<!\$)([A-Z]+\d+\b)/g;
95
+ var result = formula.replace(stringOrCellRef, function (m, cellRef) {
96
+ if (!cellRef) return m;
97
+ if (cellRef.startsWith("$")) return m;
98
+ console.log(m, "cellRef", cellRef);
99
+ return cellRef.replace(cellRefRegex, function (__, absCol, colLetters, absRow, rowNum) {
100
+ var colIndex = columnLabelIndex(colLetters);
101
+ var rowIndex = parseInt(rowNum, 10);
102
+ if (!absCol) colIndex += colOffset;
103
+ if (!absRow) rowIndex += rowOffset;
104
+ if (colIndex < 0 || rowIndex <= 0) {
105
+ hadInvalid = true;
106
+ var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
107
+ var invalidRow = rowIndex.toString();
108
+ return "".concat(invalidCol).concat(invalidRow);
109
+ }
110
+ var newCol = indexToColumnLabel(colIndex);
111
+ return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
112
+ });
106
113
  });
107
114
  if (hadInvalid) {
108
115
  var brokenFormula = "=".concat(result.replace(/^=/, ""));
@@ -977,6 +984,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
977
984
  var isError = false;
978
985
  try {
979
986
  adjustedFormula = adjustFormulaForPaste(value.f, c_c1, c_r1, c, h);
987
+ console.log("adjustedFormula", adjustedFormula);
980
988
  } catch (error) {
981
989
  isError = true;
982
990
  value.error = {
@@ -26,6 +26,16 @@ var _selection = require("./selection");
26
26
  var _refresh = require("./refresh");
27
27
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
28
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
+ var __assign = void 0 && (void 0).__assign || function () {
30
+ __assign = Object.assign || function (t) {
31
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
32
+ s = arguments[i];
33
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34
+ }
35
+ return t;
36
+ };
37
+ return __assign.apply(this, arguments);
38
+ };
29
39
  function toPx(v) {
30
40
  return "".concat(v, "px");
31
41
  }
@@ -1830,6 +1840,13 @@ function updateDropCell(ctx) {
1830
1840
  var v = formula.execfunction(ctx, f, j, i);
1831
1841
  formula.execFunctionGroup(ctx, j, i, v[1], undefined, d);
1832
1842
  cell.v = v[1], cell.f = v[2];
1843
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
1844
+ if (afterUpdateCell) {
1845
+ afterUpdateCell(j, i, null, __assign(__assign({}, cell), {
1846
+ v: v[1] instanceof Promise ? v[1] : cell.v,
1847
+ m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1848
+ }));
1849
+ }
1833
1850
  if (cell.spl != null) {
1834
1851
  cell.spl = v[3].data;
1835
1852
  } else if (cell.v != null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.56-patch-3",
3
+ "version": "1.2.56-patch-5",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",