@fileverse-dev/fortune-core 1.2.30 → 1.2.32
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.d.ts +7 -0
- package/es/events/paste.js +124 -23
- package/es/modules/formula.js +5 -1
- package/es/modules/hyperlink.js +7 -5
- package/es/modules/toolbar.js +2 -2
- package/lib/events/paste.d.ts +7 -0
- package/lib/events/paste.js +125 -21
- package/lib/modules/formula.js +5 -1
- package/lib/modules/hyperlink.js +7 -5
- package/lib/modules/toolbar.js +2 -2
- package/package.json +1 -1
package/es/events/paste.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Context } from "../context";
|
|
2
|
+
export declare function columnLabelIndex(label: string): number;
|
|
3
|
+
export declare function indexToColumnLabel(index: number): string;
|
|
4
|
+
export declare class FormularCellRefError extends Error {
|
|
5
|
+
formula: string;
|
|
6
|
+
constructor(message: string, formula: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function adjustFormulaForPaste(formula: string, srcCol: number, srcRow: number, destCol: number, destRow: number): string;
|
|
2
9
|
export declare function parseAsLinkIfUrl(txtdata: string, ctx: Context): void;
|
|
3
10
|
export declare function handlePaste(ctx: Context, e: ClipboardEvent): void;
|
|
4
11
|
export declare function handlePasteByClick(ctx: Context, clipboardData: string, triggerType?: string): void;
|
package/es/events/paste.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var __extends = this && this.__extends || function () {
|
|
3
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
4
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
5
|
+
__proto__: []
|
|
6
|
+
} instanceof Array && function (d, b) {
|
|
7
|
+
d.__proto__ = b;
|
|
8
|
+
} || function (d, b) {
|
|
9
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
|
+
};
|
|
11
|
+
return _extendStatics(d, b);
|
|
12
|
+
};
|
|
13
|
+
return function (d, b) {
|
|
14
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
15
|
+
_extendStatics(d, b);
|
|
16
|
+
function __() {
|
|
17
|
+
this.constructor = d;
|
|
18
|
+
}
|
|
19
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
20
|
+
};
|
|
21
|
+
}();
|
|
2
22
|
var __assign = this && this.__assign || function () {
|
|
3
23
|
__assign = Object.assign || function (t) {
|
|
4
24
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -12,7 +32,7 @@ var __assign = this && this.__assign || function () {
|
|
|
12
32
|
import _ from "lodash";
|
|
13
33
|
import { handlePastedTable } from "../paste-table-helpers";
|
|
14
34
|
import { getFlowdata } from "../context";
|
|
15
|
-
import { execfunction
|
|
35
|
+
import { execfunction } from "../modules/formula";
|
|
16
36
|
import { getdatabyselection } from "../modules/cell";
|
|
17
37
|
import { genarate, update } from "../modules/format";
|
|
18
38
|
import { normalizeSelection, selectionCache } from "../modules/selection";
|
|
@@ -21,9 +41,62 @@ import { hasPartMC, isRealNum } from "../modules/validation";
|
|
|
21
41
|
import { getBorderInfoCompute } from "../modules/border";
|
|
22
42
|
import { expandRowsAndColumns, storeSheetParamALL } from "../modules/sheet";
|
|
23
43
|
import { jfrefreshgrid } from "../modules/refresh";
|
|
24
|
-
import { CFSplitRange, sanitizeDuneUrl, saveHyperlink } from "../modules";
|
|
44
|
+
import { CFSplitRange, sanitizeDuneUrl, saveHyperlink, spillSortResult } from "../modules";
|
|
25
45
|
import clipboard from "../modules/clipboard";
|
|
26
46
|
import { calculateRangeCellSize, updateSheetCellSizes } from "../paste-helpers/calculate-range-cell-size";
|
|
47
|
+
export function columnLabelIndex(label) {
|
|
48
|
+
var index = 0;
|
|
49
|
+
var A = "A".charCodeAt(0);
|
|
50
|
+
for (var i = 0; i < label.length; i++) {
|
|
51
|
+
var charCode = label.charCodeAt(i) - A + 1;
|
|
52
|
+
index = index * 26 + charCode;
|
|
53
|
+
}
|
|
54
|
+
return index - 1;
|
|
55
|
+
}
|
|
56
|
+
export function indexToColumnLabel(index) {
|
|
57
|
+
var label = "";
|
|
58
|
+
while (index >= 0) {
|
|
59
|
+
var remainder = index % 26;
|
|
60
|
+
label = String.fromCharCode(65 + remainder) + label;
|
|
61
|
+
index = Math.floor(index / 26) - 1;
|
|
62
|
+
}
|
|
63
|
+
return label;
|
|
64
|
+
}
|
|
65
|
+
var FormularCellRefError = function (_super) {
|
|
66
|
+
__extends(FormularCellRefError, _super);
|
|
67
|
+
function FormularCellRefError(message, formula) {
|
|
68
|
+
var _this = _super.call(this, message) || this;
|
|
69
|
+
_this.name = "FormularCellRefError";
|
|
70
|
+
_this.formula = formula;
|
|
71
|
+
return _this;
|
|
72
|
+
}
|
|
73
|
+
return FormularCellRefError;
|
|
74
|
+
}(Error);
|
|
75
|
+
export { FormularCellRefError };
|
|
76
|
+
export function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
|
|
77
|
+
var colOffset = destCol - srcCol;
|
|
78
|
+
var rowOffset = destRow - srcRow;
|
|
79
|
+
var hadInvalid = false;
|
|
80
|
+
var result = formula.replace(/(\$?)([A-Z]+)(\$?)(\d+)/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);
|
|
93
|
+
});
|
|
94
|
+
if (hadInvalid) {
|
|
95
|
+
var brokenFormula = "=".concat(result.replace(/^=/, ""));
|
|
96
|
+
throw new FormularCellRefError("Invalid cell reference generated while pasting formula: ".concat(formula), brokenFormula);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
27
100
|
function postPasteCut(ctx, source, target, RowlChange) {
|
|
28
101
|
var execF_rc = {};
|
|
29
102
|
ctx.formulaCache.execFunctionExist = [];
|
|
@@ -792,8 +865,6 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
792
865
|
mtc = minc + (tc - 1) * copyc;
|
|
793
866
|
maxrowCache = minh + th * copyh;
|
|
794
867
|
maxcellCahe = minc + tc * copyc;
|
|
795
|
-
var offsetRow = mth - c_r1;
|
|
796
|
-
var offsetCol = mtc - c_c1;
|
|
797
868
|
var offsetMC = {};
|
|
798
869
|
for (var h = mth; h < maxrowCache; h += 1) {
|
|
799
870
|
if (hiddenRows === null || hiddenRows === void 0 ? void 0 : hiddenRows.has(h.toString())) continue;
|
|
@@ -868,26 +939,56 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
868
939
|
}
|
|
869
940
|
}
|
|
870
941
|
if (!_.isNil(value) && !_.isNil(value.f)) {
|
|
871
|
-
var
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
942
|
+
var adjustedFormula = value.f;
|
|
943
|
+
var isError = false;
|
|
944
|
+
try {
|
|
945
|
+
adjustedFormula = adjustFormulaForPaste(value.f, c_c1, c_r1, c, h);
|
|
946
|
+
} catch (error) {
|
|
947
|
+
isError = true;
|
|
948
|
+
value.error = {
|
|
949
|
+
row_column: "".concat(h, "_").concat(c),
|
|
950
|
+
title: "Error",
|
|
951
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || "Failed to adjust cell reference"
|
|
952
|
+
};
|
|
953
|
+
value.m = "#ERROR";
|
|
954
|
+
value.f = error === null || error === void 0 ? void 0 : error.formula;
|
|
955
|
+
delete value.ct;
|
|
956
|
+
delete value.v;
|
|
957
|
+
delete value.tb;
|
|
958
|
+
delete value.ht;
|
|
883
959
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
960
|
+
if (!isError) {
|
|
961
|
+
var funcV = execfunction(ctx, adjustedFormula, h, c, undefined, undefined, true);
|
|
962
|
+
value.f = adjustedFormula;
|
|
963
|
+
if (!(funcV[1] instanceof Promise) && !funcV[3]) {
|
|
964
|
+
if (Array.isArray(funcV[1])) {
|
|
965
|
+
var formulaResultValue = funcV[1];
|
|
966
|
+
value.m = String(formulaResultValue[0][0]);
|
|
967
|
+
spillSortResult(ctx, h, c, {
|
|
968
|
+
m: String(formulaResultValue[0][0]),
|
|
969
|
+
f: value.f,
|
|
970
|
+
v: formulaResultValue
|
|
971
|
+
}, d);
|
|
972
|
+
} else {
|
|
973
|
+
value.m = String(funcV[1]);
|
|
974
|
+
value.v = String(funcV[1]);
|
|
975
|
+
}
|
|
976
|
+
} else if (funcV[3]) {
|
|
977
|
+
value.error = funcV[3];
|
|
978
|
+
value.m = "#ERROR";
|
|
979
|
+
value.f = adjustedFormula;
|
|
980
|
+
delete value.ct;
|
|
981
|
+
delete value.v;
|
|
982
|
+
delete value.tb;
|
|
983
|
+
delete value.ht;
|
|
984
|
+
}
|
|
985
|
+
var afterUpdateCell = ctx.hooks.afterUpdateCell;
|
|
986
|
+
if (afterUpdateCell) {
|
|
987
|
+
afterUpdateCell(h, c, null, __assign(__assign({}, value), {
|
|
988
|
+
v: arr.length === 1 ? funcV[1] : value.v,
|
|
989
|
+
m: funcV[1] instanceof Promise ? "[object Promise]" : funcV[1]
|
|
990
|
+
}));
|
|
991
|
+
}
|
|
891
992
|
}
|
|
892
993
|
if (!_.isNil(value.spl)) {}
|
|
893
994
|
}
|
package/es/modules/formula.js
CHANGED
|
@@ -740,7 +740,11 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
|
|
|
740
740
|
} else {
|
|
741
741
|
clearCellError(ctx, r, c);
|
|
742
742
|
}
|
|
743
|
-
return [true, !isError ? finalResult : "#ERROR", txt
|
|
743
|
+
return [true, !isError ? finalResult : "#ERROR", txt, isError && {
|
|
744
|
+
row_column: "".concat(r, "_").concat(c),
|
|
745
|
+
title: "Error",
|
|
746
|
+
message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || detectedErrorFromValue || "Unknown Error"
|
|
747
|
+
}];
|
|
744
748
|
}
|
|
745
749
|
function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
746
750
|
var r = dynamicArrayItem.r,
|
package/es/modules/hyperlink.js
CHANGED
|
@@ -152,11 +152,13 @@ export function isLinkValid(ctx, linkType, linkAddress) {
|
|
|
152
152
|
tooltip: ""
|
|
153
153
|
};
|
|
154
154
|
var insertLink = locale(ctx).insertLink;
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
if (!/^https?:\/\//i.test(linkAddress)) {
|
|
156
|
+
linkAddress = "https://".concat(linkAddress);
|
|
157
|
+
}
|
|
158
|
+
var urlPattern = /^(https?):\/\/[^\s$.?#].[^\s]*$/i;
|
|
159
|
+
var isValid = urlPattern.test(linkAddress);
|
|
160
|
+
if (!isValid) {
|
|
161
|
+
return {
|
|
160
162
|
isValid: false,
|
|
161
163
|
tooltip: insertLink.tooltipInfo1
|
|
162
164
|
};
|
package/es/modules/toolbar.js
CHANGED
|
@@ -142,7 +142,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
142
142
|
}
|
|
143
143
|
if (value.m) {
|
|
144
144
|
lineCount_1 = getLineCount(value.m, currentColWidth_1, fontString_1);
|
|
145
|
-
var hOffset = lineCount_1 < 4 ?
|
|
145
|
+
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
146
146
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
147
147
|
} else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
|
|
148
148
|
lineCount_1 -= 1;
|
|
@@ -151,7 +151,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
151
151
|
var subLineCount = getLineCount(item, currentColWidth_1, fontString_1);
|
|
152
152
|
lineCount_1 += subLineCount;
|
|
153
153
|
});
|
|
154
|
-
var hOffset = lineCount_1 < 4 ? 2.2 : 1.
|
|
154
|
+
var hOffset = lineCount_1 < 4 ? 2.2 : 1.6;
|
|
155
155
|
lineCount_1 *= hOffset;
|
|
156
156
|
}
|
|
157
157
|
var fontSize = (value === null || value === void 0 ? void 0 : value.fs) || 10;
|
package/lib/events/paste.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Context } from "../context";
|
|
2
|
+
export declare function columnLabelIndex(label: string): number;
|
|
3
|
+
export declare function indexToColumnLabel(index: number): string;
|
|
4
|
+
export declare class FormularCellRefError extends Error {
|
|
5
|
+
formula: string;
|
|
6
|
+
constructor(message: string, formula: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function adjustFormulaForPaste(formula: string, srcCol: number, srcRow: number, destCol: number, destRow: number): string;
|
|
2
9
|
export declare function parseAsLinkIfUrl(txtdata: string, ctx: Context): void;
|
|
3
10
|
export declare function handlePaste(ctx: Context, e: ClipboardEvent): void;
|
|
4
11
|
export declare function handlePasteByClick(ctx: Context, clipboardData: string, triggerType?: string): void;
|
package/lib/events/paste.js
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.FormularCellRefError = void 0;
|
|
7
|
+
exports.adjustFormulaForPaste = adjustFormulaForPaste;
|
|
8
|
+
exports.columnLabelIndex = columnLabelIndex;
|
|
6
9
|
exports.handlePaste = handlePaste;
|
|
7
10
|
exports.handlePasteByClick = handlePasteByClick;
|
|
11
|
+
exports.indexToColumnLabel = indexToColumnLabel;
|
|
8
12
|
exports.parseAsLinkIfUrl = parseAsLinkIfUrl;
|
|
9
13
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
14
|
var _pasteTableHelpers = require("../paste-table-helpers");
|
|
@@ -23,6 +27,26 @@ var _clipboard = _interopRequireDefault(require("../modules/clipboard"));
|
|
|
23
27
|
var _calculateRangeCellSize = require("../paste-helpers/calculate-range-cell-size");
|
|
24
28
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
29
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
30
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
31
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
32
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
33
|
+
__proto__: []
|
|
34
|
+
} instanceof Array && function (d, b) {
|
|
35
|
+
d.__proto__ = b;
|
|
36
|
+
} || function (d, b) {
|
|
37
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
38
|
+
};
|
|
39
|
+
return _extendStatics(d, b);
|
|
40
|
+
};
|
|
41
|
+
return function (d, b) {
|
|
42
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
43
|
+
_extendStatics(d, b);
|
|
44
|
+
function __() {
|
|
45
|
+
this.constructor = d;
|
|
46
|
+
}
|
|
47
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
48
|
+
};
|
|
49
|
+
}();
|
|
26
50
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
27
51
|
__assign = Object.assign || function (t) {
|
|
28
52
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -33,6 +57,58 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
33
57
|
};
|
|
34
58
|
return __assign.apply(this, arguments);
|
|
35
59
|
};
|
|
60
|
+
function columnLabelIndex(label) {
|
|
61
|
+
var index = 0;
|
|
62
|
+
var A = "A".charCodeAt(0);
|
|
63
|
+
for (var i = 0; i < label.length; i++) {
|
|
64
|
+
var charCode = label.charCodeAt(i) - A + 1;
|
|
65
|
+
index = index * 26 + charCode;
|
|
66
|
+
}
|
|
67
|
+
return index - 1;
|
|
68
|
+
}
|
|
69
|
+
function indexToColumnLabel(index) {
|
|
70
|
+
var label = "";
|
|
71
|
+
while (index >= 0) {
|
|
72
|
+
var remainder = index % 26;
|
|
73
|
+
label = String.fromCharCode(65 + remainder) + label;
|
|
74
|
+
index = Math.floor(index / 26) - 1;
|
|
75
|
+
}
|
|
76
|
+
return label;
|
|
77
|
+
}
|
|
78
|
+
var FormularCellRefError = exports.FormularCellRefError = function (_super) {
|
|
79
|
+
__extends(FormularCellRefError, _super);
|
|
80
|
+
function FormularCellRefError(message, formula) {
|
|
81
|
+
var _this = _super.call(this, message) || this;
|
|
82
|
+
_this.name = "FormularCellRefError";
|
|
83
|
+
_this.formula = formula;
|
|
84
|
+
return _this;
|
|
85
|
+
}
|
|
86
|
+
return FormularCellRefError;
|
|
87
|
+
}(Error);
|
|
88
|
+
function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
|
|
89
|
+
var colOffset = destCol - srcCol;
|
|
90
|
+
var rowOffset = destRow - srcRow;
|
|
91
|
+
var hadInvalid = false;
|
|
92
|
+
var result = formula.replace(/(\$?)([A-Z]+)(\$?)(\d+)/g, function (__, absCol, colLetters, absRow, rowNum) {
|
|
93
|
+
var colIndex = columnLabelIndex(colLetters);
|
|
94
|
+
var rowIndex = parseInt(rowNum, 10);
|
|
95
|
+
if (!absCol) colIndex += colOffset;
|
|
96
|
+
if (!absRow) rowIndex += rowOffset;
|
|
97
|
+
if (colIndex < 0 || rowIndex <= 0) {
|
|
98
|
+
hadInvalid = true;
|
|
99
|
+
var invalidCol = colIndex < 0 ? "".concat(absCol ? "$" : "").concat(colLetters).concat(colIndex) : "".concat(absCol ? "$" : "").concat(indexToColumnLabel(colIndex));
|
|
100
|
+
var invalidRow = rowIndex.toString();
|
|
101
|
+
return "".concat(invalidCol).concat(invalidRow);
|
|
102
|
+
}
|
|
103
|
+
var newCol = indexToColumnLabel(colIndex);
|
|
104
|
+
return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
|
|
105
|
+
});
|
|
106
|
+
if (hadInvalid) {
|
|
107
|
+
var brokenFormula = "=".concat(result.replace(/^=/, ""));
|
|
108
|
+
throw new FormularCellRefError("Invalid cell reference generated while pasting formula: ".concat(formula), brokenFormula);
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
36
112
|
function postPasteCut(ctx, source, target, RowlChange) {
|
|
37
113
|
var execF_rc = {};
|
|
38
114
|
ctx.formulaCache.execFunctionExist = [];
|
|
@@ -801,8 +877,6 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
801
877
|
mtc = minc + (tc - 1) * copyc;
|
|
802
878
|
maxrowCache = minh + th * copyh;
|
|
803
879
|
maxcellCahe = minc + tc * copyc;
|
|
804
|
-
var offsetRow = mth - c_r1;
|
|
805
|
-
var offsetCol = mtc - c_c1;
|
|
806
880
|
var offsetMC = {};
|
|
807
881
|
for (var h = mth; h < maxrowCache; h += 1) {
|
|
808
882
|
if (hiddenRows === null || hiddenRows === void 0 ? void 0 : hiddenRows.has(h.toString())) continue;
|
|
@@ -877,26 +951,56 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
877
951
|
}
|
|
878
952
|
}
|
|
879
953
|
if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
|
|
880
|
-
var
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
954
|
+
var adjustedFormula = value.f;
|
|
955
|
+
var isError = false;
|
|
956
|
+
try {
|
|
957
|
+
adjustedFormula = adjustFormulaForPaste(value.f, c_c1, c_r1, c, h);
|
|
958
|
+
} catch (error) {
|
|
959
|
+
isError = true;
|
|
960
|
+
value.error = {
|
|
961
|
+
row_column: "".concat(h, "_").concat(c),
|
|
962
|
+
title: "Error",
|
|
963
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || "Failed to adjust cell reference"
|
|
964
|
+
};
|
|
965
|
+
value.m = "#ERROR";
|
|
966
|
+
value.f = error === null || error === void 0 ? void 0 : error.formula;
|
|
967
|
+
delete value.ct;
|
|
968
|
+
delete value.v;
|
|
969
|
+
delete value.tb;
|
|
970
|
+
delete value.ht;
|
|
892
971
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
972
|
+
if (!isError) {
|
|
973
|
+
var funcV = (0, _formula.execfunction)(ctx, adjustedFormula, h, c, undefined, undefined, true);
|
|
974
|
+
value.f = adjustedFormula;
|
|
975
|
+
if (!(funcV[1] instanceof Promise) && !funcV[3]) {
|
|
976
|
+
if (Array.isArray(funcV[1])) {
|
|
977
|
+
var formulaResultValue = funcV[1];
|
|
978
|
+
value.m = String(formulaResultValue[0][0]);
|
|
979
|
+
(0, _modules.spillSortResult)(ctx, h, c, {
|
|
980
|
+
m: String(formulaResultValue[0][0]),
|
|
981
|
+
f: value.f,
|
|
982
|
+
v: formulaResultValue
|
|
983
|
+
}, d);
|
|
984
|
+
} else {
|
|
985
|
+
value.m = String(funcV[1]);
|
|
986
|
+
value.v = String(funcV[1]);
|
|
987
|
+
}
|
|
988
|
+
} else if (funcV[3]) {
|
|
989
|
+
value.error = funcV[3];
|
|
990
|
+
value.m = "#ERROR";
|
|
991
|
+
value.f = adjustedFormula;
|
|
992
|
+
delete value.ct;
|
|
993
|
+
delete value.v;
|
|
994
|
+
delete value.tb;
|
|
995
|
+
delete value.ht;
|
|
996
|
+
}
|
|
997
|
+
var afterUpdateCell = ctx.hooks.afterUpdateCell;
|
|
998
|
+
if (afterUpdateCell) {
|
|
999
|
+
afterUpdateCell(h, c, null, __assign(__assign({}, value), {
|
|
1000
|
+
v: arr.length === 1 ? funcV[1] : value.v,
|
|
1001
|
+
m: funcV[1] instanceof Promise ? "[object Promise]" : funcV[1]
|
|
1002
|
+
}));
|
|
1003
|
+
}
|
|
900
1004
|
}
|
|
901
1005
|
if (!_lodash.default.isNil(value.spl)) {}
|
|
902
1006
|
}
|
package/lib/modules/formula.js
CHANGED
|
@@ -770,7 +770,11 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
|
|
|
770
770
|
} else {
|
|
771
771
|
(0, _2.clearCellError)(ctx, r, c);
|
|
772
772
|
}
|
|
773
|
-
return [true, !isError ? finalResult : "#ERROR", txt
|
|
773
|
+
return [true, !isError ? finalResult : "#ERROR", txt, isError && {
|
|
774
|
+
row_column: "".concat(r, "_").concat(c),
|
|
775
|
+
title: "Error",
|
|
776
|
+
message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || detectedErrorFromValue || "Unknown Error"
|
|
777
|
+
}];
|
|
774
778
|
}
|
|
775
779
|
function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
776
780
|
var r = dynamicArrayItem.r,
|
package/lib/modules/hyperlink.js
CHANGED
|
@@ -168,11 +168,13 @@ function isLinkValid(ctx, linkType, linkAddress) {
|
|
|
168
168
|
tooltip: ""
|
|
169
169
|
};
|
|
170
170
|
var insertLink = (0, _locale.locale)(ctx).insertLink;
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
if (!/^https?:\/\//i.test(linkAddress)) {
|
|
172
|
+
linkAddress = "https://".concat(linkAddress);
|
|
173
|
+
}
|
|
174
|
+
var urlPattern = /^(https?):\/\/[^\s$.?#].[^\s]*$/i;
|
|
175
|
+
var isValid = urlPattern.test(linkAddress);
|
|
176
|
+
if (!isValid) {
|
|
177
|
+
return {
|
|
176
178
|
isValid: false,
|
|
177
179
|
tooltip: insertLink.tooltipInfo1
|
|
178
180
|
};
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -175,7 +175,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
175
175
|
}
|
|
176
176
|
if (value.m) {
|
|
177
177
|
lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
|
|
178
|
-
var hOffset = lineCount_1 < 4 ?
|
|
178
|
+
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
179
179
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
180
180
|
} else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
|
|
181
181
|
lineCount_1 -= 1;
|
|
@@ -184,7 +184,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
184
184
|
var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
|
|
185
185
|
lineCount_1 += subLineCount;
|
|
186
186
|
});
|
|
187
|
-
var hOffset = lineCount_1 < 4 ? 2.2 : 1.
|
|
187
|
+
var hOffset = lineCount_1 < 4 ? 2.2 : 1.6;
|
|
188
188
|
lineCount_1 *= hOffset;
|
|
189
189
|
}
|
|
190
190
|
var fontSize = (value === null || value === void 0 ? void 0 : value.fs) || 10;
|