@fileverse-dev/fortune-core 1.2.56-patch-3 → 1.2.56-patch-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.
- package/es/events/paste.js +19 -13
- package/lib/events/paste.js +19 -13
- package/package.json +1 -1
package/es/events/paste.js
CHANGED
|
@@ -77,19 +77,24 @@ 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
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
var cellRefRegex = /\b(\$?)([A-Z]+)(\$?)(\d+)\b/g;
|
|
81
|
+
var stringOrCellRef = /"(?:\\.|[^"])*"|(\b\$?[A-Z]+\$?\d+\b)/g;
|
|
82
|
+
var result = formula.replace(stringOrCellRef, function (m, cellRef) {
|
|
83
|
+
if (!cellRef) return m;
|
|
84
|
+
return cellRef.replace(cellRefRegex, function (__, absCol, colLetters, absRow, rowNum) {
|
|
85
|
+
var colIndex = columnLabelIndex(colLetters);
|
|
86
|
+
var rowIndex = parseInt(rowNum, 10);
|
|
87
|
+
if (!absCol) colIndex += colOffset;
|
|
88
|
+
if (!absRow) rowIndex += rowOffset;
|
|
89
|
+
if (colIndex < 0 || rowIndex <= 0) {
|
|
90
|
+
hadInvalid = true;
|
|
91
|
+
var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
|
|
92
|
+
var invalidRow = rowIndex.toString();
|
|
93
|
+
return "".concat(invalidCol).concat(invalidRow);
|
|
94
|
+
}
|
|
95
|
+
var newCol = indexToColumnLabel(colIndex);
|
|
96
|
+
return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
|
|
97
|
+
});
|
|
93
98
|
});
|
|
94
99
|
if (hadInvalid) {
|
|
95
100
|
var brokenFormula = "=".concat(result.replace(/^=/, ""));
|
|
@@ -980,6 +985,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
980
985
|
}
|
|
981
986
|
if (!isError) {
|
|
982
987
|
var funcV = execfunction(ctx, adjustedFormula, h, c, undefined, undefined, true);
|
|
988
|
+
console.log(funcV, adjustedFormula);
|
|
983
989
|
value.f = adjustedFormula;
|
|
984
990
|
if (!(funcV[1] instanceof Promise) && !funcV[3]) {
|
|
985
991
|
if (Array.isArray(funcV[1])) {
|
package/lib/events/paste.js
CHANGED
|
@@ -90,19 +90,24 @@ 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
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (!
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
var cellRefRegex = /\b(\$?)([A-Z]+)(\$?)(\d+)\b/g;
|
|
94
|
+
var stringOrCellRef = /"(?:\\.|[^"])*"|(\b\$?[A-Z]+\$?\d+\b)/g;
|
|
95
|
+
var result = formula.replace(stringOrCellRef, function (m, cellRef) {
|
|
96
|
+
if (!cellRef) return m;
|
|
97
|
+
return cellRef.replace(cellRefRegex, function (__, absCol, colLetters, absRow, rowNum) {
|
|
98
|
+
var colIndex = columnLabelIndex(colLetters);
|
|
99
|
+
var rowIndex = parseInt(rowNum, 10);
|
|
100
|
+
if (!absCol) colIndex += colOffset;
|
|
101
|
+
if (!absRow) rowIndex += rowOffset;
|
|
102
|
+
if (colIndex < 0 || rowIndex <= 0) {
|
|
103
|
+
hadInvalid = true;
|
|
104
|
+
var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
|
|
105
|
+
var invalidRow = rowIndex.toString();
|
|
106
|
+
return "".concat(invalidCol).concat(invalidRow);
|
|
107
|
+
}
|
|
108
|
+
var newCol = indexToColumnLabel(colIndex);
|
|
109
|
+
return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
|
|
110
|
+
});
|
|
106
111
|
});
|
|
107
112
|
if (hadInvalid) {
|
|
108
113
|
var brokenFormula = "=".concat(result.replace(/^=/, ""));
|
|
@@ -993,6 +998,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
993
998
|
}
|
|
994
999
|
if (!isError) {
|
|
995
1000
|
var funcV = (0, _formula.execfunction)(ctx, adjustedFormula, h, c, undefined, undefined, true);
|
|
1001
|
+
console.log(funcV, adjustedFormula);
|
|
996
1002
|
value.f = adjustedFormula;
|
|
997
1003
|
if (!(funcV[1] instanceof Promise) && !funcV[3]) {
|
|
998
1004
|
if (Array.isArray(funcV[1])) {
|