@fileverse-dev/fortune-react 1.3.13-create-4 → 1.3.13-create-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.
- package/es/components/FxEditor/index.js +32 -1
- package/es/components/SheetOverlay/InputBox.js +89 -12
- package/es/components/SheetOverlay/drag_and_drop/column-helpers.js +4 -27
- package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +4 -25
- package/es/components/SheetOverlay/formula-segment-boundary.js +1 -1
- package/es/components/SheetOverlay/index.css +10 -83
- package/es/components/SheetOverlay/index.js +1 -26
- package/es/hooks/useFormulaEditorHistory.js +4 -78
- package/es/hooks/useRerenderOnFormulaCaret.d.ts +1 -1
- package/es/hooks/useRerenderOnFormulaCaret.js +6 -3
- package/lib/components/FxEditor/index.js +32 -1
- package/lib/components/SheetOverlay/InputBox.js +89 -12
- package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +3 -26
- package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +3 -24
- package/lib/components/SheetOverlay/formula-segment-boundary.js +1 -1
- package/lib/components/SheetOverlay/index.css +10 -83
- package/lib/components/SheetOverlay/index.js +1 -26
- package/lib/hooks/useFormulaEditorHistory.js +4 -78
- package/lib/hooks/useRerenderOnFormulaCaret.d.ts +1 -1
- package/lib/hooks/useRerenderOnFormulaCaret.js +5 -2
- package/package.json +2 -2
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
export function useRerenderOnFormulaCaret(editorRef, editSessionActive) {
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
export function useRerenderOnFormulaCaret(editorRef, editSessionActive, onAfterCaretMove) {
|
|
3
3
|
var _a = useState(0),
|
|
4
4
|
bump = _a[1];
|
|
5
|
+
var onAfterCaretMoveRef = useRef(onAfterCaretMove);
|
|
6
|
+
onAfterCaretMoveRef.current = onAfterCaretMove;
|
|
5
7
|
useEffect(function () {
|
|
6
8
|
if (!editSessionActive) {
|
|
7
9
|
return function () {};
|
|
8
10
|
}
|
|
9
11
|
var onSelectionChange = function onSelectionChange() {
|
|
10
|
-
var _a, _b;
|
|
12
|
+
var _a, _b, _c;
|
|
11
13
|
var el = editorRef.current;
|
|
12
14
|
if (!el) return;
|
|
13
15
|
var text = (_b = (_a = el.innerText) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
|
|
@@ -19,6 +21,7 @@ export function useRerenderOnFormulaCaret(editorRef, editSessionActive) {
|
|
|
19
21
|
bump(function (n) {
|
|
20
22
|
return n + 1;
|
|
21
23
|
});
|
|
24
|
+
(_c = onAfterCaretMoveRef.current) === null || _c === void 0 ? void 0 : _c.call(onAfterCaretMoveRef);
|
|
22
25
|
};
|
|
23
26
|
document.addEventListener("selectionchange", onSelectionChange);
|
|
24
27
|
return function () {
|
|
@@ -510,6 +510,13 @@ var FxEditor = function FxEditor() {
|
|
|
510
510
|
if (editor_1) {
|
|
511
511
|
setContext(function (draftCtx) {
|
|
512
512
|
if (!(0, _fortuneCore.isAllowEdit)(draftCtx, draftCtx.luckysheet_select_save)) return;
|
|
513
|
+
if ((0, _fortuneCore.getFormulaEditorOwner)(draftCtx) !== "fx") return;
|
|
514
|
+
if (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start) {
|
|
515
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, editor_1);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
draftCtx.formulaCache.selectingRangeIndex = -1;
|
|
519
|
+
(0, _fortuneCore.createRangeHightlight)(draftCtx, editor_1.innerHTML);
|
|
513
520
|
(0, _fortuneCore.rangeHightlightselected)(draftCtx, editor_1);
|
|
514
521
|
});
|
|
515
522
|
}
|
|
@@ -532,7 +539,26 @@ var FxEditor = function FxEditor() {
|
|
|
532
539
|
});
|
|
533
540
|
});
|
|
534
541
|
}, [appendEditorHistoryFromPrimaryEditor, context.isFlvReadOnly, context.luckysheetCellUpdate, refs.cellInput, refs.fxInput, setContext]);
|
|
535
|
-
(0,
|
|
542
|
+
var refreshFxFormulaRangeHighlights = (0, _react.useCallback)(function () {
|
|
543
|
+
var el = refs.fxInput.current;
|
|
544
|
+
if (!el) return;
|
|
545
|
+
setContext(function (draftCtx) {
|
|
546
|
+
var _a, _b;
|
|
547
|
+
if (draftCtx.luckysheetCellUpdate.length === 0) return;
|
|
548
|
+
if ((0, _fortuneCore.getFormulaEditorOwner)(draftCtx) !== "fx") return;
|
|
549
|
+
if (!(0, _fortuneCore.isAllowEdit)(draftCtx, draftCtx.luckysheet_select_save)) return;
|
|
550
|
+
var t = (_b = (_a = el.innerText) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
|
|
551
|
+
if (!t.startsWith("=")) return;
|
|
552
|
+
if (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start) {
|
|
553
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, el);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
draftCtx.formulaCache.selectingRangeIndex = -1;
|
|
557
|
+
(0, _fortuneCore.createRangeHightlight)(draftCtx, el.innerHTML);
|
|
558
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, el);
|
|
559
|
+
});
|
|
560
|
+
}, [refs.fxInput, setContext]);
|
|
561
|
+
(0, _useRerenderOnFormulaCaret.useRerenderOnFormulaCaret)(refs.fxInput, context.luckysheetCellUpdate.length > 0, refreshFxFormulaRangeHighlights);
|
|
536
562
|
var getFunctionNameFromInput = (0, _react.useCallback)(function () {
|
|
537
563
|
var _a, _b, _c, _d;
|
|
538
564
|
var inputText = ((_b = (_a = refs.fxInput) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.innerText) || "";
|
|
@@ -620,11 +646,16 @@ var FxEditor = function FxEditor() {
|
|
|
620
646
|
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(editor);
|
|
621
647
|
setCommaCount(currentCommaCount);
|
|
622
648
|
setContext(function (draftCtx) {
|
|
649
|
+
var _a;
|
|
623
650
|
if (draftCtx.formulaCache.rangeSelectionActive !== true) return;
|
|
624
651
|
var clickedInsideManagedRange = (0, _fortuneCore.getFormulaRangeIndexAtCaret)(editor) !== null;
|
|
625
652
|
var atValidInsertionPoint = (0, _fortuneCore.isCaretAtValidFormulaRangeInsertionPoint)(editor);
|
|
626
653
|
if (clickedInsideManagedRange || !atValidInsertionPoint) {
|
|
627
654
|
(0, _fortuneCore.markRangeSelectionDirty)(draftCtx);
|
|
655
|
+
if ((_a = editor.innerText) === null || _a === void 0 ? void 0 : _a.trim().startsWith("=")) {
|
|
656
|
+
(0, _fortuneCore.createRangeHightlight)(draftCtx, editor.innerHTML);
|
|
657
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, editor);
|
|
658
|
+
}
|
|
628
659
|
}
|
|
629
660
|
});
|
|
630
661
|
},
|
|
@@ -31,6 +31,20 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
31
31
|
};
|
|
32
32
|
return __assign.apply(this, arguments);
|
|
33
33
|
};
|
|
34
|
+
var CELL_EDIT_INPUT_EXTRA_RIGHT_PX = 10;
|
|
35
|
+
function measureCellEditorContentWidth(el) {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!el) return 0;
|
|
38
|
+
try {
|
|
39
|
+
var range = document.createRange();
|
|
40
|
+
range.selectNodeContents(el);
|
|
41
|
+
var w = range.getBoundingClientRect().width;
|
|
42
|
+
(_a = range.detach) === null || _a === void 0 ? void 0 : _a.call(range);
|
|
43
|
+
return w;
|
|
44
|
+
} catch (_b) {
|
|
45
|
+
return el.scrollWidth;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
34
48
|
var InputBox = function InputBox() {
|
|
35
49
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
36
50
|
var _q = (0, _react.useContext)(_context.default),
|
|
@@ -80,23 +94,29 @@ var InputBox = function InputBox() {
|
|
|
80
94
|
var _1 = (0, _react.useState)(false),
|
|
81
95
|
showSearchHint = _1[0],
|
|
82
96
|
setShowSearchHint = _1[1];
|
|
97
|
+
var _2 = (0, _react.useState)(0),
|
|
98
|
+
editorLayoutTick = _2[0],
|
|
99
|
+
setEditorLayoutTick = _2[1];
|
|
100
|
+
var _3 = (0, _react.useState)(false),
|
|
101
|
+
cellEditorExtendRight = _3[0],
|
|
102
|
+
setCellEditorExtendRight = _3[1];
|
|
83
103
|
var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
84
104
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
85
105
|
var isComposingRef = (0, _react.useRef)(false);
|
|
86
106
|
var formulaAnchorCellRef = (0, _react.useRef)(null);
|
|
87
107
|
var skipNextAnchorSelectionSyncRef = (0, _react.useRef)(false);
|
|
88
108
|
var lastHandledMouseDragSignatureRef = (0, _react.useRef)("");
|
|
89
|
-
var
|
|
90
|
-
preTextRef =
|
|
91
|
-
resetFormulaHistory =
|
|
92
|
-
handleFormulaHistoryUndoRedo =
|
|
93
|
-
capturePreEditorHistoryState =
|
|
94
|
-
appendEditorHistoryFromPrimaryEditor =
|
|
109
|
+
var _4 = (0, _useFormulaEditorHistory.useFormulaEditorHistory)(inputRef, refs.cellInput, refs.fxInput, setContext, "cell"),
|
|
110
|
+
preTextRef = _4.preTextRef,
|
|
111
|
+
resetFormulaHistory = _4.resetFormulaHistory,
|
|
112
|
+
handleFormulaHistoryUndoRedo = _4.handleFormulaHistoryUndoRedo,
|
|
113
|
+
capturePreEditorHistoryState = _4.capturePreEditorHistoryState,
|
|
114
|
+
appendEditorHistoryFromPrimaryEditor = _4.appendEditorHistoryFromPrimaryEditor;
|
|
95
115
|
var ZWSP = "\u200B";
|
|
96
116
|
var inputBoxInnerRef = (0, _react.useRef)(null);
|
|
97
|
-
var
|
|
98
|
-
linkSelectionHighlightRects =
|
|
99
|
-
setLinkSelectionHighlightRects =
|
|
117
|
+
var _5 = (0, _react.useState)([]),
|
|
118
|
+
linkSelectionHighlightRects = _5[0],
|
|
119
|
+
setLinkSelectionHighlightRects = _5[1];
|
|
100
120
|
var ensureNotEmpty = function ensureNotEmpty() {
|
|
101
121
|
var el = inputRef.current;
|
|
102
122
|
if (!el) return;
|
|
@@ -749,6 +769,19 @@ var InputBox = function InputBox() {
|
|
|
749
769
|
var rowReadOnly = cfg.rowReadOnly || {};
|
|
750
770
|
var colReadOnly = cfg.colReadOnly || {};
|
|
751
771
|
var edit = !((colReadOnly[col_index] || rowReadOnly[row_index]) && context.allowEdit === true);
|
|
772
|
+
var onInputBoxInnerMouseDown = (0, _react.useCallback)(function (e) {
|
|
773
|
+
if (!edit || isHidenRC || context.luckysheetCellUpdate.length === 0) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
var editor = refs.cellInput.current;
|
|
777
|
+
if (!editor) return;
|
|
778
|
+
if (editor.contains(e.target)) return;
|
|
779
|
+
e.preventDefault();
|
|
780
|
+
(0, _helper.moveCursorToEnd)(editor);
|
|
781
|
+
setContext(function (draftCtx) {
|
|
782
|
+
(0, _fortuneCore.setFormulaEditorOwner)(draftCtx, "cell");
|
|
783
|
+
});
|
|
784
|
+
}, [edit, isHidenRC, context.luckysheetCellUpdate.length, refs.cellInput, setContext]);
|
|
752
785
|
var getInputBoxPosition = (0, _react.useCallback)(function () {
|
|
753
786
|
var _a;
|
|
754
787
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show)) {
|
|
@@ -886,6 +919,20 @@ var InputBox = function InputBox() {
|
|
|
886
919
|
});
|
|
887
920
|
setLinkSelectionHighlightRects(relative);
|
|
888
921
|
}, [(_h = context.linkCard) === null || _h === void 0 ? void 0 : _h.applyToSelection, (_j = context.linkCard) === null || _j === void 0 ? void 0 : _j.selectionOffsets, (_k = context.linkCard) === null || _k === void 0 ? void 0 : _k.r, (_l = context.linkCard) === null || _l === void 0 ? void 0 : _l.c, context.luckysheetCellUpdate]);
|
|
922
|
+
(0, _react.useLayoutEffect)(function () {
|
|
923
|
+
if (context.luckysheetCellUpdate.length === 0) {
|
|
924
|
+
setCellEditorExtendRight(false);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
var baseSel = isInputBoxActive && firstSelectionActiveCell ? firstSelectionActiveCell : firstSelection;
|
|
928
|
+
var cellW = baseSel === null || baseSel === void 0 ? void 0 : baseSel.width;
|
|
929
|
+
if (cellW == null || !inputRef.current) {
|
|
930
|
+
setCellEditorExtendRight(false);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
var contentW = measureCellEditorContentWidth(inputRef.current);
|
|
934
|
+
setCellEditorExtendRight(contentW + CELL_EDIT_INPUT_EXTRA_RIGHT_PX > cellW);
|
|
935
|
+
}, [editorLayoutTick, context.luckysheetCellUpdate.length, isInputBoxActive, firstSelectionActiveCell, firstSelection, context.zoomRatio]);
|
|
889
936
|
var wraperGetCell = function wraperGetCell() {
|
|
890
937
|
var cell = getCellAddress();
|
|
891
938
|
if (activeRefCell !== cell) {
|
|
@@ -893,7 +940,26 @@ var InputBox = function InputBox() {
|
|
|
893
940
|
}
|
|
894
941
|
return activeCell || cell;
|
|
895
942
|
};
|
|
896
|
-
(0,
|
|
943
|
+
var refreshCellFormulaRangeHighlights = (0, _react.useCallback)(function () {
|
|
944
|
+
var el = inputRef.current;
|
|
945
|
+
if (!el) return;
|
|
946
|
+
setContext(function (draftCtx) {
|
|
947
|
+
var _a, _b;
|
|
948
|
+
if (draftCtx.luckysheetCellUpdate.length === 0) return;
|
|
949
|
+
if ((0, _fortuneCore.getFormulaEditorOwner)(draftCtx) !== "cell") return;
|
|
950
|
+
if (!(0, _fortuneCore.isAllowEdit)(draftCtx, draftCtx.luckysheet_select_save)) return;
|
|
951
|
+
var t = (_b = (_a = el.innerText) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
|
|
952
|
+
if (!t.startsWith("=")) return;
|
|
953
|
+
if (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start) {
|
|
954
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, el);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
draftCtx.formulaCache.selectingRangeIndex = -1;
|
|
958
|
+
(0, _fortuneCore.createRangeHightlight)(draftCtx, el.innerHTML);
|
|
959
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, el);
|
|
960
|
+
});
|
|
961
|
+
}, [setContext]);
|
|
962
|
+
(0, _useRerenderOnFormulaCaret.useRerenderOnFormulaCaret)(inputRef, context.luckysheetCellUpdate.length > 0, refreshCellFormulaRangeHighlights);
|
|
897
963
|
var getFunctionNameFromInput = (0, _react.useCallback)(function () {
|
|
898
964
|
var _a, _b;
|
|
899
965
|
var inputText = ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
|
|
@@ -930,11 +996,14 @@ var InputBox = function InputBox() {
|
|
|
930
996
|
}, wraperGetCell())), /*#__PURE__*/_react.default.createElement("div", {
|
|
931
997
|
ref: inputBoxInnerRef,
|
|
932
998
|
className: "luckysheet-input-box-inner",
|
|
933
|
-
|
|
999
|
+
onMouseDown: onInputBoxInnerMouseDown,
|
|
1000
|
+
style: inputBoxBaseSelection ? __assign(__assign({
|
|
934
1001
|
position: "relative",
|
|
935
1002
|
minWidth: inputBoxBaseSelection.width,
|
|
936
1003
|
minHeight: inputBoxBaseSelection.height
|
|
937
|
-
}, inputBoxStyle)
|
|
1004
|
+
}, inputBoxStyle), cellEditorExtendRight ? {
|
|
1005
|
+
paddingRight: 2 + CELL_EDIT_INPUT_EXTRA_RIGHT_PX
|
|
1006
|
+
} : {}) : {
|
|
938
1007
|
position: "relative"
|
|
939
1008
|
}
|
|
940
1009
|
}, /*#__PURE__*/_react.default.createElement(_ContentEditable.default, {
|
|
@@ -951,6 +1020,9 @@ var InputBox = function InputBox() {
|
|
|
951
1020
|
}
|
|
952
1021
|
ensureNotEmpty();
|
|
953
1022
|
isComposingRef.current = false;
|
|
1023
|
+
setEditorLayoutTick(function (t) {
|
|
1024
|
+
return t + 1;
|
|
1025
|
+
});
|
|
954
1026
|
},
|
|
955
1027
|
onMouseUp: function onMouseUp() {
|
|
956
1028
|
handleHideShowHint();
|
|
@@ -964,11 +1036,16 @@ var InputBox = function InputBox() {
|
|
|
964
1036
|
var editor = inputRef.current;
|
|
965
1037
|
if (!editor) return;
|
|
966
1038
|
setContext(function (draftCtx) {
|
|
1039
|
+
var _a;
|
|
967
1040
|
if (draftCtx.formulaCache.rangeSelectionActive !== true) return;
|
|
968
1041
|
var clickedInsideManagedRange = (0, _fortuneCore.getFormulaRangeIndexAtCaret)(editor) !== null;
|
|
969
1042
|
var atValidInsertionPoint = (0, _fortuneCore.isCaretAtValidFormulaRangeInsertionPoint)(editor);
|
|
970
1043
|
if (clickedInsideManagedRange || !atValidInsertionPoint) {
|
|
971
1044
|
(0, _fortuneCore.markRangeSelectionDirty)(draftCtx);
|
|
1045
|
+
if ((_a = editor.innerText) === null || _a === void 0 ? void 0 : _a.trim().startsWith("=")) {
|
|
1046
|
+
(0, _fortuneCore.createRangeHightlight)(draftCtx, editor.innerHTML);
|
|
1047
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, editor);
|
|
1048
|
+
}
|
|
972
1049
|
}
|
|
973
1050
|
});
|
|
974
1051
|
},
|
|
@@ -18,31 +18,6 @@ var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
-
var REF_TOKEN_REGEX = /((?:'(?:[^']|'')+'|[A-Za-z_][A-Za-z0-9_.]*)!)?(\$?)([A-Za-z]+)(\$?)(\d+)(?::(\$?)([A-Za-z]+)(\$?)(\d+))?/g;
|
|
22
|
-
function normalizeSheetName(raw) {
|
|
23
|
-
if (!raw) return "";
|
|
24
|
-
var noBang = raw.endsWith("!") ? raw.slice(0, -1) : raw;
|
|
25
|
-
if (noBang.startsWith("'") && noBang.endsWith("'")) {
|
|
26
|
-
return noBang.slice(1, -1).replace(/''/g, "'");
|
|
27
|
-
}
|
|
28
|
-
return noBang;
|
|
29
|
-
}
|
|
30
|
-
function remapFormulaCols(formula, formulaSheetName, movedSheetName, colMap) {
|
|
31
|
-
return formula.replace(REF_TOKEN_REGEX, function (token, sheetPrefix, colAbs0, col0, rowAbs0, row0, colAbs1, col1, rowAbs1, row1) {
|
|
32
|
-
var refSheet = normalizeSheetName(sheetPrefix) || formulaSheetName;
|
|
33
|
-
if (refSheet !== movedSheetName) return token;
|
|
34
|
-
var colIdx0 = (0, _fortuneCore.columnCharToIndex)(col0);
|
|
35
|
-
var mapped0 = colMap[colIdx0];
|
|
36
|
-
var nextCol0 = mapped0 == null ? col0 : (0, _fortuneCore.indexToColumnChar)(mapped0);
|
|
37
|
-
if (!col1) {
|
|
38
|
-
return "".concat(sheetPrefix || "").concat(colAbs0).concat(nextCol0).concat(rowAbs0).concat(row0);
|
|
39
|
-
}
|
|
40
|
-
var colIdx1 = (0, _fortuneCore.columnCharToIndex)(col1);
|
|
41
|
-
var mapped1 = colMap[colIdx1];
|
|
42
|
-
var nextCol1 = mapped1 == null ? col1 : (0, _fortuneCore.indexToColumnChar)(mapped1);
|
|
43
|
-
return "".concat(sheetPrefix || "").concat(colAbs0).concat(nextCol0).concat(rowAbs0).concat(row0, ":").concat(colAbs1).concat(nextCol1).concat(rowAbs1).concat(row1);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
21
|
function numberToColumnName(num) {
|
|
47
22
|
return (0, _fortuneCore.indexToColumnChar)(num);
|
|
48
23
|
}
|
|
@@ -307,7 +282,9 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
307
282
|
}
|
|
308
283
|
if (cell.f) {
|
|
309
284
|
var sheetName = _sheet.name || "";
|
|
310
|
-
cell.f =
|
|
285
|
+
cell.f = (0, _fortuneCore.remapFormulaReferencesByMap)(cell.f, sheetName, sheetName, {
|
|
286
|
+
colMap: colMap_1
|
|
287
|
+
});
|
|
311
288
|
}
|
|
312
289
|
}
|
|
313
290
|
});
|
|
@@ -17,29 +17,6 @@ var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack
|
|
|
17
17
|
}
|
|
18
18
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
19
19
|
};
|
|
20
|
-
var REF_TOKEN_REGEX = /((?:'(?:[^']|'')+'|[A-Za-z_][A-Za-z0-9_.]*)!)?(\$?)([A-Za-z]+)(\$?)(\d+)(?::(\$?)([A-Za-z]+)(\$?)(\d+))?/g;
|
|
21
|
-
function normalizeSheetName(raw) {
|
|
22
|
-
if (!raw) return "";
|
|
23
|
-
var noBang = raw.endsWith("!") ? raw.slice(0, -1) : raw;
|
|
24
|
-
if (noBang.startsWith("'") && noBang.endsWith("'")) {
|
|
25
|
-
return noBang.slice(1, -1).replace(/''/g, "'");
|
|
26
|
-
}
|
|
27
|
-
return noBang;
|
|
28
|
-
}
|
|
29
|
-
function remapFormulaRows(formula, formulaSheetName, movedSheetName, rowMap) {
|
|
30
|
-
return formula.replace(REF_TOKEN_REGEX, function (token, sheetPrefix, colAbs0, col0, rowAbs0, row0, colAbs1, col1, rowAbs1, row1) {
|
|
31
|
-
var refSheet = normalizeSheetName(sheetPrefix) || formulaSheetName;
|
|
32
|
-
if (refSheet !== movedSheetName) return token;
|
|
33
|
-
var mapped0 = rowMap[parseInt(row0, 10) - 1];
|
|
34
|
-
var nextRow0 = mapped0 == null ? parseInt(row0, 10) : mapped0 + 1;
|
|
35
|
-
if (!row1) {
|
|
36
|
-
return "".concat(sheetPrefix || "").concat(colAbs0).concat(col0).concat(rowAbs0).concat(nextRow0);
|
|
37
|
-
}
|
|
38
|
-
var mapped1 = rowMap[parseInt(row1, 10) - 1];
|
|
39
|
-
var nextRow1 = mapped1 == null ? parseInt(row1, 10) : mapped1 + 1;
|
|
40
|
-
return "".concat(sheetPrefix || "").concat(colAbs0).concat(col0).concat(rowAbs0).concat(nextRow0, ":").concat(colAbs1).concat(col1).concat(rowAbs1).concat(nextRow1);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
20
|
var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(containerRef, selectedLocationRef) {
|
|
44
21
|
var DOUBLE_MS = 300;
|
|
45
22
|
var START_DRAG_THRESHOLD_PX = 6;
|
|
@@ -300,7 +277,9 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
300
277
|
}
|
|
301
278
|
if (cell.f) {
|
|
302
279
|
var sheetName = _sheet.name || "";
|
|
303
|
-
cell.f =
|
|
280
|
+
cell.f = (0, _fortuneCore.remapFormulaReferencesByMap)(cell.f, sheetName, sheetName, {
|
|
281
|
+
rowMap: rowMap_1
|
|
282
|
+
});
|
|
304
283
|
}
|
|
305
284
|
}
|
|
306
285
|
});
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isFormulaSegmentBoundaryKey = isFormulaSegmentBoundaryKey;
|
|
7
|
-
var FORMULA_SEGMENT_BOUNDARY_KEYS = new Set([",", "+", "-", "*", "/", "%", "^", "&"]);
|
|
7
|
+
var FORMULA_SEGMENT_BOUNDARY_KEYS = new Set([",", "+", "-", "*", "/", "%", "^", "&", ">", "<", ")"]);
|
|
8
8
|
function isFormulaSegmentBoundaryKey(key) {
|
|
9
9
|
return FORMULA_SEGMENT_BOUNDARY_KEYS.has(key);
|
|
10
10
|
}
|
|
@@ -145,12 +145,6 @@
|
|
|
145
145
|
margin: 0px 0 0 0px;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
.fortune-selection-copy .fortune-copy {
|
|
149
|
-
position: absolute;
|
|
150
|
-
z-index: 18;
|
|
151
|
-
background-color: transparent;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
148
|
.fortune-selection-copy-hc {
|
|
155
149
|
position: absolute;
|
|
156
150
|
top: 0;
|
|
@@ -330,7 +324,7 @@
|
|
|
330
324
|
max-height: 9900px;
|
|
331
325
|
max-width: 9900px;
|
|
332
326
|
border: 2px #efc703 solid;
|
|
333
|
-
padding:
|
|
327
|
+
padding: 2px 2px;
|
|
334
328
|
margin: 0;
|
|
335
329
|
resize: none;
|
|
336
330
|
overflow: hidden;
|
|
@@ -363,6 +357,14 @@
|
|
|
363
357
|
color: forestgreen;
|
|
364
358
|
}
|
|
365
359
|
|
|
360
|
+
.luckysheet-formula-text-calc,
|
|
361
|
+
.luckysheet-formula-text-lpar,
|
|
362
|
+
.luckysheet-formula-text-comma,
|
|
363
|
+
.luckysheet-formula-text-rpar {
|
|
364
|
+
padding-left: 2px;
|
|
365
|
+
padding-right: 2px;
|
|
366
|
+
}
|
|
367
|
+
|
|
366
368
|
.luckysheet-cell-flow {
|
|
367
369
|
margin: 0;
|
|
368
370
|
padding: 0;
|
|
@@ -647,50 +649,6 @@
|
|
|
647
649
|
cursor: se-resize;
|
|
648
650
|
}
|
|
649
651
|
|
|
650
|
-
.fortune-selection-copy-top {
|
|
651
|
-
left: 0;
|
|
652
|
-
right: 0;
|
|
653
|
-
height: 2px;
|
|
654
|
-
top: 0;
|
|
655
|
-
background-position: bottom;
|
|
656
|
-
/* background-image: url("EwaAntH.gif"); */
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
.fortune-selection-copy-right {
|
|
660
|
-
top: 0;
|
|
661
|
-
bottom: 0;
|
|
662
|
-
width: 2px;
|
|
663
|
-
right: 0;
|
|
664
|
-
/* background-image: url("EwaAntV.gif"); */
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
.fortune-selection-copy-bottom {
|
|
668
|
-
left: 0;
|
|
669
|
-
right: 0;
|
|
670
|
-
height: 2px;
|
|
671
|
-
bottom: 0;
|
|
672
|
-
/* background-image: url("EwaAntH.gif"); */
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
.fortune-selection-copy-left {
|
|
676
|
-
top: 0;
|
|
677
|
-
bottom: 0;
|
|
678
|
-
width: 2px;
|
|
679
|
-
left: 0;
|
|
680
|
-
background-position: right;
|
|
681
|
-
/* background-image: url("EwaAntV.gif"); */
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
.fortune-selection-copy-hc {
|
|
685
|
-
position: absolute;
|
|
686
|
-
top: 0;
|
|
687
|
-
right: 0;
|
|
688
|
-
bottom: 0;
|
|
689
|
-
left: 0;
|
|
690
|
-
border: 2px dashed #12a5ff;
|
|
691
|
-
z-index: 8;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
652
|
.luckysheet-modal-dialog-resize {
|
|
695
653
|
position: absolute;
|
|
696
654
|
border: 2px solid #0188fb;
|
|
@@ -765,39 +723,8 @@
|
|
|
765
723
|
cursor: se-resize;
|
|
766
724
|
}
|
|
767
725
|
|
|
768
|
-
.fortune-formula-functionrange-highlight
|
|
769
|
-
background-image: none;
|
|
770
|
-
background: #0188fb;
|
|
771
|
-
position: absolute;
|
|
772
|
-
z-index: 18;
|
|
726
|
+
.fortune-formula-functionrange-highlight {
|
|
773
727
|
cursor: move;
|
|
774
|
-
opacity: 0.9;
|
|
775
|
-
box-sizing: content-box;
|
|
776
|
-
/*border: 1px solid #fff;*/
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
.fortune-formula-functionrange-highlight .fortune-selection-copy-top {
|
|
780
|
-
top: -2px;
|
|
781
|
-
border-top: 2px solid #fff;
|
|
782
|
-
border-bottom: 2px solid #fff;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
.fortune-formula-functionrange-highlight .fortune-selection-copy-right {
|
|
786
|
-
right: -2px;
|
|
787
|
-
border-left: 2px solid #fff;
|
|
788
|
-
border-right: 2px solid #fff;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
.fortune-formula-functionrange-highlight .fortune-selection-copy-bottom {
|
|
792
|
-
bottom: -2px;
|
|
793
|
-
border-top: 2px solid #fff;
|
|
794
|
-
border-bottom: 2px solid #fff;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
.fortune-formula-functionrange-highlight .fortune-selection-copy-left {
|
|
798
|
-
left: -2px;
|
|
799
|
-
border-left: 2px solid #fff;
|
|
800
|
-
border-right: 2px solid #fff;
|
|
801
728
|
}
|
|
802
729
|
|
|
803
730
|
.fortune-formula-functionrange-highlight .fortune-selection-copy-hc {
|
|
@@ -294,14 +294,6 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
294
294
|
className: "fortune-selection-copy fortune-formula-functionrange-select",
|
|
295
295
|
style: context.formulaRangeSelect
|
|
296
296
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
297
|
-
className: "fortune-selection-copy-top fortune-copy"
|
|
298
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
299
|
-
className: "fortune-selection-copy-right fortune-copy"
|
|
300
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
301
|
-
className: "fortune-selection-copy-bottom fortune-copy"
|
|
302
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
303
|
-
className: "fortune-selection-copy-left fortune-copy"
|
|
304
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
305
297
|
className: "fortune-selection-copy-hc"
|
|
306
298
|
}))), context.formulaRangeHighlight.map(function (v) {
|
|
307
299
|
var rangeIndex = v.rangeIndex,
|
|
@@ -311,16 +303,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
311
303
|
id: "fortune-formula-functionrange-highlight",
|
|
312
304
|
className: "fortune-selection-highlight fortune-formula-functionrange-highlight",
|
|
313
305
|
style: _lodash.default.omit(v, "backgroundColor")
|
|
314
|
-
},
|
|
315
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
316
|
-
key: d,
|
|
317
|
-
"data-type": d,
|
|
318
|
-
className: "fortune-selection-copy-".concat(d, " fortune-copy"),
|
|
319
|
-
style: {
|
|
320
|
-
backgroundColor: backgroundColor
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
306
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
324
307
|
className: "fortune-selection-copy-hc",
|
|
325
308
|
style: formulaRangeHighlightHcStyle(backgroundColor)
|
|
326
309
|
}));
|
|
@@ -373,14 +356,6 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
373
356
|
height: row - row_pre - 1
|
|
374
357
|
}
|
|
375
358
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
376
|
-
className: "fortune-selection-copy-top fortune-copy"
|
|
377
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
378
|
-
className: "fortune-selection-copy-right fortune-copy"
|
|
379
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
380
|
-
className: "fortune-selection-copy-bottom fortune-copy"
|
|
381
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
382
|
-
className: "fortune-selection-copy-left fortune-copy"
|
|
383
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
384
359
|
className: "fortune-selection-copy-hc"
|
|
385
360
|
}));
|
|
386
361
|
}))), /*#__PURE__*/_react.default.createElement("div", {
|