@fileverse-dev/fortune-core 1.2.21 → 1.2.22-cell-ref-adjustment-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.
- package/es/events/paste.d.ts +3 -0
- package/es/events/paste.js +34 -17
- package/es/locale/en.js +2 -2
- package/lib/events/paste.d.ts +3 -0
- package/lib/events/paste.js +36 -16
- package/lib/locale/en.js +2 -2
- package/package.json +1 -1
package/es/events/paste.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
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 function adjustFormulaForPaste(formula: string, srcCol: number, srcRow: number, destCol: number, destRow: number): string;
|
|
2
5
|
export declare function parseAsLinkIfUrl(txtdata: string, ctx: Context): void;
|
|
3
6
|
export declare function handlePaste(ctx: Context, e: ClipboardEvent): void;
|
|
4
7
|
export declare function handlePasteByClick(ctx: Context, clipboardData: string, triggerType?: string): void;
|
package/es/events/paste.js
CHANGED
|
@@ -12,7 +12,7 @@ var __assign = this && this.__assign || function () {
|
|
|
12
12
|
import _ from "lodash";
|
|
13
13
|
import { handlePastedTable } from "../paste-table-helpers";
|
|
14
14
|
import { getFlowdata } from "../context";
|
|
15
|
-
import { execfunction
|
|
15
|
+
import { execfunction } from "../modules/formula";
|
|
16
16
|
import { getdatabyselection } from "../modules/cell";
|
|
17
17
|
import { genarate, update } from "../modules/format";
|
|
18
18
|
import { normalizeSelection, selectionCache } from "../modules/selection";
|
|
@@ -24,6 +24,36 @@ import { jfrefreshgrid } from "../modules/refresh";
|
|
|
24
24
|
import { CFSplitRange, sanitizeDuneUrl, saveHyperlink } from "../modules";
|
|
25
25
|
import clipboard from "../modules/clipboard";
|
|
26
26
|
import { calculateRangeCellSize, updateSheetCellSizes } from "../paste-helpers/calculate-range-cell-size";
|
|
27
|
+
export function columnLabelIndex(label) {
|
|
28
|
+
var index = 0;
|
|
29
|
+
var A = "A".charCodeAt(0);
|
|
30
|
+
for (var i = 0; i < label.length; i++) {
|
|
31
|
+
var charCode = label.charCodeAt(i) - A + 1;
|
|
32
|
+
index = index * 26 + charCode;
|
|
33
|
+
}
|
|
34
|
+
return index - 1;
|
|
35
|
+
}
|
|
36
|
+
export function indexToColumnLabel(index) {
|
|
37
|
+
var label = "";
|
|
38
|
+
while (index >= 0) {
|
|
39
|
+
var remainder = index % 26;
|
|
40
|
+
label = String.fromCharCode(65 + remainder) + label;
|
|
41
|
+
index = Math.floor(index / 26) - 1;
|
|
42
|
+
}
|
|
43
|
+
return label;
|
|
44
|
+
}
|
|
45
|
+
export function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
|
|
46
|
+
var colOffset = destCol - srcCol;
|
|
47
|
+
var rowOffset = destRow - srcRow;
|
|
48
|
+
return formula.replace(/(\$?)([A-Z]+)(\$?)(\d+)/g, function (__, absCol, colLetters, absRow, rowNum) {
|
|
49
|
+
var colIndex = columnLabelIndex(colLetters);
|
|
50
|
+
var rowIndex = parseInt(rowNum, 10);
|
|
51
|
+
if (!absCol) colIndex += colOffset;
|
|
52
|
+
if (!absRow) rowIndex += rowOffset;
|
|
53
|
+
var newCol = indexToColumnLabel(colIndex);
|
|
54
|
+
return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
27
57
|
function postPasteCut(ctx, source, target, RowlChange) {
|
|
28
58
|
var execF_rc = {};
|
|
29
59
|
ctx.formulaCache.execFunctionExist = [];
|
|
@@ -792,8 +822,6 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
792
822
|
mtc = minc + (tc - 1) * copyc;
|
|
793
823
|
maxrowCache = minh + th * copyh;
|
|
794
824
|
maxcellCahe = minc + tc * copyc;
|
|
795
|
-
var offsetRow = mth - c_r1;
|
|
796
|
-
var offsetCol = mtc - c_c1;
|
|
797
825
|
var offsetMC = {};
|
|
798
826
|
for (var h = mth; h < maxrowCache; h += 1) {
|
|
799
827
|
if (hiddenRows === null || hiddenRows === void 0 ? void 0 : hiddenRows.has(h.toString())) continue;
|
|
@@ -868,20 +896,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
868
896
|
}
|
|
869
897
|
}
|
|
870
898
|
if (!_.isNil(value) && !_.isNil(value.f)) {
|
|
871
|
-
var
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}
|
|
875
|
-
if (offsetRow < 0) {
|
|
876
|
-
func = "=".concat(functionCopy(ctx, func, "up", Math.abs(offsetRow)));
|
|
877
|
-
}
|
|
878
|
-
if (offsetCol > 0) {
|
|
879
|
-
func = "=".concat(functionCopy(ctx, func, "right", offsetCol));
|
|
880
|
-
}
|
|
881
|
-
if (offsetCol < 0) {
|
|
882
|
-
func = "=".concat(functionCopy(ctx, func, "left", Math.abs(offsetCol)));
|
|
883
|
-
}
|
|
884
|
-
var funcV = execfunction(ctx, func, h, c, undefined, undefined, true);
|
|
899
|
+
var adjustedFormula = adjustFormulaForPaste(value.f.startsWith("=") ? value.f : "=".concat(value.f), c_c1, c_r1, c, h);
|
|
900
|
+
var funcV = execfunction(ctx, adjustedFormula, h, c, undefined, undefined, true);
|
|
901
|
+
value.f = adjustedFormula;
|
|
885
902
|
var afterUpdateCell = ctx.hooks.afterUpdateCell;
|
|
886
903
|
if (afterUpdateCell) {
|
|
887
904
|
afterUpdateCell(h, c, null, __assign(__assign({}, value), {
|
package/es/locale/en.js
CHANGED
|
@@ -9808,7 +9808,7 @@ export default {
|
|
|
9808
9808
|
cellRange: "Cell range",
|
|
9809
9809
|
selectCellRange: "Select a data range",
|
|
9810
9810
|
selectCellRange2: "Please select a range of cells",
|
|
9811
|
-
verificationCondition: "
|
|
9811
|
+
verificationCondition: "Validation condition",
|
|
9812
9812
|
allowMultiSelect: "Allow multiple selection",
|
|
9813
9813
|
dropdown: "Dropdown list",
|
|
9814
9814
|
checkbox: "Checkbox",
|
|
@@ -9845,7 +9845,7 @@ export default {
|
|
|
9845
9845
|
remote: "Automatic remote acquisition option",
|
|
9846
9846
|
prohibitInput: "Prohibit input when input data is invalid",
|
|
9847
9847
|
hintShow: "Show prompt when the cell is selected",
|
|
9848
|
-
deleteVerification: "Delete
|
|
9848
|
+
deleteVerification: "Delete validation",
|
|
9849
9849
|
tooltipInfo1: "The drop-down list option cannot be empty",
|
|
9850
9850
|
tooltipInfo2: "Checkbox content cannot be empty",
|
|
9851
9851
|
tooltipInfo3: "The value entered is not a numeric type",
|
package/lib/events/paste.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
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 function adjustFormulaForPaste(formula: string, srcCol: number, srcRow: number, destCol: number, destRow: number): string;
|
|
2
5
|
export declare function parseAsLinkIfUrl(txtdata: string, ctx: Context): void;
|
|
3
6
|
export declare function handlePaste(ctx: Context, e: ClipboardEvent): void;
|
|
4
7
|
export declare function handlePasteByClick(ctx: Context, clipboardData: string, triggerType?: string): void;
|
package/lib/events/paste.js
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.adjustFormulaForPaste = adjustFormulaForPaste;
|
|
7
|
+
exports.columnLabelIndex = columnLabelIndex;
|
|
6
8
|
exports.handlePaste = handlePaste;
|
|
7
9
|
exports.handlePasteByClick = handlePasteByClick;
|
|
10
|
+
exports.indexToColumnLabel = indexToColumnLabel;
|
|
8
11
|
exports.parseAsLinkIfUrl = parseAsLinkIfUrl;
|
|
9
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
13
|
var _pasteTableHelpers = require("../paste-table-helpers");
|
|
@@ -33,6 +36,36 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
33
36
|
};
|
|
34
37
|
return __assign.apply(this, arguments);
|
|
35
38
|
};
|
|
39
|
+
function columnLabelIndex(label) {
|
|
40
|
+
var index = 0;
|
|
41
|
+
var A = "A".charCodeAt(0);
|
|
42
|
+
for (var i = 0; i < label.length; i++) {
|
|
43
|
+
var charCode = label.charCodeAt(i) - A + 1;
|
|
44
|
+
index = index * 26 + charCode;
|
|
45
|
+
}
|
|
46
|
+
return index - 1;
|
|
47
|
+
}
|
|
48
|
+
function indexToColumnLabel(index) {
|
|
49
|
+
var label = "";
|
|
50
|
+
while (index >= 0) {
|
|
51
|
+
var remainder = index % 26;
|
|
52
|
+
label = String.fromCharCode(65 + remainder) + label;
|
|
53
|
+
index = Math.floor(index / 26) - 1;
|
|
54
|
+
}
|
|
55
|
+
return label;
|
|
56
|
+
}
|
|
57
|
+
function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
|
|
58
|
+
var colOffset = destCol - srcCol;
|
|
59
|
+
var rowOffset = destRow - srcRow;
|
|
60
|
+
return formula.replace(/(\$?)([A-Z]+)(\$?)(\d+)/g, function (__, absCol, colLetters, absRow, rowNum) {
|
|
61
|
+
var colIndex = columnLabelIndex(colLetters);
|
|
62
|
+
var rowIndex = parseInt(rowNum, 10);
|
|
63
|
+
if (!absCol) colIndex += colOffset;
|
|
64
|
+
if (!absRow) rowIndex += rowOffset;
|
|
65
|
+
var newCol = indexToColumnLabel(colIndex);
|
|
66
|
+
return "".concat(absCol ? "$" : "").concat(newCol).concat(absRow ? "$" : "").concat(rowIndex);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
36
69
|
function postPasteCut(ctx, source, target, RowlChange) {
|
|
37
70
|
var execF_rc = {};
|
|
38
71
|
ctx.formulaCache.execFunctionExist = [];
|
|
@@ -801,8 +834,6 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
801
834
|
mtc = minc + (tc - 1) * copyc;
|
|
802
835
|
maxrowCache = minh + th * copyh;
|
|
803
836
|
maxcellCahe = minc + tc * copyc;
|
|
804
|
-
var offsetRow = mth - c_r1;
|
|
805
|
-
var offsetCol = mtc - c_c1;
|
|
806
837
|
var offsetMC = {};
|
|
807
838
|
for (var h = mth; h < maxrowCache; h += 1) {
|
|
808
839
|
if (hiddenRows === null || hiddenRows === void 0 ? void 0 : hiddenRows.has(h.toString())) continue;
|
|
@@ -877,20 +908,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
877
908
|
}
|
|
878
909
|
}
|
|
879
910
|
if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
|
|
880
|
-
var
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
if (offsetRow < 0) {
|
|
885
|
-
func = "=".concat((0, _formula.functionCopy)(ctx, func, "up", Math.abs(offsetRow)));
|
|
886
|
-
}
|
|
887
|
-
if (offsetCol > 0) {
|
|
888
|
-
func = "=".concat((0, _formula.functionCopy)(ctx, func, "right", offsetCol));
|
|
889
|
-
}
|
|
890
|
-
if (offsetCol < 0) {
|
|
891
|
-
func = "=".concat((0, _formula.functionCopy)(ctx, func, "left", Math.abs(offsetCol)));
|
|
892
|
-
}
|
|
893
|
-
var funcV = (0, _formula.execfunction)(ctx, func, h, c, undefined, undefined, true);
|
|
911
|
+
var adjustedFormula = adjustFormulaForPaste(value.f.startsWith("=") ? value.f : "=".concat(value.f), c_c1, c_r1, c, h);
|
|
912
|
+
var funcV = (0, _formula.execfunction)(ctx, adjustedFormula, h, c, undefined, undefined, true);
|
|
913
|
+
value.f = adjustedFormula;
|
|
894
914
|
var afterUpdateCell = ctx.hooks.afterUpdateCell;
|
|
895
915
|
if (afterUpdateCell) {
|
|
896
916
|
afterUpdateCell(h, c, null, __assign(__assign({}, value), {
|
package/lib/locale/en.js
CHANGED
|
@@ -9814,7 +9814,7 @@ var _default = exports.default = {
|
|
|
9814
9814
|
cellRange: "Cell range",
|
|
9815
9815
|
selectCellRange: "Select a data range",
|
|
9816
9816
|
selectCellRange2: "Please select a range of cells",
|
|
9817
|
-
verificationCondition: "
|
|
9817
|
+
verificationCondition: "Validation condition",
|
|
9818
9818
|
allowMultiSelect: "Allow multiple selection",
|
|
9819
9819
|
dropdown: "Dropdown list",
|
|
9820
9820
|
checkbox: "Checkbox",
|
|
@@ -9851,7 +9851,7 @@ var _default = exports.default = {
|
|
|
9851
9851
|
remote: "Automatic remote acquisition option",
|
|
9852
9852
|
prohibitInput: "Prohibit input when input data is invalid",
|
|
9853
9853
|
hintShow: "Show prompt when the cell is selected",
|
|
9854
|
-
deleteVerification: "Delete
|
|
9854
|
+
deleteVerification: "Delete validation",
|
|
9855
9855
|
tooltipInfo1: "The drop-down list option cannot be empty",
|
|
9856
9856
|
tooltipInfo2: "Checkbox content cannot be empty",
|
|
9857
9857
|
tooltipInfo3: "The value entered is not a numeric type",
|