@fileverse-dev/fortune-react 1.2.86-pinyin-8 → 1.2.87

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.
@@ -8,7 +8,7 @@ var __assign = this && this.__assign || function () {
8
8
  };
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
- import { cancelNormalSelected, getCellValue, getInlineStringHTML, getStyleByCell, isInlineStringCell, moveToEnd, getFlowdata, handleFormulaInput, moveHighlightCell, escapeScriptTag, valueShowEs, createRangeHightlight, isShowHidenCR, israngeseleciton, escapeHTMLTag, isAllowEdit, getrangeseleciton, indexToColumnChar, handleBold, handleItalic, handleUnderline, handleStrikeThrough, setCellValue } from "@fileverse-dev/fortune-core";
11
+ import { cancelNormalSelected, getCellValue, getInlineStringHTML, getStyleByCell, isInlineStringCell, moveToEnd, getFlowdata, handleFormulaInput, moveHighlightCell, escapeScriptTag, valueShowEs, createRangeHightlight, isShowHidenCR, israngeseleciton, escapeHTMLTag, isAllowEdit, getrangeseleciton, indexToColumnChar, handleBold, handleItalic, handleUnderline, handleStrikeThrough } from "@fileverse-dev/fortune-core";
12
12
  import React, { useContext, useEffect, useMemo, useRef, useCallback, useLayoutEffect, useState } from "react";
13
13
  import _ from "lodash";
14
14
  import { Tooltip } from "@fileverse/ui";
@@ -65,24 +65,6 @@ var InputBox = function InputBox() {
65
65
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
66
66
  var preText = useRef("");
67
67
  var placeRef = useRef("");
68
- var rootRef = useRef(null);
69
- var isComposingRef = useRef(false);
70
- var placeCursorAtEnd = function placeCursorAtEnd(el) {
71
- var range = document.createRange();
72
- var sel = window.getSelection();
73
- range.selectNodeContents(el);
74
- range.collapse(false);
75
- sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
76
- sel === null || sel === void 0 ? void 0 : sel.addRange(range);
77
- };
78
- var ensureNotEmpty = function ensureNotEmpty() {
79
- var el = rootRef.current;
80
- if (!el) return;
81
- if (el.textContent === "") {
82
- el.innerHTML = "\u200B";
83
- placeCursorAtEnd(el);
84
- }
85
- };
86
68
  var handleShowFormulaHint = function handleShowFormulaHint() {
87
69
  localStorage.setItem("formulaMore", String(showFormulaHint));
88
70
  setShowFormulaHint(!showFormulaHint);
@@ -148,7 +130,7 @@ var InputBox = function InputBox() {
148
130
  }
149
131
  }
150
132
  refs.globalCache.overwriteCell = false;
151
- if (!refs.globalCache.ignoreWriteCell && inputRef.current) inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
133
+ if (!refs.globalCache.ignoreWriteCell) inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
152
134
  refs.globalCache.ignoreWriteCell = false;
153
135
  if (!refs.globalCache.doNotFocus) {
154
136
  setTimeout(function () {
@@ -170,7 +152,6 @@ var InputBox = function InputBox() {
170
152
  }, [context.luckysheet_select_save]);
171
153
  useEffect(function () {
172
154
  var _a;
173
- if (isComposingRef.current) return;
174
155
  if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _.isEmpty(context.luckysheetCellUpdate)) {
175
156
  setIsInputBoxActive(false);
176
157
  }
@@ -180,7 +161,6 @@ var InputBox = function InputBox() {
180
161
  }, []);
181
162
  var insertSelectedFormula = useCallback(function (formulaName) {
182
163
  var _a;
183
- if (isComposingRef.current) return;
184
164
  if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
185
165
  var ht = "<span dir=\"auto\" class=\"luckysheet-formula-text-color\">=</span><span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span><span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>");
186
166
  inputRef.current.innerHTML = ht;
@@ -245,7 +225,6 @@ var InputBox = function InputBox() {
245
225
  }, [getActiveFormula]);
246
226
  var selectActiveFormula = useCallback(function (e) {
247
227
  var _a, _b;
248
- if (isComposingRef.current) return;
249
228
  var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
250
229
  var lastSpanText = getLastInputSpanText();
251
230
  if (formulaName && !isLetterNumberPattern(lastSpanText)) {
@@ -256,7 +235,6 @@ var InputBox = function InputBox() {
256
235
  }, [getActiveFormula, insertSelectedFormula]);
257
236
  var selectActiveFormulaOnClick = useCallback(function (e) {
258
237
  var _a, _b;
259
- if (isComposingRef.current || !inputRef.current) return;
260
238
  if (e.target.className.includes("sign-fortune")) return;
261
239
  preText.current = inputRef.current.innerText;
262
240
  var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
@@ -273,10 +251,6 @@ var InputBox = function InputBox() {
273
251
  };
274
252
  var onKeyDown = useCallback(function (e) {
275
253
  var _a, _b;
276
- if (isComposingRef.current || !inputRef.current) {
277
- ensureNotEmpty();
278
- return;
279
- }
280
254
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
281
255
  preText.current = inputRef.current.innerText;
282
256
  if (e.metaKey) {
@@ -294,10 +268,8 @@ var InputBox = function InputBox() {
294
268
  stopPropagation(e);
295
269
  }
296
270
  }
297
- if (!isComposingRef.current) {
298
- var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
299
- setCommaCount(currentCommaCount);
300
- }
271
+ var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
272
+ setCommaCount(currentCommaCount);
301
273
  var allowListNavigation = true;
302
274
  if ((e.key === "Delete" || e.key === "Backspace") && getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
303
275
  setTimeout(function () {
@@ -414,9 +386,6 @@ var InputBox = function InputBox() {
414
386
  };
415
387
  var onChange = useCallback(function (__, isBlur) {
416
388
  var _a;
417
- if (isComposingRef.current) {
418
- return;
419
- }
420
389
  if (context.isFlvReadOnly) return;
421
390
  handleHideShowHint();
422
391
  if (((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.includes("=")) && /^=?[A-Za-z]*$/.test(getLastInputSpanText())) {
@@ -424,10 +393,8 @@ var InputBox = function InputBox() {
424
393
  } else {
425
394
  setShowSearchHint(false);
426
395
  }
427
- if (!isComposingRef.current) {
428
- var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
429
- setCommaCount(currentCommaCount);
430
- }
396
+ var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
397
+ setCommaCount(currentCommaCount);
431
398
  var e = lastKeyDownEventRef.current;
432
399
  if (!e) return;
433
400
  var kcode = e.keyCode;
@@ -443,7 +410,6 @@ var InputBox = function InputBox() {
443
410
  }
444
411
  }, [refs.cellInput, refs.fxInput, setContext]);
445
412
  var onPaste = useCallback(function (e) {
446
- if (isComposingRef.current) return;
447
413
  if (_.isEmpty(context.luckysheetCellUpdate)) {
448
414
  e.preventDefault();
449
415
  }
@@ -589,44 +555,12 @@ var InputBox = function InputBox() {
589
555
  minHeight: firstSelection.height
590
556
  }, inputBoxStyle) : {}
591
557
  }, /*#__PURE__*/React.createElement(ContentEditable, {
592
- onCompositionStart: function onCompositionStart() {
593
- isComposingRef.current = true;
594
- console.log("onCompositionStart");
595
- },
596
- onCompositionUpdate: function onCompositionUpdate(e) {
597
- window.CompositData = e.currentTarget.innerText;
598
- isComposingRef.current = true;
599
- console.log("onCompositionUpdate", e.currentTarget.innerText);
600
- },
601
- onCompositionEnd: function onCompositionEnd(e) {
602
- ensureNotEmpty();
603
- var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
604
- var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
605
- console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, setCellValue);
606
- window.CompositData = e.currentTarget.innerText;
607
- setContext(function (draftCtx) {
608
- setCellValue(draftCtx, rowIndex, colIndex, null, window.CompositData);
609
- window.CompositData = "";
610
- });
611
- isComposingRef.current = false;
612
- },
613
558
  onMouseUp: function onMouseUp() {
614
- if (isComposingRef.current) {
615
- return;
616
- }
617
559
  handleHideShowHint();
618
- if (!isComposingRef.current) {
619
- var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
620
- setCommaCount(currentCommaCount);
621
- }
560
+ var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
561
+ setCommaCount(currentCommaCount);
622
562
  },
623
563
  innerRef: function innerRef(e) {
624
- rootRef.current = e;
625
- if (isComposingRef.current) {
626
- inputRef.current = null;
627
- refs.cellInput.current = null;
628
- return;
629
- }
630
564
  inputRef.current = e;
631
565
  refs.cellInput.current = e;
632
566
  },
@@ -140,6 +140,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
140
140
  handleRedo: () => void;
141
141
  calculateFormula: () => void;
142
142
  calculateSubSheetFormula: (id: string) => void;
143
+ calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
143
144
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
144
145
  celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
145
146
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
@@ -389,6 +389,12 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
389
389
  api.calculateSheetFromula(draftCtx, id);
390
390
  });
391
391
  },
392
+ calculateCellReferencedSubSheetFormula: function calculateCellReferencedSubSheetFormula(id, refCell) {
393
+ console.log("calculateCellReferencedSubSheetFormula", id, refCell);
394
+ setContext(function (draftCtx) {
395
+ api.calculateReferencedCellSheetFromula(draftCtx, id, refCell);
396
+ });
397
+ },
392
398
  dataToCelldata: function dataToCelldata(data) {
393
399
  return api.dataToCelldata(data);
394
400
  },
@@ -147,6 +147,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
147
147
  handleRedo: () => void;
148
148
  calculateFormula: () => void;
149
149
  calculateSubSheetFormula: (id: string) => void;
150
+ calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[] | undefined) => void;
150
151
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
151
152
  celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
152
153
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: (() => void) | undefined) => void;
@@ -1,13 +1,3 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
- }
7
- return t;
8
- };
9
- return __assign.apply(this, arguments);
10
- };
11
1
  var __rest = this && this.__rest || function (s, e) {
12
2
  var t = {};
13
3
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -258,16 +248,11 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
258
248
  return result;
259
249
  });
260
250
  }, [emitOp]);
261
- var handleUndo = function handleUndo() {
262
- console.log("undo poo");
251
+ var handleUndo = useCallback(function () {
263
252
  var history = globalCache.current.undoList.pop();
264
253
  if (history) {
265
254
  setContext(function (ctx_) {
266
- var _a, _b, _c, _d, _e, _f, _g;
267
- var isBorderUndo = history.patches.some(function (onePatch) {
268
- var _a;
269
- return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
270
- });
255
+ var _a, _b, _c, _d, _e;
271
256
  if ((_a = history.options) === null || _a === void 0 ? void 0 : _a.deleteSheetOp) {
272
257
  history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
273
258
  var order_1 = (_c = (_b = history.options.deletedSheet) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.order;
@@ -300,44 +285,21 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
300
285
  delete inversedOptions.addSheet.value.data;
301
286
  }
302
287
  emitOp(newContext, history.inversePatches, inversedOptions, true);
303
- var nw = __assign({}, newContext);
304
- if (isBorderUndo) {
305
- var nwborderlist = (_g = (_f = nw === null || nw === void 0 ? void 0 : nw.config) === null || _f === void 0 ? void 0 : _f.borderInfo) === null || _g === void 0 ? void 0 : _g.slice(0, -1);
306
- nw = __assign(__assign({}, nw), {
307
- config: __assign(__assign({}, nw.config), {
308
- borderInfo: nwborderlist
309
- })
310
- });
311
- }
312
- return isBorderUndo ? nw : newContext;
288
+ return newContext;
313
289
  });
314
290
  }
315
- };
316
- var handleRedo = function handleRedo() {
291
+ }, [emitOp, globalCache]);
292
+ var handleRedo = useCallback(function () {
317
293
  var history = globalCache.current.redoList.pop();
318
294
  if (history) {
319
295
  setContext(function (ctx_) {
320
- var _a, _b, _c;
321
296
  var newContext = applyPatches(ctx_, history.patches);
322
- var isBorderUndo = history.patches.some(function (onePatch) {
323
- var _a;
324
- return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
325
- });
326
297
  globalCache.current.undoList.push(history);
327
298
  emitOp(newContext, history.patches, history.options);
328
- var nw = __assign({}, newContext);
329
- if (isBorderUndo) {
330
- var nwborderlist = ((_b = (_a = nw === null || nw === void 0 ? void 0 : nw.config) === null || _a === void 0 ? void 0 : _a.borderInfo) !== null && _b !== void 0 ? _b : []).concat((_c = history.patches[0].value) === null || _c === void 0 ? void 0 : _c.borderInfo[0]);
331
- nw = __assign(__assign({}, nw), {
332
- config: __assign(__assign({}, nw.config), {
333
- borderInfo: nwborderlist
334
- })
335
- });
336
- }
337
- return isBorderUndo ? nw : newContext;
299
+ return newContext;
338
300
  });
339
301
  }
340
- };
302
+ }, [emitOp]);
341
303
  useEffect(function () {
342
304
  var _a, _b;
343
305
  (_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId);
@@ -74,24 +74,6 @@ var InputBox = function InputBox() {
74
74
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
75
75
  var preText = (0, _react.useRef)("");
76
76
  var placeRef = (0, _react.useRef)("");
77
- var rootRef = (0, _react.useRef)(null);
78
- var isComposingRef = (0, _react.useRef)(false);
79
- var placeCursorAtEnd = function placeCursorAtEnd(el) {
80
- var range = document.createRange();
81
- var sel = window.getSelection();
82
- range.selectNodeContents(el);
83
- range.collapse(false);
84
- sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
85
- sel === null || sel === void 0 ? void 0 : sel.addRange(range);
86
- };
87
- var ensureNotEmpty = function ensureNotEmpty() {
88
- var el = rootRef.current;
89
- if (!el) return;
90
- if (el.textContent === "") {
91
- el.innerHTML = "\u200B";
92
- placeCursorAtEnd(el);
93
- }
94
- };
95
77
  var handleShowFormulaHint = function handleShowFormulaHint() {
96
78
  localStorage.setItem("formulaMore", String(showFormulaHint));
97
79
  setShowFormulaHint(!showFormulaHint);
@@ -157,7 +139,7 @@ var InputBox = function InputBox() {
157
139
  }
158
140
  }
159
141
  refs.globalCache.overwriteCell = false;
160
- if (!refs.globalCache.ignoreWriteCell && inputRef.current) inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
142
+ if (!refs.globalCache.ignoreWriteCell) inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
161
143
  refs.globalCache.ignoreWriteCell = false;
162
144
  if (!refs.globalCache.doNotFocus) {
163
145
  setTimeout(function () {
@@ -179,7 +161,6 @@ var InputBox = function InputBox() {
179
161
  }, [context.luckysheet_select_save]);
180
162
  (0, _react.useEffect)(function () {
181
163
  var _a;
182
- if (isComposingRef.current) return;
183
164
  if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _lodash.default.isEmpty(context.luckysheetCellUpdate)) {
184
165
  setIsInputBoxActive(false);
185
166
  }
@@ -189,7 +170,6 @@ var InputBox = function InputBox() {
189
170
  }, []);
190
171
  var insertSelectedFormula = (0, _react.useCallback)(function (formulaName) {
191
172
  var _a;
192
- if (isComposingRef.current) return;
193
173
  if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
194
174
  var ht = "<span dir=\"auto\" class=\"luckysheet-formula-text-color\">=</span><span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span><span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>");
195
175
  inputRef.current.innerHTML = ht;
@@ -254,7 +234,6 @@ var InputBox = function InputBox() {
254
234
  }, [getActiveFormula]);
255
235
  var selectActiveFormula = (0, _react.useCallback)(function (e) {
256
236
  var _a, _b;
257
- if (isComposingRef.current) return;
258
237
  var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
259
238
  var lastSpanText = getLastInputSpanText();
260
239
  if (formulaName && !(0, _helper.isLetterNumberPattern)(lastSpanText)) {
@@ -265,7 +244,6 @@ var InputBox = function InputBox() {
265
244
  }, [getActiveFormula, insertSelectedFormula]);
266
245
  var selectActiveFormulaOnClick = (0, _react.useCallback)(function (e) {
267
246
  var _a, _b;
268
- if (isComposingRef.current || !inputRef.current) return;
269
247
  if (e.target.className.includes("sign-fortune")) return;
270
248
  preText.current = inputRef.current.innerText;
271
249
  var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
@@ -282,10 +260,6 @@ var InputBox = function InputBox() {
282
260
  };
283
261
  var onKeyDown = (0, _react.useCallback)(function (e) {
284
262
  var _a, _b;
285
- if (isComposingRef.current || !inputRef.current) {
286
- ensureNotEmpty();
287
- return;
288
- }
289
263
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
290
264
  preText.current = inputRef.current.innerText;
291
265
  if (e.metaKey) {
@@ -303,10 +277,8 @@ var InputBox = function InputBox() {
303
277
  stopPropagation(e);
304
278
  }
305
279
  }
306
- if (!isComposingRef.current) {
307
- var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
308
- setCommaCount(currentCommaCount);
309
- }
280
+ var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
281
+ setCommaCount(currentCommaCount);
310
282
  var allowListNavigation = true;
311
283
  if ((e.key === "Delete" || e.key === "Backspace") && (0, _helper.getCursorPosition)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
312
284
  setTimeout(function () {
@@ -423,9 +395,6 @@ var InputBox = function InputBox() {
423
395
  };
424
396
  var onChange = (0, _react.useCallback)(function (__, isBlur) {
425
397
  var _a;
426
- if (isComposingRef.current) {
427
- return;
428
- }
429
398
  if (context.isFlvReadOnly) return;
430
399
  handleHideShowHint();
431
400
  if (((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.includes("=")) && /^=?[A-Za-z]*$/.test(getLastInputSpanText())) {
@@ -433,10 +402,8 @@ var InputBox = function InputBox() {
433
402
  } else {
434
403
  setShowSearchHint(false);
435
404
  }
436
- if (!isComposingRef.current) {
437
- var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
438
- setCommaCount(currentCommaCount);
439
- }
405
+ var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
406
+ setCommaCount(currentCommaCount);
440
407
  var e = lastKeyDownEventRef.current;
441
408
  if (!e) return;
442
409
  var kcode = e.keyCode;
@@ -452,7 +419,6 @@ var InputBox = function InputBox() {
452
419
  }
453
420
  }, [refs.cellInput, refs.fxInput, setContext]);
454
421
  var onPaste = (0, _react.useCallback)(function (e) {
455
- if (isComposingRef.current) return;
456
422
  if (_lodash.default.isEmpty(context.luckysheetCellUpdate)) {
457
423
  e.preventDefault();
458
424
  }
@@ -598,44 +564,12 @@ var InputBox = function InputBox() {
598
564
  minHeight: firstSelection.height
599
565
  }, inputBoxStyle) : {}
600
566
  }, /*#__PURE__*/_react.default.createElement(_ContentEditable.default, {
601
- onCompositionStart: function onCompositionStart() {
602
- isComposingRef.current = true;
603
- console.log("onCompositionStart");
604
- },
605
- onCompositionUpdate: function onCompositionUpdate(e) {
606
- window.CompositData = e.currentTarget.innerText;
607
- isComposingRef.current = true;
608
- console.log("onCompositionUpdate", e.currentTarget.innerText);
609
- },
610
- onCompositionEnd: function onCompositionEnd(e) {
611
- ensureNotEmpty();
612
- var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
613
- var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
614
- console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, _fortuneCore.setCellValue);
615
- window.CompositData = e.currentTarget.innerText;
616
- setContext(function (draftCtx) {
617
- (0, _fortuneCore.setCellValue)(draftCtx, rowIndex, colIndex, null, window.CompositData);
618
- window.CompositData = "";
619
- });
620
- isComposingRef.current = false;
621
- },
622
567
  onMouseUp: function onMouseUp() {
623
- if (isComposingRef.current) {
624
- return;
625
- }
626
568
  handleHideShowHint();
627
- if (!isComposingRef.current) {
628
- var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
629
- setCommaCount(currentCommaCount);
630
- }
569
+ var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
570
+ setCommaCount(currentCommaCount);
631
571
  },
632
572
  innerRef: function innerRef(e) {
633
- rootRef.current = e;
634
- if (isComposingRef.current) {
635
- inputRef.current = null;
636
- refs.cellInput.current = null;
637
- return;
638
- }
639
573
  inputRef.current = e;
640
574
  refs.cellInput.current = e;
641
575
  },
@@ -140,6 +140,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
140
140
  handleRedo: () => void;
141
141
  calculateFormula: () => void;
142
142
  calculateSubSheetFormula: (id: string) => void;
143
+ calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
143
144
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
144
145
  celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
145
146
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
@@ -396,6 +396,12 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
396
396
  _fortuneCore.api.calculateSheetFromula(draftCtx, id);
397
397
  });
398
398
  },
399
+ calculateCellReferencedSubSheetFormula: function calculateCellReferencedSubSheetFormula(id, refCell) {
400
+ console.log("calculateCellReferencedSubSheetFormula", id, refCell);
401
+ setContext(function (draftCtx) {
402
+ _fortuneCore.api.calculateReferencedCellSheetFromula(draftCtx, id, refCell);
403
+ });
404
+ },
399
405
  dataToCelldata: function dataToCelldata(data) {
400
406
  return _fortuneCore.api.dataToCelldata(data);
401
407
  },
@@ -147,6 +147,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
147
147
  handleRedo: () => void;
148
148
  calculateFormula: () => void;
149
149
  calculateSubSheetFormula: (id: string) => void;
150
+ calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[] | undefined) => void;
150
151
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
151
152
  celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
152
153
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: (() => void) | undefined) => void;
@@ -26,16 +26,6 @@ var _SheetList = _interopRequireDefault(require("../SheetList"));
26
26
  var _DunePreview = _interopRequireDefault(require("../DunePreview/DunePreview"));
27
27
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
28
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
29
- var __assign = void 0 && (void 0).__assign || function () {
30
- __assign = Object.assign || function (t) {
31
- for (var s, i = 1, n = arguments.length; i < n; i++) {
32
- s = arguments[i];
33
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34
- }
35
- return t;
36
- };
37
- return __assign.apply(this, arguments);
38
- };
39
29
  var __rest = void 0 && (void 0).__rest || function (s, e) {
40
30
  var t = {};
41
31
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -267,16 +257,11 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
267
257
  return result;
268
258
  });
269
259
  }, [emitOp]);
270
- var handleUndo = function handleUndo() {
271
- console.log("undo poo");
260
+ var handleUndo = (0, _react.useCallback)(function () {
272
261
  var history = globalCache.current.undoList.pop();
273
262
  if (history) {
274
263
  setContext(function (ctx_) {
275
- var _a, _b, _c, _d, _e, _f, _g;
276
- var isBorderUndo = history.patches.some(function (onePatch) {
277
- var _a;
278
- return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
279
- });
264
+ var _a, _b, _c, _d, _e;
280
265
  if ((_a = history.options) === null || _a === void 0 ? void 0 : _a.deleteSheetOp) {
281
266
  history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
282
267
  var order_1 = (_c = (_b = history.options.deletedSheet) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.order;
@@ -309,44 +294,21 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
309
294
  delete inversedOptions.addSheet.value.data;
310
295
  }
311
296
  emitOp(newContext, history.inversePatches, inversedOptions, true);
312
- var nw = __assign({}, newContext);
313
- if (isBorderUndo) {
314
- var nwborderlist = (_g = (_f = nw === null || nw === void 0 ? void 0 : nw.config) === null || _f === void 0 ? void 0 : _f.borderInfo) === null || _g === void 0 ? void 0 : _g.slice(0, -1);
315
- nw = __assign(__assign({}, nw), {
316
- config: __assign(__assign({}, nw.config), {
317
- borderInfo: nwborderlist
318
- })
319
- });
320
- }
321
- return isBorderUndo ? nw : newContext;
297
+ return newContext;
322
298
  });
323
299
  }
324
- };
325
- var handleRedo = function handleRedo() {
300
+ }, [emitOp, globalCache]);
301
+ var handleRedo = (0, _react.useCallback)(function () {
326
302
  var history = globalCache.current.redoList.pop();
327
303
  if (history) {
328
304
  setContext(function (ctx_) {
329
- var _a, _b, _c;
330
305
  var newContext = (0, _immer.applyPatches)(ctx_, history.patches);
331
- var isBorderUndo = history.patches.some(function (onePatch) {
332
- var _a;
333
- return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
334
- });
335
306
  globalCache.current.undoList.push(history);
336
307
  emitOp(newContext, history.patches, history.options);
337
- var nw = __assign({}, newContext);
338
- if (isBorderUndo) {
339
- var nwborderlist = ((_b = (_a = nw === null || nw === void 0 ? void 0 : nw.config) === null || _a === void 0 ? void 0 : _a.borderInfo) !== null && _b !== void 0 ? _b : []).concat((_c = history.patches[0].value) === null || _c === void 0 ? void 0 : _c.borderInfo[0]);
340
- nw = __assign(__assign({}, nw), {
341
- config: __assign(__assign({}, nw.config), {
342
- borderInfo: nwborderlist
343
- })
344
- });
345
- }
346
- return isBorderUndo ? nw : newContext;
308
+ return newContext;
347
309
  });
348
310
  }
349
- };
311
+ }, [emitOp]);
350
312
  (0, _react.useEffect)(function () {
351
313
  var _a, _b;
352
314
  (_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.86-pinyin-8",
3
+ "version": "1.2.87",
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.2.86-pinyin-8",
19
+ "@fileverse-dev/fortune-core": "1.2.87",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",