@fileverse-dev/fortune-react 1.3.11-input-ref-1 → 1.3.11-input-ref-2

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.
@@ -23,11 +23,21 @@ var __assign = void 0 && (void 0).__assign || function () {
23
23
  };
24
24
  return __assign.apply(this, arguments);
25
25
  };
26
- var FormulaSearch = function FormulaSearch(props) {
27
- var _a;
28
- var _b = (0, _react.useContext)(_context.default),
29
- context = _b.context,
30
- isAuthorized = _b.settings.isAuthorized;
26
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
27
+ var t = {};
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
31
+ }
32
+ return t;
33
+ };
34
+ var FormulaSearch = function FormulaSearch(_a) {
35
+ var _b, _c, _d;
36
+ var from = _a.from,
37
+ divProps = __rest(_a, ["from"]);
38
+ var _e = (0, _react.useContext)(_context.default),
39
+ context = _e.context,
40
+ isAuthorized = _e.settings.isAuthorized;
31
41
  var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT", "DUNESIM"];
32
42
  var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
33
43
  return !authedFunction.includes(item.n);
@@ -39,39 +49,58 @@ var FormulaSearch = function FormulaSearch(props) {
39
49
  var finalFunctionCandidates = isAuthorized ? context.functionCandidates : context.functionCandidates.filter(function (item) {
40
50
  return item.t !== 20;
41
51
  });
42
- var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
52
+ var firstSelection = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0];
53
+ var cellHeightPx = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) != null ? Number(firstSelection.height_move) : 24;
54
+ var belowCellTop = cellHeightPx + 4;
43
55
  var hintRef = (0, _react.useRef)(null);
44
- var _c = (0, _react.useState)(0),
45
- top = _c[0],
46
- setTop = _c[1];
47
- var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
48
- var _a, _b, _c, _d, _e, _f;
49
- if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
50
- var hintHeight = 360;
51
- var inputBoxTop = parseInt(((_c = document.getElementById("luckysheet-input-box")) === null || _c === void 0 ? void 0 : _c.style.top) || "0", 10) - 85;
52
- var inputBottom = inputBoxTop + firstSelection.height_move;
53
- var availableBelow = window.innerHeight - inputBottom;
54
- var hintAbove = hintHeight > availableBelow;
55
- var selectionHeight = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) || 0;
56
- var divOffset = ((_d = hintRef.current) === null || _d === void 0 ? void 0 : _d.offsetHeight) || 0;
57
- var topV = hintAbove ? selectionHeight - (divOffset + 80) : selectionHeight + 4;
58
- var el = (_e = document.getElementsByClassName("fx-hint")) === null || _e === void 0 ? void 0 : _e[0];
59
- if (el && ((_f = el === null || el === void 0 ? void 0 : el.style) === null || _f === void 0 ? void 0 : _f.display) !== "none") {
56
+ var _f = (0, _react.useState)(belowCellTop),
57
+ top = _f[0],
58
+ setTop = _f[1];
59
+ var applyPlacement = (0, _react.useCallback)(function () {
60
+ var _a;
61
+ if ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) == null || firstSelection.height_move == null) {
62
+ setTop(belowCellTop);
63
+ return;
64
+ }
65
+ var fromFx = from === "fx";
66
+ var cellH = Number(firstSelection.height_move) || cellHeightPx;
67
+ if (fromFx) {
68
+ setTop(25);
69
+ return;
70
+ }
71
+ var innerEl = hintRef.current;
72
+ var popupHeight = Math.min((innerEl === null || innerEl === void 0 ? void 0 : innerEl.offsetHeight) || 360, 360);
73
+ var inputBox = document.getElementById("luckysheet-input-box");
74
+ var rect = inputBox === null || inputBox === void 0 ? void 0 : inputBox.getBoundingClientRect();
75
+ if (!rect) {
76
+ setTop(cellH + 4);
77
+ return;
78
+ }
79
+ var cellBottomViewport = rect.top + cellH;
80
+ var availableBelow = window.innerHeight - cellBottomViewport - 12;
81
+ var preferBelow = popupHeight <= availableBelow;
82
+ var topV = preferBelow ? cellH + 4 : -(popupHeight + 8);
83
+ var fxHint = (_a = document.getElementsByClassName("fx-hint")) === null || _a === void 0 ? void 0 : _a[0];
84
+ if (fxHint && fxHint.style.display !== "none") {
60
85
  topV = 25;
61
86
  }
62
87
  setTop(topV);
63
- };
64
- (0, _react.useEffect)(function () {
65
- calcuatePopUpPlacement();
66
- });
88
+ }, [belowCellTop, cellHeightPx, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top, from]);
89
+ (0, _react.useLayoutEffect)(function () {
90
+ applyPlacement();
91
+ var id = requestAnimationFrame(applyPlacement);
92
+ return function () {
93
+ cancelAnimationFrame(id);
94
+ };
95
+ }, [applyPlacement, (_c = context.defaultCandidates) === null || _c === void 0 ? void 0 : _c.length, (_d = context.functionCandidates) === null || _d === void 0 ? void 0 : _d.length, context.functionHint]);
67
96
  if (_lodash.default.isEmpty(context.functionCandidates) && _lodash.default.isEmpty(context.defaultCandidates)) return null;
68
97
  return /*#__PURE__*/_react.default.createElement("div", {
69
- className: "flex color-border-default border flex-col luckysheet-formula-search-c-p custom-scroll ".concat((props === null || props === void 0 ? void 0 : props.from) === "fx" ? "fx-search" : "cell-search"),
98
+ className: "flex color-border-default border flex-col luckysheet-formula-search-c-p custom-scroll ".concat(from === "fx" ? "fx-search" : "cell-search"),
70
99
  id: "luckysheet-formula-search-c-p",
71
100
  style: {
72
101
  top: top
73
102
  }
74
- }, /*#__PURE__*/_react.default.createElement("div", __assign({}, props, {
103
+ }, /*#__PURE__*/_react.default.createElement("div", __assign({}, divProps, {
75
104
  ref: hintRef,
76
105
  id: "luckysheet-formula-search-c",
77
106
  className: "luckysheet-formula-search-c"
@@ -65,31 +65,34 @@ var InputBox = function InputBox() {
65
65
  var _x = (0, _react.useState)(0),
66
66
  commaCount = _x[0],
67
67
  setCommaCount = _x[1];
68
+ var _y = (0, _react.useState)(false),
69
+ cellEditorIsFormula = _y[0],
70
+ setCellEditorIsFormula = _y[1];
68
71
  var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
69
- var _y = (0, _react.useState)(!hideFormulaHintLocal),
70
- showFormulaHint = _y[0],
71
- setShowFormulaHint = _y[1];
72
- var _z = (0, _react.useState)(false),
73
- showSearchHint = _z[0],
74
- setShowSearchHint = _z[1];
72
+ var _z = (0, _react.useState)(!hideFormulaHintLocal),
73
+ showFormulaHint = _z[0],
74
+ setShowFormulaHint = _z[1];
75
+ var _0 = (0, _react.useState)(false),
76
+ showSearchHint = _0[0],
77
+ setShowSearchHint = _0[1];
75
78
  var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
76
79
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
77
80
  var isComposingRef = (0, _react.useRef)(false);
78
81
  var formulaAnchorCellRef = (0, _react.useRef)(null);
79
82
  var skipNextAnchorSelectionSyncRef = (0, _react.useRef)(false);
80
83
  var lastHandledMouseDragSignatureRef = (0, _react.useRef)("");
81
- var _0 = (0, _useFormulaEditorHistory.useFormulaEditorHistory)(inputRef, refs.cellInput, refs.fxInput, setContext, "cell"),
82
- formulaHistoryRef = _0.formulaHistoryRef,
83
- preTextRef = _0.preTextRef,
84
- resetFormulaHistory = _0.resetFormulaHistory,
85
- handleFormulaHistoryUndoRedo = _0.handleFormulaHistoryUndoRedo,
86
- capturePreFormulaState = _0.capturePreFormulaState,
87
- appendFormulaHistoryFromPrimaryEditor = _0.appendFormulaHistoryFromPrimaryEditor;
84
+ var _1 = (0, _useFormulaEditorHistory.useFormulaEditorHistory)(inputRef, refs.cellInput, refs.fxInput, setContext, "cell"),
85
+ formulaHistoryRef = _1.formulaHistoryRef,
86
+ preTextRef = _1.preTextRef,
87
+ resetFormulaHistory = _1.resetFormulaHistory,
88
+ handleFormulaHistoryUndoRedo = _1.handleFormulaHistoryUndoRedo,
89
+ capturePreFormulaState = _1.capturePreFormulaState,
90
+ appendFormulaHistoryFromPrimaryEditor = _1.appendFormulaHistoryFromPrimaryEditor;
88
91
  var ZWSP = "\u200B";
89
92
  var inputBoxInnerRef = (0, _react.useRef)(null);
90
- var _1 = (0, _react.useState)([]),
91
- linkSelectionHighlightRects = _1[0],
92
- setLinkSelectionHighlightRects = _1[1];
93
+ var _2 = (0, _react.useState)([]),
94
+ linkSelectionHighlightRects = _2[0],
95
+ setLinkSelectionHighlightRects = _2[1];
93
96
  var ensureNotEmpty = function ensureNotEmpty() {
94
97
  var el = inputRef.current;
95
98
  if (!el) return;
@@ -112,12 +115,11 @@ var InputBox = function InputBox() {
112
115
  return lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText;
113
116
  };
114
117
  var inputBoxStyle = (0, _react.useMemo)(function () {
115
- var _a;
116
118
  if (firstSelectionActiveCell && context.luckysheetCellUpdate.length > 0) {
117
119
  var flowdata = (0, _fortuneCore.getFlowdata)(context);
118
120
  if (!flowdata) return {};
119
121
  var style = (0, _fortuneCore.getStyleByCell)(context, flowdata, firstSelectionActiveCell.row_focus, firstSelectionActiveCell.column_focus);
120
- if (((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.charAt(0)) === "=") {
122
+ if (cellEditorIsFormula) {
121
123
  style = __assign(__assign({}, style), {
122
124
  textAlign: "left"
123
125
  });
@@ -125,7 +127,7 @@ var InputBox = function InputBox() {
125
127
  return style;
126
128
  }
127
129
  return {};
128
- }, [context.luckysheetfile, context.currentSheetId, context.luckysheetCellUpdate, (_b = context === null || context === void 0 ? void 0 : context.luckysheetCellUpdate) === null || _b === void 0 ? void 0 : _b.length, firstSelectionActiveCell]);
130
+ }, [context.luckysheetfile, context.currentSheetId, context.luckysheetCellUpdate, (_b = context === null || context === void 0 ? void 0 : context.luckysheetCellUpdate) === null || _b === void 0 ? void 0 : _b.length, firstSelectionActiveCell, cellEditorIsFormula]);
129
131
  (0, _react.useLayoutEffect)(function () {
130
132
  var _a;
131
133
  if (!context.allowEdit) {
@@ -145,10 +147,23 @@ var InputBox = function InputBox() {
145
147
  if (_lodash.default.isEqual(prevCellUpdate, context.luckysheetCellUpdate) && prevSheetId === context.currentSheetId) {
146
148
  return;
147
149
  }
150
+ var _b = context.luckysheetCellUpdate,
151
+ ur = _b[0],
152
+ uc = _b[1];
153
+ var pending_1 = refs.globalCache.pendingTypeOverCell;
154
+ if (pending_1 && pending_1[0] === ur && pending_1[1] === uc) {
155
+ refs.globalCache.overwriteCell = false;
156
+ if (inputRef.current) {
157
+ setCellEditorIsFormula(inputRef.current.innerText.trim().startsWith("="));
158
+ }
159
+ delete refs.globalCache.doNotFocus;
160
+ return;
161
+ }
148
162
  var flowdata = (0, _fortuneCore.getFlowdata)(context);
149
163
  var cell = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _a === void 0 ? void 0 : _a[col_index];
164
+ var overwrite = refs.globalCache.overwriteCell;
150
165
  var value_1 = "";
151
- if (cell && !refs.globalCache.overwriteCell) {
166
+ if (cell && !overwrite) {
152
167
  if ((0, _fortuneCore.isInlineStringCell)(cell)) {
153
168
  value_1 = (0, _fortuneCore.getInlineStringHTML)(row_index, col_index, flowdata);
154
169
  } else if (cell.f) {
@@ -164,14 +179,20 @@ var InputBox = function InputBox() {
164
179
  }
165
180
  }
166
181
  refs.globalCache.overwriteCell = false;
182
+ var wroteEditorFromStoredCell = false;
167
183
  if (!refs.globalCache.ignoreWriteCell && inputRef.current && value_1) {
168
184
  inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
169
- } else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1) {
185
+ wroteEditorFromStoredCell = true;
186
+ } else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1 && !overwrite) {
170
187
  var valueD = (0, _fortuneCore.getCellValue)(row_index, col_index, flowdata, "f");
171
188
  inputRef.current.innerText = valueD;
189
+ wroteEditorFromStoredCell = true;
172
190
  }
173
191
  refs.globalCache.ignoreWriteCell = false;
174
- if (!refs.globalCache.doNotFocus) {
192
+ if (inputRef.current) {
193
+ setCellEditorIsFormula(inputRef.current.innerText.trim().startsWith("="));
194
+ }
195
+ if (wroteEditorFromStoredCell && !refs.globalCache.doNotFocus) {
175
196
  setTimeout(function () {
176
197
  (0, _fortuneCore.moveToEnd)(inputRef.current);
177
198
  });
@@ -184,9 +205,15 @@ var InputBox = function InputBox() {
184
205
  if (inputRef.current) {
185
206
  inputRef.current.innerHTML = "";
186
207
  }
208
+ delete refs.globalCache.pendingTypeOverCell;
209
+ setCellEditorIsFormula(false);
187
210
  resetFormulaHistory();
188
211
  }
189
- }, [context.luckysheetCellUpdate, resetFormulaHistory]);
212
+ }, [context.luckysheetCellUpdate, resetFormulaHistory, refs.globalCache]);
213
+ (0, _react.useEffect)(function () {
214
+ if (_lodash.default.isEmpty(context.luckysheetCellUpdate)) return;
215
+ delete refs.globalCache.pendingTypeOverCell;
216
+ }, [context.luckysheetCellUpdate, refs.globalCache]);
190
217
  (0, _react.useEffect)(function () {
191
218
  var _a;
192
219
  if (_lodash.default.isEmpty(context.luckysheetCellUpdate) || !refs.cellInput.current) {
@@ -477,6 +504,12 @@ var InputBox = function InputBox() {
477
504
  row_focus: anchorRow_2,
478
505
  column_focus: anchorCol_2
479
506
  }];
507
+ (0, _fortuneCore.markRangeSelectionDirty)(draftCtx);
508
+ var el = refs.cellInput.current;
509
+ if (el && el.innerText.trim().startsWith("=")) {
510
+ (0, _fortuneCore.createRangeHightlight)(draftCtx, el.innerHTML);
511
+ (0, _fortuneCore.rangeHightlightselected)(draftCtx, el);
512
+ }
480
513
  });
481
514
  }, 0);
482
515
  }
@@ -507,7 +540,7 @@ var InputBox = function InputBox() {
507
540
  e.preventDefault();
508
541
  } else if (e.key === "F4" && context.luckysheetCellUpdate.length > 0) {
509
542
  e.preventDefault();
510
- } else if (e.key === "ArrowUp" && context.luckysheetCellUpdate.length > 0 && allowListNavigation) {
543
+ } else if (!(e.metaKey || e.ctrlKey) && e.key === "ArrowUp" && context.luckysheetCellUpdate.length > 0 && allowListNavigation) {
511
544
  if (document.getElementById("luckysheet-formula-search-c")) {
512
545
  var formulaSearchContainer = document.getElementById("luckysheet-formula-search-c");
513
546
  var activeItem = formulaSearchContainer === null || formulaSearchContainer === void 0 ? void 0 : formulaSearchContainer.querySelector(".luckysheet-formula-search-item-active");
@@ -526,7 +559,7 @@ var InputBox = function InputBox() {
526
559
  }
527
560
  }
528
561
  e.preventDefault();
529
- } else if (e.key === "ArrowDown" && context.luckysheetCellUpdate.length > 0 && allowListNavigation) {
562
+ } else if (!(e.metaKey || e.ctrlKey) && e.key === "ArrowDown" && context.luckysheetCellUpdate.length > 0 && allowListNavigation) {
530
563
  if (document.getElementById("luckysheet-formula-search-c")) {
531
564
  var formulaSearchContainer = document.getElementById("luckysheet-formula-search-c");
532
565
  var activeItem = formulaSearchContainer === null || formulaSearchContainer === void 0 ? void 0 : formulaSearchContainer.querySelector(".luckysheet-formula-search-item-active");
@@ -544,7 +577,7 @@ var InputBox = function InputBox() {
544
577
  }
545
578
  e.preventDefault();
546
579
  }
547
- }, [capturePreFormulaState, clearSearchItemActiveClass, context.luckysheetCellUpdate.length, handleFormulaHistoryUndoRedo, selectActiveFormula, setContext, firstSelection]);
580
+ }, [capturePreFormulaState, clearSearchItemActiveClass, context.luckysheetCellUpdate.length, handleFormulaHistoryUndoRedo, selectActiveFormula, setContext, firstSelection, refs.cellInput]);
548
581
  var handleHideShowHint = function handleHideShowHint() {
549
582
  var _a, _b, _c, _d;
550
583
  var searchElFx = (_a = document.getElementsByClassName("fx-search")) === null || _a === void 0 ? void 0 : _a[0];
@@ -565,10 +598,12 @@ var InputBox = function InputBox() {
565
598
  }
566
599
  };
567
600
  var onChange = (0, _react.useCallback)(function (__, isBlur) {
568
- var _a, _b, _c;
601
+ var _a, _b, _c, _d, _e, _f;
569
602
  if (context.isFlvReadOnly) return;
570
603
  handleHideShowHint();
571
- setShowSearchHint((0, _helper.shouldShowFormulaFunctionList)((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== null && _a !== void 0 ? _a : null));
604
+ var editorText = (_c = (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : "";
605
+ setCellEditorIsFormula(editorText.startsWith("="));
606
+ setShowSearchHint((0, _helper.shouldShowFormulaFunctionList)((_d = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== null && _d !== void 0 ? _d : null));
572
607
  if (!isComposingRef.current) {
573
608
  var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
574
609
  setCommaCount(currentCommaCount);
@@ -576,7 +611,7 @@ var InputBox = function InputBox() {
576
611
  var e = lastKeyDownEventRef.current;
577
612
  if (!e) {
578
613
  var cellEl_1 = refs.cellInput.current;
579
- if (cellEl_1 && (((_b = cellEl_1.innerText) === null || _b === void 0 ? void 0 : _b.trim().startsWith("=")) || ((_c = cellEl_1.textContent) === null || _c === void 0 ? void 0 : _c.trim().startsWith("=")))) {
614
+ if (cellEl_1 && (((_e = cellEl_1.innerText) === null || _e === void 0 ? void 0 : _e.trim().startsWith("=")) || ((_f = cellEl_1.textContent) === null || _f === void 0 ? void 0 : _f.trim().startsWith("=")))) {
580
615
  setContext(function (draftCtx) {
581
616
  if (!(0, _fortuneCore.isAllowEdit)(draftCtx, draftCtx.luckysheet_select_save)) return;
582
617
  (0, _fortuneCore.rangeHightlightselected)(draftCtx, cellEl_1);
@@ -591,11 +626,16 @@ var InputBox = function InputBox() {
591
626
  });
592
627
  if (!(kcode >= 112 && kcode <= 123 || kcode <= 46 || kcode === 144 || kcode === 108 || e.ctrlKey || e.altKey || e.shiftKey && (kcode === 37 || kcode === 38 || kcode === 39 || kcode === 40)) || kcode === 8 || kcode === 32 || kcode === 46 || e.ctrlKey && kcode === 86) {
593
628
  setContext(function (draftCtx) {
629
+ var _a, _b;
594
630
  if ((draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start || (0, _fortuneCore.israngeseleciton)(draftCtx)) && isBlur) return;
595
631
  if (!(0, _fortuneCore.isAllowEdit)(draftCtx, draftCtx.luckysheet_select_save)) {
596
632
  return;
597
633
  }
598
634
  (0, _fortuneCore.handleFormulaInput)(draftCtx, refs.fxInput.current, refs.cellInput.current, kcode, preTextRef.current);
635
+ var cellEl = refs.cellInput.current;
636
+ if (cellEl && (((_a = cellEl.innerText) === null || _a === void 0 ? void 0 : _a.trim().startsWith("=")) || ((_b = cellEl.textContent) === null || _b === void 0 ? void 0 : _b.trim().startsWith("=")))) {
637
+ (0, _fortuneCore.rangeHightlightselected)(draftCtx, cellEl);
638
+ }
599
639
  });
600
640
  }
601
641
  }, [refs.cellInput, refs.fxInput, setContext, appendFormulaHistoryFromPrimaryEditor]);
@@ -336,9 +336,9 @@
336
336
  overflow: hidden;
337
337
  white-space: pre-wrap;
338
338
  outline: none;
339
- -webkit-box-shadow: 0 2px 5px rgb(0 0 0 / 40%);
340
- -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
341
- box-shadow: 0 2px 5px rgb(0 0 0 / 40%);
339
+ /* -webkit-box-shadow: 0 2px 5px rgb(0 0 0 / 40%);
340
+ -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); */
341
+ /* box-shadow: 0 2px 5px rgb(0 0 0 / 40%); */
342
342
  word-wrap: break-word;
343
343
  background-color: rgb(255, 255, 255);
344
344
  font-size: 13px;
@@ -58,6 +58,7 @@ var SheetOverlay = function SheetOverlay() {
58
58
  setContext(function (draftCtx) {
59
59
  var _a;
60
60
  (0, _fortuneCore.handleCellAreaMouseDown)(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, refs.cellArea.current, refs.fxInput.current, refs.canvas.current.getContext("2d"));
61
+ var keepFormulaBarFocused = draftCtx.luckysheetCellUpdate.length > 0 && draftCtx.formulaCache.formulaEditorOwner === "fx" && (draftCtx.formulaCache.rangestart || draftCtx.formulaCache.rangedrag_column_start || draftCtx.formulaCache.rangedrag_row_start || (0, _fortuneCore.israngeseleciton)(draftCtx));
61
62
  if (!_lodash.default.isEmpty((_a = draftCtx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) && refs.cellInput.current) {
62
63
  if (!(0, _fortuneCore.isAllowEdit)(draftCtx)) {
63
64
  setTimeout(function () {
@@ -69,7 +70,13 @@ var SheetOverlay = function SheetOverlay() {
69
70
  } else {
70
71
  setTimeout(function () {
71
72
  var _a;
72
- (_a = refs.cellInput.current) === null || _a === void 0 ? void 0 : _a.focus();
73
+ if (keepFormulaBarFocused && refs.fxInput.current) {
74
+ refs.fxInput.current.focus({
75
+ preventScroll: true
76
+ });
77
+ } else {
78
+ (_a = refs.cellInput.current) === null || _a === void 0 ? void 0 : _a.focus();
79
+ }
73
80
  });
74
81
  }
75
82
  }
@@ -9,7 +9,9 @@ function useRerenderOnFormulaCaret(editorRef, editSessionActive) {
9
9
  var _a = (0, _react.useState)(0),
10
10
  bump = _a[1];
11
11
  (0, _react.useEffect)(function () {
12
- if (!editSessionActive) return;
12
+ if (!editSessionActive) {
13
+ return function () {};
14
+ }
13
15
  var onSelectionChange = function onSelectionChange() {
14
16
  var _a, _b;
15
17
  var el = editorRef.current;
@@ -26,7 +28,7 @@ function useRerenderOnFormulaCaret(editorRef, editSessionActive) {
26
28
  };
27
29
  document.addEventListener("selectionchange", onSelectionChange);
28
30
  return function () {
29
- return document.removeEventListener("selectionchange", onSelectionChange);
31
+ document.removeEventListener("selectionchange", onSelectionChange);
30
32
  };
31
33
  }, [editSessionActive, editorRef]);
32
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.11-input-ref-1",
3
+ "version": "1.3.11-input-ref-2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.3.11-input-ref-1",
19
+ "@fileverse-dev/fortune-core": "1.3.11-input-ref-2",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",