@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.
@@ -501,6 +501,13 @@ var FxEditor = function FxEditor() {
501
501
  if (editor_1) {
502
502
  setContext(function (draftCtx) {
503
503
  if (!isAllowEdit(draftCtx, draftCtx.luckysheet_select_save)) return;
504
+ if (getFormulaEditorOwner(draftCtx) !== "fx") return;
505
+ if (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start) {
506
+ rangeHightlightselected(draftCtx, editor_1);
507
+ return;
508
+ }
509
+ draftCtx.formulaCache.selectingRangeIndex = -1;
510
+ createRangeHightlight(draftCtx, editor_1.innerHTML);
504
511
  rangeHightlightselected(draftCtx, editor_1);
505
512
  });
506
513
  }
@@ -523,7 +530,26 @@ var FxEditor = function FxEditor() {
523
530
  });
524
531
  });
525
532
  }, [appendEditorHistoryFromPrimaryEditor, context.isFlvReadOnly, context.luckysheetCellUpdate, refs.cellInput, refs.fxInput, setContext]);
526
- useRerenderOnFormulaCaret(refs.fxInput, context.luckysheetCellUpdate.length > 0);
533
+ var refreshFxFormulaRangeHighlights = useCallback(function () {
534
+ var el = refs.fxInput.current;
535
+ if (!el) return;
536
+ setContext(function (draftCtx) {
537
+ var _a, _b;
538
+ if (draftCtx.luckysheetCellUpdate.length === 0) return;
539
+ if (getFormulaEditorOwner(draftCtx) !== "fx") return;
540
+ if (!isAllowEdit(draftCtx, draftCtx.luckysheet_select_save)) return;
541
+ var t = (_b = (_a = el.innerText) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
542
+ if (!t.startsWith("=")) return;
543
+ if (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start) {
544
+ rangeHightlightselected(draftCtx, el);
545
+ return;
546
+ }
547
+ draftCtx.formulaCache.selectingRangeIndex = -1;
548
+ createRangeHightlight(draftCtx, el.innerHTML);
549
+ rangeHightlightselected(draftCtx, el);
550
+ });
551
+ }, [refs.fxInput, setContext]);
552
+ useRerenderOnFormulaCaret(refs.fxInput, context.luckysheetCellUpdate.length > 0, refreshFxFormulaRangeHighlights);
527
553
  var getFunctionNameFromInput = useCallback(function () {
528
554
  var _a, _b, _c, _d;
529
555
  var inputText = ((_b = (_a = refs.fxInput) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.innerText) || "";
@@ -611,11 +637,16 @@ var FxEditor = function FxEditor() {
611
637
  var currentCommaCount = countCommasBeforeCursor(editor);
612
638
  setCommaCount(currentCommaCount);
613
639
  setContext(function (draftCtx) {
640
+ var _a;
614
641
  if (draftCtx.formulaCache.rangeSelectionActive !== true) return;
615
642
  var clickedInsideManagedRange = getFormulaRangeIndexAtCaret(editor) !== null;
616
643
  var atValidInsertionPoint = isCaretAtValidFormulaRangeInsertionPoint(editor);
617
644
  if (clickedInsideManagedRange || !atValidInsertionPoint) {
618
645
  markRangeSelectionDirty(draftCtx);
646
+ if ((_a = editor.innerText) === null || _a === void 0 ? void 0 : _a.trim().startsWith("=")) {
647
+ createRangeHightlight(draftCtx, editor.innerHTML);
648
+ rangeHightlightselected(draftCtx, editor);
649
+ }
619
650
  }
620
651
  });
621
652
  },
@@ -22,6 +22,20 @@ import { useRerenderOnFormulaCaret } from "../../hooks/useRerenderOnFormulaCaret
22
22
  import { moveCursorToEnd, getCursorPosition, setCursorPosition, buildFormulaSuggestionText, getFunctionNameFromFormulaCaretSpans, isLetterNumberPattern, countCommasBeforeCursor, shouldShowFormulaFunctionList, isEditorUndoRedoKeyEvent } from "./helper";
23
23
  import { isFormulaSegmentBoundaryKey } from "./formula-segment-boundary";
24
24
  import { LucideIcon } from "./LucideIcon";
25
+ var CELL_EDIT_INPUT_EXTRA_RIGHT_PX = 10;
26
+ function measureCellEditorContentWidth(el) {
27
+ var _a;
28
+ if (!el) return 0;
29
+ try {
30
+ var range = document.createRange();
31
+ range.selectNodeContents(el);
32
+ var w = range.getBoundingClientRect().width;
33
+ (_a = range.detach) === null || _a === void 0 ? void 0 : _a.call(range);
34
+ return w;
35
+ } catch (_b) {
36
+ return el.scrollWidth;
37
+ }
38
+ }
25
39
  var InputBox = function InputBox() {
26
40
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
27
41
  var _q = useContext(WorkbookContext),
@@ -71,23 +85,29 @@ var InputBox = function InputBox() {
71
85
  var _1 = useState(false),
72
86
  showSearchHint = _1[0],
73
87
  setShowSearchHint = _1[1];
88
+ var _2 = useState(0),
89
+ editorLayoutTick = _2[0],
90
+ setEditorLayoutTick = _2[1];
91
+ var _3 = useState(false),
92
+ cellEditorExtendRight = _3[0],
93
+ setCellEditorExtendRight = _3[1];
74
94
  var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
75
95
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
76
96
  var isComposingRef = useRef(false);
77
97
  var formulaAnchorCellRef = useRef(null);
78
98
  var skipNextAnchorSelectionSyncRef = useRef(false);
79
99
  var lastHandledMouseDragSignatureRef = useRef("");
80
- var _2 = useFormulaEditorHistory(inputRef, refs.cellInput, refs.fxInput, setContext, "cell"),
81
- preTextRef = _2.preTextRef,
82
- resetFormulaHistory = _2.resetFormulaHistory,
83
- handleFormulaHistoryUndoRedo = _2.handleFormulaHistoryUndoRedo,
84
- capturePreEditorHistoryState = _2.capturePreEditorHistoryState,
85
- appendEditorHistoryFromPrimaryEditor = _2.appendEditorHistoryFromPrimaryEditor;
100
+ var _4 = useFormulaEditorHistory(inputRef, refs.cellInput, refs.fxInput, setContext, "cell"),
101
+ preTextRef = _4.preTextRef,
102
+ resetFormulaHistory = _4.resetFormulaHistory,
103
+ handleFormulaHistoryUndoRedo = _4.handleFormulaHistoryUndoRedo,
104
+ capturePreEditorHistoryState = _4.capturePreEditorHistoryState,
105
+ appendEditorHistoryFromPrimaryEditor = _4.appendEditorHistoryFromPrimaryEditor;
86
106
  var ZWSP = "\u200B";
87
107
  var inputBoxInnerRef = useRef(null);
88
- var _3 = useState([]),
89
- linkSelectionHighlightRects = _3[0],
90
- setLinkSelectionHighlightRects = _3[1];
108
+ var _5 = useState([]),
109
+ linkSelectionHighlightRects = _5[0],
110
+ setLinkSelectionHighlightRects = _5[1];
91
111
  var ensureNotEmpty = function ensureNotEmpty() {
92
112
  var el = inputRef.current;
93
113
  if (!el) return;
@@ -740,6 +760,19 @@ var InputBox = function InputBox() {
740
760
  var rowReadOnly = cfg.rowReadOnly || {};
741
761
  var colReadOnly = cfg.colReadOnly || {};
742
762
  var edit = !((colReadOnly[col_index] || rowReadOnly[row_index]) && context.allowEdit === true);
763
+ var onInputBoxInnerMouseDown = useCallback(function (e) {
764
+ if (!edit || isHidenRC || context.luckysheetCellUpdate.length === 0) {
765
+ return;
766
+ }
767
+ var editor = refs.cellInput.current;
768
+ if (!editor) return;
769
+ if (editor.contains(e.target)) return;
770
+ e.preventDefault();
771
+ moveCursorToEnd(editor);
772
+ setContext(function (draftCtx) {
773
+ setFormulaEditorOwner(draftCtx, "cell");
774
+ });
775
+ }, [edit, isHidenRC, context.luckysheetCellUpdate.length, refs.cellInput, setContext]);
743
776
  var getInputBoxPosition = useCallback(function () {
744
777
  var _a;
745
778
  if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show)) {
@@ -877,6 +910,20 @@ var InputBox = function InputBox() {
877
910
  });
878
911
  setLinkSelectionHighlightRects(relative);
879
912
  }, [(_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]);
913
+ useLayoutEffect(function () {
914
+ if (context.luckysheetCellUpdate.length === 0) {
915
+ setCellEditorExtendRight(false);
916
+ return;
917
+ }
918
+ var baseSel = isInputBoxActive && firstSelectionActiveCell ? firstSelectionActiveCell : firstSelection;
919
+ var cellW = baseSel === null || baseSel === void 0 ? void 0 : baseSel.width;
920
+ if (cellW == null || !inputRef.current) {
921
+ setCellEditorExtendRight(false);
922
+ return;
923
+ }
924
+ var contentW = measureCellEditorContentWidth(inputRef.current);
925
+ setCellEditorExtendRight(contentW + CELL_EDIT_INPUT_EXTRA_RIGHT_PX > cellW);
926
+ }, [editorLayoutTick, context.luckysheetCellUpdate.length, isInputBoxActive, firstSelectionActiveCell, firstSelection, context.zoomRatio]);
880
927
  var wraperGetCell = function wraperGetCell() {
881
928
  var cell = getCellAddress();
882
929
  if (activeRefCell !== cell) {
@@ -884,7 +931,26 @@ var InputBox = function InputBox() {
884
931
  }
885
932
  return activeCell || cell;
886
933
  };
887
- useRerenderOnFormulaCaret(inputRef, context.luckysheetCellUpdate.length > 0);
934
+ var refreshCellFormulaRangeHighlights = useCallback(function () {
935
+ var el = inputRef.current;
936
+ if (!el) return;
937
+ setContext(function (draftCtx) {
938
+ var _a, _b;
939
+ if (draftCtx.luckysheetCellUpdate.length === 0) return;
940
+ if (getFormulaEditorOwner(draftCtx) !== "cell") return;
941
+ if (!isAllowEdit(draftCtx, draftCtx.luckysheet_select_save)) return;
942
+ var t = (_b = (_a = el.innerText) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
943
+ if (!t.startsWith("=")) return;
944
+ if (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start) {
945
+ rangeHightlightselected(draftCtx, el);
946
+ return;
947
+ }
948
+ draftCtx.formulaCache.selectingRangeIndex = -1;
949
+ createRangeHightlight(draftCtx, el.innerHTML);
950
+ rangeHightlightselected(draftCtx, el);
951
+ });
952
+ }, [setContext]);
953
+ useRerenderOnFormulaCaret(inputRef, context.luckysheetCellUpdate.length > 0, refreshCellFormulaRangeHighlights);
888
954
  var getFunctionNameFromInput = useCallback(function () {
889
955
  var _a, _b;
890
956
  var inputText = ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
@@ -921,11 +987,14 @@ var InputBox = function InputBox() {
921
987
  }, wraperGetCell())), /*#__PURE__*/React.createElement("div", {
922
988
  ref: inputBoxInnerRef,
923
989
  className: "luckysheet-input-box-inner",
924
- style: inputBoxBaseSelection ? __assign({
990
+ onMouseDown: onInputBoxInnerMouseDown,
991
+ style: inputBoxBaseSelection ? __assign(__assign({
925
992
  position: "relative",
926
993
  minWidth: inputBoxBaseSelection.width,
927
994
  minHeight: inputBoxBaseSelection.height
928
- }, inputBoxStyle) : {
995
+ }, inputBoxStyle), cellEditorExtendRight ? {
996
+ paddingRight: 2 + CELL_EDIT_INPUT_EXTRA_RIGHT_PX
997
+ } : {}) : {
929
998
  position: "relative"
930
999
  }
931
1000
  }, /*#__PURE__*/React.createElement(ContentEditable, {
@@ -942,6 +1011,9 @@ var InputBox = function InputBox() {
942
1011
  }
943
1012
  ensureNotEmpty();
944
1013
  isComposingRef.current = false;
1014
+ setEditorLayoutTick(function (t) {
1015
+ return t + 1;
1016
+ });
945
1017
  },
946
1018
  onMouseUp: function onMouseUp() {
947
1019
  handleHideShowHint();
@@ -955,11 +1027,16 @@ var InputBox = function InputBox() {
955
1027
  var editor = inputRef.current;
956
1028
  if (!editor) return;
957
1029
  setContext(function (draftCtx) {
1030
+ var _a;
958
1031
  if (draftCtx.formulaCache.rangeSelectionActive !== true) return;
959
1032
  var clickedInsideManagedRange = getFormulaRangeIndexAtCaret(editor) !== null;
960
1033
  var atValidInsertionPoint = isCaretAtValidFormulaRangeInsertionPoint(editor);
961
1034
  if (clickedInsideManagedRange || !atValidInsertionPoint) {
962
1035
  markRangeSelectionDirty(draftCtx);
1036
+ if ((_a = editor.innerText) === null || _a === void 0 ? void 0 : _a.trim().startsWith("=")) {
1037
+ createRangeHightlight(draftCtx, editor.innerHTML);
1038
+ rangeHightlightselected(draftCtx, editor);
1039
+ }
963
1040
  }
964
1041
  });
965
1042
  },
@@ -8,33 +8,8 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
10
  import { useContext, useRef } from "react";
11
- import { fixPositionOnFrozenCells, getSheetIndex, getFlowdata, colLocation, colLocationByIndex, updateContextWithSheetData, api, indexToColumnChar, columnCharToIndex } from "@fileverse-dev/fortune-core";
11
+ import { fixPositionOnFrozenCells, getSheetIndex, getFlowdata, colLocation, colLocationByIndex, updateContextWithSheetData, api, indexToColumnChar, remapFormulaReferencesByMap } from "@fileverse-dev/fortune-core";
12
12
  import WorkbookContext from "../../../context";
13
- var REF_TOKEN_REGEX = /((?:'(?:[^']|'')+'|[A-Za-z_][A-Za-z0-9_.]*)!)?(\$?)([A-Za-z]+)(\$?)(\d+)(?::(\$?)([A-Za-z]+)(\$?)(\d+))?/g;
14
- function normalizeSheetName(raw) {
15
- if (!raw) return "";
16
- var noBang = raw.endsWith("!") ? raw.slice(0, -1) : raw;
17
- if (noBang.startsWith("'") && noBang.endsWith("'")) {
18
- return noBang.slice(1, -1).replace(/''/g, "'");
19
- }
20
- return noBang;
21
- }
22
- function remapFormulaCols(formula, formulaSheetName, movedSheetName, colMap) {
23
- return formula.replace(REF_TOKEN_REGEX, function (token, sheetPrefix, colAbs0, col0, rowAbs0, row0, colAbs1, col1, rowAbs1, row1) {
24
- var refSheet = normalizeSheetName(sheetPrefix) || formulaSheetName;
25
- if (refSheet !== movedSheetName) return token;
26
- var colIdx0 = columnCharToIndex(col0);
27
- var mapped0 = colMap[colIdx0];
28
- var nextCol0 = mapped0 == null ? col0 : indexToColumnChar(mapped0);
29
- if (!col1) {
30
- return "".concat(sheetPrefix || "").concat(colAbs0).concat(nextCol0).concat(rowAbs0).concat(row0);
31
- }
32
- var colIdx1 = columnCharToIndex(col1);
33
- var mapped1 = colMap[colIdx1];
34
- var nextCol1 = mapped1 == null ? col1 : indexToColumnChar(mapped1);
35
- return "".concat(sheetPrefix || "").concat(colAbs0).concat(nextCol0).concat(rowAbs0).concat(row0, ":").concat(colAbs1).concat(nextCol1).concat(rowAbs1).concat(row1);
36
- });
37
- }
38
13
  export function numberToColumnName(num) {
39
14
  return indexToColumnChar(num);
40
15
  }
@@ -299,7 +274,9 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
299
274
  }
300
275
  if (cell.f) {
301
276
  var sheetName = _sheet.name || "";
302
- cell.f = remapFormulaCols(cell.f, sheetName, sheetName, colMap_1);
277
+ cell.f = remapFormulaReferencesByMap(cell.f, sheetName, sheetName, {
278
+ colMap: colMap_1
279
+ });
303
280
  }
304
281
  }
305
282
  });
@@ -8,31 +8,8 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
10
  import { useContext, useRef } from "react";
11
- import { fixPositionOnFrozenCells, getSheetIndex, rowLocation, getFlowdata, rowLocationByIndex, updateContextWithSheetData, api } from "@fileverse-dev/fortune-core";
11
+ import { fixPositionOnFrozenCells, getSheetIndex, rowLocation, getFlowdata, rowLocationByIndex, updateContextWithSheetData, api, remapFormulaReferencesByMap } from "@fileverse-dev/fortune-core";
12
12
  import WorkbookContext from "../../../context";
13
- var REF_TOKEN_REGEX = /((?:'(?:[^']|'')+'|[A-Za-z_][A-Za-z0-9_.]*)!)?(\$?)([A-Za-z]+)(\$?)(\d+)(?::(\$?)([A-Za-z]+)(\$?)(\d+))?/g;
14
- function normalizeSheetName(raw) {
15
- if (!raw) return "";
16
- var noBang = raw.endsWith("!") ? raw.slice(0, -1) : raw;
17
- if (noBang.startsWith("'") && noBang.endsWith("'")) {
18
- return noBang.slice(1, -1).replace(/''/g, "'");
19
- }
20
- return noBang;
21
- }
22
- function remapFormulaRows(formula, formulaSheetName, movedSheetName, rowMap) {
23
- return formula.replace(REF_TOKEN_REGEX, function (token, sheetPrefix, colAbs0, col0, rowAbs0, row0, colAbs1, col1, rowAbs1, row1) {
24
- var refSheet = normalizeSheetName(sheetPrefix) || formulaSheetName;
25
- if (refSheet !== movedSheetName) return token;
26
- var mapped0 = rowMap[parseInt(row0, 10) - 1];
27
- var nextRow0 = mapped0 == null ? parseInt(row0, 10) : mapped0 + 1;
28
- if (!row1) {
29
- return "".concat(sheetPrefix || "").concat(colAbs0).concat(col0).concat(rowAbs0).concat(nextRow0);
30
- }
31
- var mapped1 = rowMap[parseInt(row1, 10) - 1];
32
- var nextRow1 = mapped1 == null ? parseInt(row1, 10) : mapped1 + 1;
33
- return "".concat(sheetPrefix || "").concat(colAbs0).concat(col0).concat(rowAbs0).concat(nextRow0, ":").concat(colAbs1).concat(col1).concat(rowAbs1).concat(nextRow1);
34
- });
35
- }
36
13
  export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selectedLocationRef) {
37
14
  var DOUBLE_MS = 300;
38
15
  var START_DRAG_THRESHOLD_PX = 6;
@@ -293,7 +270,9 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
293
270
  }
294
271
  if (cell.f) {
295
272
  var sheetName = _sheet.name || "";
296
- cell.f = remapFormulaRows(cell.f, sheetName, sheetName, rowMap_1);
273
+ cell.f = remapFormulaReferencesByMap(cell.f, sheetName, sheetName, {
274
+ rowMap: rowMap_1
275
+ });
297
276
  }
298
277
  }
299
278
  });
@@ -1,4 +1,4 @@
1
- var FORMULA_SEGMENT_BOUNDARY_KEYS = new Set([",", "+", "-", "*", "/", "%", "^", "&"]);
1
+ var FORMULA_SEGMENT_BOUNDARY_KEYS = new Set([",", "+", "-", "*", "/", "%", "^", "&", ">", "<", ")"]);
2
2
  export function isFormulaSegmentBoundaryKey(key) {
3
3
  return FORMULA_SEGMENT_BOUNDARY_KEYS.has(key);
4
4
  }
@@ -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: 0 2px;
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 .fortune-copy {
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 {
@@ -285,14 +285,6 @@ var SheetOverlay = function SheetOverlay() {
285
285
  className: "fortune-selection-copy fortune-formula-functionrange-select",
286
286
  style: context.formulaRangeSelect
287
287
  }, /*#__PURE__*/React.createElement("div", {
288
- className: "fortune-selection-copy-top fortune-copy"
289
- }), /*#__PURE__*/React.createElement("div", {
290
- className: "fortune-selection-copy-right fortune-copy"
291
- }), /*#__PURE__*/React.createElement("div", {
292
- className: "fortune-selection-copy-bottom fortune-copy"
293
- }), /*#__PURE__*/React.createElement("div", {
294
- className: "fortune-selection-copy-left fortune-copy"
295
- }), /*#__PURE__*/React.createElement("div", {
296
288
  className: "fortune-selection-copy-hc"
297
289
  }))), context.formulaRangeHighlight.map(function (v) {
298
290
  var rangeIndex = v.rangeIndex,
@@ -302,16 +294,7 @@ var SheetOverlay = function SheetOverlay() {
302
294
  id: "fortune-formula-functionrange-highlight",
303
295
  className: "fortune-selection-highlight fortune-formula-functionrange-highlight",
304
296
  style: _.omit(v, "backgroundColor")
305
- }, ["top", "right", "bottom", "left"].map(function (d) {
306
- return /*#__PURE__*/React.createElement("div", {
307
- key: d,
308
- "data-type": d,
309
- className: "fortune-selection-copy-".concat(d, " fortune-copy"),
310
- style: {
311
- backgroundColor: backgroundColor
312
- }
313
- });
314
- }), /*#__PURE__*/React.createElement("div", {
297
+ }, /*#__PURE__*/React.createElement("div", {
315
298
  className: "fortune-selection-copy-hc",
316
299
  style: formulaRangeHighlightHcStyle(backgroundColor)
317
300
  }));
@@ -364,14 +347,6 @@ var SheetOverlay = function SheetOverlay() {
364
347
  height: row - row_pre - 1
365
348
  }
366
349
  }, /*#__PURE__*/React.createElement("div", {
367
- className: "fortune-selection-copy-top fortune-copy"
368
- }), /*#__PURE__*/React.createElement("div", {
369
- className: "fortune-selection-copy-right fortune-copy"
370
- }), /*#__PURE__*/React.createElement("div", {
371
- className: "fortune-selection-copy-bottom fortune-copy"
372
- }), /*#__PURE__*/React.createElement("div", {
373
- className: "fortune-selection-copy-left fortune-copy"
374
- }), /*#__PURE__*/React.createElement("div", {
375
350
  className: "fortune-selection-copy-hc"
376
351
  }));
377
352
  }))), /*#__PURE__*/React.createElement("div", {
@@ -9,17 +9,6 @@ function normalizeEditorHtmlSnapshot(html) {
9
9
  }
10
10
  return html !== null && html !== void 0 ? html : "";
11
11
  }
12
- function historyForLog(entries, index) {
13
- return entries.map(function (e, i) {
14
- var _a, _b;
15
- return {
16
- i: i,
17
- active: i === index,
18
- len: ((_a = e.html) !== null && _a !== void 0 ? _a : "").length,
19
- preview: ((_b = e.html) !== null && _b !== void 0 ? _b : "").replace(/\s+/g, " ").slice(0, 24)
20
- };
21
- });
22
- }
23
12
  export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _setContext, primary) {
24
13
  var preTextRef = useRef("");
25
14
  var preHtmlRef = useRef("");
@@ -45,11 +34,6 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
45
34
  var history = formulaHistoryRef.current;
46
35
  var current = history.entries[history.index];
47
36
  if (current && current.html === entry.html) {
48
- console.log("[Hist:pushSkipDuplicate]", {
49
- currentHtmlLen: current.html.length,
50
- entryHtmlLen: entry.html.length,
51
- index: history.index
52
- });
53
37
  return;
54
38
  }
55
39
  var nextEntries = history.entries.slice(0, history.index + 1);
@@ -58,16 +42,9 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
58
42
  history.entries = nextEntries;
59
43
  history.index = nextEntries.length - 1;
60
44
  history.active = true;
61
- console.log("[Hist:push]", {
62
- htmlLen: entry.html.length,
63
- caret: entry.caret,
64
- entriesLen: history.entries.length,
65
- index: history.index,
66
- entries: historyForLog(history.entries, history.index)
67
- });
68
45
  }, []);
69
46
  var applyFormulaHistoryEntry = useCallback(function (entry, preserveSelection) {
70
- var _a, _b, _c, _d, _e;
47
+ var _a, _b, _c;
71
48
  var primaryEl = primaryRef.current;
72
49
  if (!primaryEl) return;
73
50
  isApplyingHistoryRef.current = true;
@@ -88,11 +65,6 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
88
65
  } else {
89
66
  setCursorPosition(primaryEl, Math.max(0, textLen));
90
67
  }
91
- console.log("[Hist:apply]", {
92
- entryHtmlLen: ((_d = entry.html) !== null && _d !== void 0 ? _d : "").length,
93
- afterHtmlLen: ((_e = primaryEl.innerHTML) !== null && _e !== void 0 ? _e : "").length,
94
- afterTextLen: textLen
95
- });
96
68
  requestAnimationFrame(function () {
97
69
  requestAnimationFrame(function () {
98
70
  setTimeout(function () {
@@ -102,22 +74,13 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
102
74
  });
103
75
  }, [cellInputRef, fxInputRef, primary, primaryRef]);
104
76
  var handleFormulaHistoryUndoRedo = useCallback(function (isRedo) {
105
- var _a, _b, _c, _d;
77
+ var _a, _b;
106
78
  var history = formulaHistoryRef.current;
107
79
  if (!history.active || history.entries.length === 0) return false;
108
80
  var nextIndex = isRedo ? history.index + 1 : history.index - 1;
109
81
  if (nextIndex < 0 || nextIndex >= history.entries.length) {
110
- console.log("[Hist:undoRedoBoundary]", {
111
- isRedo: isRedo,
112
- index: history.index,
113
- entriesLen: history.entries.length,
114
- nextIndex: nextIndex,
115
- startedFromEmpty: startedFromEmptyRef.current,
116
- liveHtmlLen: normalizeEditorHtmlSnapshot((_b = (_a = primaryRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML) !== null && _b !== void 0 ? _b : "").length,
117
- entries: historyForLog(history.entries, history.index)
118
- });
119
82
  if (!isRedo && nextIndex < 0 && startedFromEmptyRef.current) {
120
- var liveHtml = normalizeEditorHtmlSnapshot((_d = (_c = primaryRef.current) === null || _c === void 0 ? void 0 : _c.innerHTML) !== null && _d !== void 0 ? _d : "");
83
+ var liveHtml = normalizeEditorHtmlSnapshot((_b = (_a = primaryRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML) !== null && _b !== void 0 ? _b : "");
121
84
  if (liveHtml !== "") {
122
85
  history.entries[0] = {
123
86
  html: "",
@@ -126,11 +89,6 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
126
89
  history.index = 0;
127
90
  var currentSelection_1 = primaryRef.current ? getSelectionOffsets(primaryRef.current) : undefined;
128
91
  applyFormulaHistoryEntry(history.entries[0], currentSelection_1);
129
- console.log("[Hist:undoRedoForcedEmpty]", {
130
- entriesLen: history.entries.length,
131
- index: history.index,
132
- entries: historyForLog(history.entries, history.index)
133
- });
134
92
  return true;
135
93
  }
136
94
  }
@@ -140,17 +98,10 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
140
98
  var entry = history.entries[nextIndex];
141
99
  var currentSelection = primaryRef.current ? getSelectionOffsets(primaryRef.current) : undefined;
142
100
  applyFormulaHistoryEntry(entry, currentSelection);
143
- console.log("[Hist:undoRedoApplied]", {
144
- isRedo: isRedo,
145
- nextIndex: nextIndex,
146
- entriesLen: history.entries.length,
147
- entryHtmlLen: entry.html.length,
148
- entries: historyForLog(history.entries, history.index)
149
- });
150
101
  return true;
151
102
  }, [applyFormulaHistoryEntry, primaryRef]);
152
103
  var capturePreEditorHistoryState = useCallback(function () {
153
- var _a, _b, _c;
104
+ var _a;
154
105
  var el = primaryRef.current;
155
106
  if (!el) return;
156
107
  preTextRef.current = el.innerText;
@@ -159,15 +110,6 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
159
110
  if (!formulaHistoryRef.current.active) {
160
111
  startedFromEmptyRef.current = normalizeEditorHtmlSnapshot((_a = preHtmlRef.current) !== null && _a !== void 0 ? _a : "") === "";
161
112
  }
162
- console.log("[Hist:capturePre]", {
163
- preHtmlLen: ((_b = preHtmlRef.current) !== null && _b !== void 0 ? _b : "").length,
164
- preTextLen: ((_c = preTextRef.current) !== null && _c !== void 0 ? _c : "").length,
165
- preCaret: preCaretRef.current,
166
- startedFromEmpty: startedFromEmptyRef.current,
167
- historyActive: formulaHistoryRef.current.active,
168
- entriesLen: formulaHistoryRef.current.entries.length,
169
- index: formulaHistoryRef.current.index
170
- });
171
113
  }, [primaryRef]);
172
114
  var appendEditorHistoryFromPrimaryEditor = useCallback(function (getCaret) {
173
115
  var _a, _b;
@@ -179,16 +121,6 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
179
121
  var caret = getCaret();
180
122
  var history = formulaHistoryRef.current;
181
123
  var wasInactive = !history.active || history.entries.length === 0;
182
- console.log("[Hist:appendStart]", {
183
- preHtmlLen: preHtmlSnapshot.length,
184
- currentHtmlLen: snapshotHtml.length,
185
- caret: caret,
186
- wasInactive: wasInactive,
187
- historyActive: history.active,
188
- entriesLen: history.entries.length,
189
- index: history.index,
190
- entries: historyForLog(history.entries, history.index)
191
- });
192
124
  if (wasInactive) {
193
125
  startedFromEmptyRef.current = preHtmlSnapshot === "";
194
126
  var seedHtml = preHtmlSnapshot === snapshotHtml ? "" : preHtmlSnapshot !== null && preHtmlSnapshot !== void 0 ? preHtmlSnapshot : "";
@@ -196,12 +128,6 @@ export function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _s
196
128
  html: seedHtml,
197
129
  caret: preCaretRef.current
198
130
  });
199
- } else {
200
- console.log("[Hist:seedSkippedAlreadyActive]", {
201
- index: history.index,
202
- entriesLen: history.entries.length,
203
- entries: historyForLog(history.entries, history.index)
204
- });
205
131
  }
206
132
  pushFormulaHistoryEntry({
207
133
  html: snapshotHtml,
@@ -1,2 +1,2 @@
1
1
  import { type RefObject } from "react";
2
- export declare function useRerenderOnFormulaCaret(editorRef: RefObject<HTMLDivElement | null>, editSessionActive: boolean): void;
2
+ export declare function useRerenderOnFormulaCaret(editorRef: RefObject<HTMLDivElement | null>, editSessionActive: boolean, onAfterCaretMove?: () => void): void;