@fileverse-dev/fortune-core 1.3.10 → 1.3.11-mixed

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.
Files changed (71) hide show
  1. package/es/api/range.js +20 -0
  2. package/es/api/sheet.js +30 -2
  3. package/es/events/keyboard.js +74 -37
  4. package/es/events/mouse.js +1 -0
  5. package/es/events/paste.js +124 -56
  6. package/es/locale/en.d.ts +3 -0
  7. package/es/locale/en.js +3 -0
  8. package/es/locale/es.d.ts +3 -0
  9. package/es/locale/es.js +3 -0
  10. package/es/locale/hi.d.ts +3 -0
  11. package/es/locale/hi.js +3 -0
  12. package/es/locale/index.d.ts +3 -0
  13. package/es/locale/zh.d.ts +3 -0
  14. package/es/locale/zh.js +3 -0
  15. package/es/locale/zh_tw.d.ts +3 -0
  16. package/es/locale/zh_tw.js +3 -0
  17. package/es/modules/ConditionFormat.js +26 -0
  18. package/es/modules/cell.js +58 -2
  19. package/es/modules/comment.js +129 -24
  20. package/es/modules/dataVerification.js +34 -1
  21. package/es/modules/dropCell.js +65 -1
  22. package/es/modules/format.js +12 -7
  23. package/es/modules/formula.js +14 -0
  24. package/es/modules/hyperlink.js +52 -5
  25. package/es/modules/merge.js +93 -1
  26. package/es/modules/moveCells.js +35 -9
  27. package/es/modules/rowcol.js +75 -2
  28. package/es/modules/searchReplace.js +58 -2
  29. package/es/modules/selection.js +152 -42
  30. package/es/modules/sort.js +74 -9
  31. package/es/modules/splitColumn.js +21 -0
  32. package/es/modules/toolbar.js +46 -3
  33. package/es/modules/validation.js +6 -3
  34. package/es/settings.d.ts +5 -0
  35. package/es/types.d.ts +2 -0
  36. package/lib/api/range.js +20 -0
  37. package/lib/api/sheet.js +29 -1
  38. package/lib/events/keyboard.js +74 -37
  39. package/lib/events/mouse.js +1 -0
  40. package/lib/events/paste.js +122 -54
  41. package/lib/locale/en.d.ts +3 -0
  42. package/lib/locale/en.js +3 -0
  43. package/lib/locale/es.d.ts +3 -0
  44. package/lib/locale/es.js +3 -0
  45. package/lib/locale/hi.d.ts +3 -0
  46. package/lib/locale/hi.js +3 -0
  47. package/lib/locale/index.d.ts +3 -0
  48. package/lib/locale/zh.d.ts +3 -0
  49. package/lib/locale/zh.js +3 -0
  50. package/lib/locale/zh_tw.d.ts +3 -0
  51. package/lib/locale/zh_tw.js +3 -0
  52. package/lib/modules/ConditionFormat.js +26 -0
  53. package/lib/modules/cell.js +58 -2
  54. package/lib/modules/comment.js +129 -24
  55. package/lib/modules/dataVerification.js +34 -1
  56. package/lib/modules/dropCell.js +65 -1
  57. package/lib/modules/format.js +12 -7
  58. package/lib/modules/formula.js +14 -0
  59. package/lib/modules/hyperlink.js +52 -5
  60. package/lib/modules/merge.js +93 -1
  61. package/lib/modules/moveCells.js +35 -9
  62. package/lib/modules/rowcol.js +75 -2
  63. package/lib/modules/searchReplace.js +58 -2
  64. package/lib/modules/selection.js +152 -42
  65. package/lib/modules/sort.js +74 -9
  66. package/lib/modules/splitColumn.js +21 -0
  67. package/lib/modules/toolbar.js +46 -3
  68. package/lib/modules/validation.js +6 -3
  69. package/lib/settings.d.ts +5 -0
  70. package/lib/types.d.ts +2 -0
  71. package/package.json +1 -1
@@ -396,7 +396,8 @@ function activeFormulaInput(cellInput, fxInput, ctx, row_index, col_index, rowh,
396
396
  });
397
397
  }
398
398
  function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
399
- var _a;
399
+ var _a, _b, _c;
400
+ var _d;
400
401
  var f = "=".concat(formula.toUpperCase(), "(").concat(getRangetxt(ctx, ctx.currentSheetId, {
401
402
  row: rowh,
402
403
  column: columnh
@@ -407,7 +408,20 @@ function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
407
408
  f: v[2]
408
409
  };
409
410
  setCellValue(ctx, r, c, d, value);
410
- (_a = ctx.formulaCache).execFunctionExist || (_a.execFunctionExist = []);
411
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
412
+ ctx.hooks.updateCellYdoc([{
413
+ sheetId: ctx.currentSheetId,
414
+ path: ["celldata"],
415
+ value: {
416
+ r: r,
417
+ c: c,
418
+ v: (_c = (_b = d === null || d === void 0 ? void 0 : d[r]) === null || _b === void 0 ? void 0 : _b[c]) !== null && _c !== void 0 ? _c : null
419
+ },
420
+ key: "".concat(r, "_").concat(c),
421
+ type: "update"
422
+ }]);
423
+ }
424
+ (_d = ctx.formulaCache).execFunctionExist || (_d.execFunctionExist = []);
411
425
  ctx.formulaCache.execFunctionExist.push({
412
426
  r: r,
413
427
  c: c,
@@ -836,10 +850,12 @@ export function handleFormatPainter(ctx) {
836
850
  ctx.luckysheetPaintSingle = true;
837
851
  }
838
852
  export function handleClearFormat(ctx) {
839
- var _a;
853
+ var _a, _b, _c, _d, _e, _f, _g;
840
854
  if (ctx.allowEdit === false) return;
841
855
  var flowdata = getFlowdata(ctx);
842
856
  if (!flowdata) return;
857
+ var ydocChanges = [];
858
+ var borderInfoChanged = false;
843
859
  (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.every(function (selection) {
844
860
  var _a = selection.row,
845
861
  rowSt = _a[0],
@@ -855,6 +871,17 @@ export function handleClearFormat(ctx) {
855
871
  var cell = flowdata[r][c];
856
872
  if (!cell) continue;
857
873
  flowdata[r][c] = _.pick(cell, "v", "m", "mc", "f", "ct");
874
+ ydocChanges.push({
875
+ sheetId: ctx.currentSheetId,
876
+ path: ["celldata"],
877
+ key: "".concat(r, "_").concat(c),
878
+ value: {
879
+ r: r,
880
+ c: c,
881
+ v: flowdata[r][c]
882
+ },
883
+ type: "update"
884
+ });
858
885
  }
859
886
  }
860
887
  var index = getSheetIndex(ctx, ctx.currentSheetId);
@@ -890,9 +917,25 @@ export function handleClearFormat(ctx) {
890
917
  }
891
918
  }
892
919
  ctx.luckysheetfile[index].config.borderInfo = source_borderInfo;
920
+ borderInfoChanged = true;
893
921
  }
894
922
  return true;
895
923
  });
924
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
925
+ if (borderInfoChanged) {
926
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
927
+ var borderInfo = index == null ? (_d = (_c = ctx.config) === null || _c === void 0 ? void 0 : _c.borderInfo) !== null && _d !== void 0 ? _d : [] : (_g = (_f = (_e = ctx.luckysheetfile[index]) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.borderInfo) !== null && _g !== void 0 ? _g : [];
928
+ ydocChanges.push({
929
+ sheetId: ctx.currentSheetId,
930
+ path: ["config", "borderInfo"],
931
+ value: borderInfo,
932
+ type: "update"
933
+ });
934
+ }
935
+ if (ydocChanges.length > 0) {
936
+ ctx.hooks.updateCellYdoc(ydocChanges);
937
+ }
938
+ }
896
939
  }
897
940
  export function handleTextColor(ctx, cellInput, color) {
898
941
  setAttr(ctx, cellInput, "fc", color);
@@ -66,6 +66,7 @@ var MONTH_NAME_MAP = {
66
66
  };
67
67
  var MONTH_NAMES_RE = "january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec";
68
68
  var MONTH_ABBR_RE = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec";
69
+ var MONTH_ABBR_SET = new Set(MONTH_ABBR_RE.split("|"));
69
70
  function isValidDateParts(year, month, day) {
70
71
  if (year < 1900) return false;
71
72
  if (month < 1 || month > 12) return false;
@@ -280,6 +281,7 @@ export function detectDateFormat(str) {
280
281
  var d = +m[2];
281
282
  var y = +m[3];
282
283
  if (mo && isValidDateParts(y, mo, d)) {
284
+ var isAbbr = MONTH_ABBR_SET.has(m[1].toLowerCase());
283
285
  return {
284
286
  year: y,
285
287
  month: mo,
@@ -287,7 +289,7 @@ export function detectDateFormat(str) {
287
289
  hours: 0,
288
290
  minutes: 0,
289
291
  seconds: 0,
290
- formatType: "named"
292
+ formatType: isAbbr ? "named-mdy-abbr" : "named-mdy-full"
291
293
  };
292
294
  }
293
295
  }
@@ -297,6 +299,7 @@ export function detectDateFormat(str) {
297
299
  var mo = MONTH_NAME_MAP[m[2].toLowerCase()];
298
300
  var y = +m[3];
299
301
  if (mo && isValidDateParts(y, mo, d)) {
302
+ var isAbbr = MONTH_ABBR_SET.has(m[2].toLowerCase());
300
303
  return {
301
304
  year: y,
302
305
  month: mo,
@@ -304,7 +307,7 @@ export function detectDateFormat(str) {
304
307
  hours: 0,
305
308
  minutes: 0,
306
309
  seconds: 0,
307
- formatType: "named"
310
+ formatType: isAbbr ? "named-dmy-abbr" : "named-dmy-full"
308
311
  };
309
312
  }
310
313
  }
@@ -321,7 +324,7 @@ export function detectDateFormat(str) {
321
324
  hours: 0,
322
325
  minutes: 0,
323
326
  seconds: 0,
324
- formatType: "named"
327
+ formatType: "named-abbr-dashes"
325
328
  };
326
329
  }
327
330
  }
package/es/settings.d.ts CHANGED
@@ -16,9 +16,12 @@ export type Hooks = {
16
16
  iframeListChange?: () => void;
17
17
  conditionRulesChange?: () => void;
18
18
  conditionFormatChange?: () => void;
19
+ filterSelectChange?: () => void;
20
+ filterChange?: () => void;
19
21
  cellDataChange?: () => void;
20
22
  hyperlinkChange?: () => void;
21
23
  updateCellYdoc?: (changes: SheetChangePath[]) => void;
24
+ updateAllCell?: (sheetId: string) => void;
22
25
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
23
26
  afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
24
27
  afterSelectionChange?: (sheetId: string, selection: Selection) => void;
@@ -78,6 +81,8 @@ export type Hooks = {
78
81
  afterIframesChange?: () => void;
79
82
  afterFrozenChange?: () => void;
80
83
  afterOrderChanges?: () => void;
84
+ afterColorChanges?: () => void;
85
+ afterHideChanges?: () => void;
81
86
  afterConfigChanges?: () => void;
82
87
  afterColRowChanges?: () => void;
83
88
  afterShowGridLinesChange?: () => void;
package/es/types.d.ts CHANGED
@@ -328,6 +328,8 @@ export type GlobalCache = {
328
328
  verticalScrollLock?: boolean;
329
329
  horizontalScrollLock?: boolean;
330
330
  overwriteCell?: boolean;
331
+ overwriteCellFirstChar?: string;
332
+ enteredEditByTyping?: boolean;
331
333
  ignoreWriteCell?: boolean;
332
334
  doNotFocus?: boolean;
333
335
  doNotUpdateCell?: boolean;
package/lib/api/range.js CHANGED
@@ -93,6 +93,7 @@ function setSelection(ctx, range, options) {
93
93
  }
94
94
  }
95
95
  function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpdate) {
96
+ var _a, _b, _c, _d, _e;
96
97
  if (options === void 0) {
97
98
  options = {};
98
99
  }
@@ -110,13 +111,32 @@ function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpd
110
111
  if (data.length !== rowCount || data[0].length !== columnCount) {
111
112
  throw new Error("data size does not match range");
112
113
  }
114
+ var sheet = (0, _common.getSheet)(ctx, options);
115
+ var sheetId = sheet.id || ctx.currentSheetId;
116
+ var cellChanges = [];
113
117
  for (var i = 0; i < rowCount; i += 1) {
114
118
  for (var j = 0; j < columnCount; j += 1) {
115
119
  var row = range.row[0] + i;
116
120
  var column = range.column[0] + j;
117
121
  (0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options, callAfterUpdate);
122
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && sheet.data) {
123
+ cellChanges.push({
124
+ sheetId: sheetId,
125
+ path: ["celldata"],
126
+ value: {
127
+ r: row,
128
+ c: column,
129
+ v: (_d = (_c = (_b = sheet.data) === null || _b === void 0 ? void 0 : _b[row]) === null || _c === void 0 ? void 0 : _c[column]) !== null && _d !== void 0 ? _d : null
130
+ },
131
+ key: "".concat(row, "_").concat(column),
132
+ type: "update"
133
+ });
134
+ }
118
135
  }
119
136
  }
137
+ if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
138
+ ctx.hooks.updateCellYdoc(cellChanges);
139
+ }
120
140
  }
121
141
  function setCellFormatByRange(ctx, attr, value, range, options) {
122
142
  if (options === void 0) {
package/lib/api/sheet.js CHANGED
@@ -164,7 +164,7 @@ function generateCopySheetName(ctx, sheetId) {
164
164
  return sheetCopyName;
165
165
  }
166
166
  function copySheet(ctx, sheetId) {
167
- var _a, _b, _c;
167
+ var _a, _b, _c, _d, _e;
168
168
  var index = (0, _utils.getSheetIndex)(ctx, sheetId);
169
169
  var order = ctx.luckysheetfile[index].order + 1;
170
170
  var sheetName = generateCopySheetName(ctx, sheetId);
@@ -201,6 +201,34 @@ function copySheet(ctx, sheetId) {
201
201
  var sheetOrderList = {};
202
202
  sheetOrderList[newSheetId] = order;
203
203
  _2.api.setSheetOrder(ctx, sheetOrderList);
204
+ (0, _2.changeSheet)(ctx, newSheetId, undefined, true, true);
205
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateAllCell) {
206
+ ctx.hooks.updateAllCell(newSheetId);
207
+ } else if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
208
+ var changes_1 = [];
209
+ var celldata = newSheet.celldata || (0, _common.dataToCelldata)(newSheet.data);
210
+ if (Array.isArray(celldata)) {
211
+ celldata.forEach(function (d) {
212
+ var _a;
213
+ if (d == null) return;
214
+ var r = d.r;
215
+ var c = d.c;
216
+ if (!_lodash.default.isNumber(r) || !_lodash.default.isNumber(c)) return;
217
+ changes_1.push({
218
+ sheetId: newSheetId,
219
+ path: ["celldata"],
220
+ key: "".concat(r, "_").concat(c),
221
+ value: {
222
+ r: r,
223
+ c: c,
224
+ v: (_a = d.v) !== null && _a !== void 0 ? _a : null
225
+ },
226
+ type: d.v == null ? "delete" : "update"
227
+ });
228
+ });
229
+ }
230
+ if (changes_1.length > 0) ctx.hooks.updateCellYdoc(changes_1);
231
+ }
204
232
  }
205
233
  function calculateSheetFromula(ctx, id) {
206
234
  var _a, _b, _c;
@@ -179,63 +179,72 @@ function moveToEdge(sheetData, key, curr, rowDelta, colDelta, startR, endR, star
179
179
  return colDelta === 0 ? r : c;
180
180
  }
181
181
  function handleControlPlusArrowKey(ctx, e, shiftPressed) {
182
- if (ctx.luckysheetCellUpdate.length > 0) return;
182
+ var _a, _b, _c, _d;
183
183
  var idx = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
184
184
  if (_lodash.default.isNil(idx)) return;
185
185
  var file = ctx.luckysheetfile[idx];
186
- if (!file || !file.row || !file.column) return;
187
186
  var maxRow = file.row;
188
187
  var maxCol = file.column;
189
- var last;
190
- if (ctx.luckysheet_select_save && ctx.luckysheet_select_save.length > 0) last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
188
+ if (_lodash.default.isNil(maxRow) || _lodash.default.isNil(maxCol)) return;
189
+ var last = ctx.luckysheet_select_save && ctx.luckysheet_select_save.length > 0 ? ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1] : undefined;
191
190
  if (!last) return;
192
191
  var currR = last.row_focus;
193
192
  var currC = last.column_focus;
194
193
  if (_lodash.default.isNil(currR) || _lodash.default.isNil(currC)) return;
195
- var startR = last.row[0];
196
- var endR = last.row[1];
197
- var startC = last.column[0];
198
- var endC = last.column[1];
194
+ var startR = (_a = last.row) === null || _a === void 0 ? void 0 : _a[0];
195
+ var endR = (_b = last.row) === null || _b === void 0 ? void 0 : _b[1];
196
+ var startC = (_c = last.column) === null || _c === void 0 ? void 0 : _c[0];
197
+ var endC = (_d = last.column) === null || _d === void 0 ? void 0 : _d[1];
198
+ if (_lodash.default.isNil(startR) || _lodash.default.isNil(endR) || _lodash.default.isNil(startC) || _lodash.default.isNil(endC)) {
199
+ return;
200
+ }
199
201
  var horizontalOffset = currC - endC !== 0 ? currC - endC : currC - startC;
200
202
  var verticalOffset = currR - endR !== 0 ? currR - endR : currR - startR;
201
203
  var sheetData = file.data;
202
204
  if (!sheetData) return;
203
- var selectedLimit;
204
205
  switch (e.key) {
205
206
  case "ArrowUp":
206
- selectedLimit = moveToEdge(sheetData, e.key, currC, -1, 0, startR, endR, startC, endC, maxRow, maxCol);
207
- if (shiftPressed) {
208
- (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
209
- (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
210
- } else {
211
- (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
207
+ {
208
+ var selectedLimit = moveToEdge(sheetData, e.key, currC, -1, 0, startR, endR, startC, endC, maxRow, maxCol);
209
+ if (shiftPressed) {
210
+ (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
211
+ (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
212
+ } else {
213
+ (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
214
+ }
212
215
  }
213
216
  break;
214
217
  case "ArrowDown":
215
- selectedLimit = moveToEdge(sheetData, e.key, currC, 1, 0, startR, endR, startC, endC, maxRow, maxCol);
216
- if (shiftPressed) {
217
- (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
218
- (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
219
- } else {
220
- (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
218
+ {
219
+ var selectedLimit = moveToEdge(sheetData, e.key, currC, 1, 0, startR, endR, startC, endC, maxRow, maxCol);
220
+ if (shiftPressed) {
221
+ (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
222
+ (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
223
+ } else {
224
+ (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
225
+ }
221
226
  }
222
227
  break;
223
228
  case "ArrowLeft":
224
- selectedLimit = moveToEdge(sheetData, e.key, currR, 0, -1, startR, endR, startC, endC, maxRow, maxCol);
225
- if (shiftPressed) {
226
- (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
227
- (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
228
- } else {
229
- (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
229
+ {
230
+ var selectedLimit = moveToEdge(sheetData, e.key, currR, 0, -1, startR, endR, startC, endC, maxRow, maxCol);
231
+ if (shiftPressed) {
232
+ (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
233
+ (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
234
+ } else {
235
+ (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
236
+ }
230
237
  }
231
238
  break;
232
239
  case "ArrowRight":
233
- selectedLimit = moveToEdge(sheetData, e.key, currR, 0, 1, startR, endR, startC, endC, maxRow, maxCol);
234
- if (shiftPressed) {
235
- (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
236
- (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
237
- } else {
238
- (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
240
+ {
241
+ var selectedLimit = moveToEdge(sheetData, e.key, currR, 0, 1, startR, endR, startC, endC, maxRow, maxCol);
242
+ if (shiftPressed) {
243
+ (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
244
+ (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
245
+ } else {
246
+ (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
247
+ }
239
248
  }
240
249
  break;
241
250
  default:
@@ -388,37 +397,51 @@ function handleArrowKey(ctx, e) {
388
397
  }
389
398
  }
390
399
  function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
391
- var _a, _b, _c;
400
+ var _a, _b, _c, _d;
392
401
  return __awaiter(this, void 0, void 0, function () {
393
- var kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
394
- return __generator(this, function (_d) {
402
+ var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, isEditing, inputText, isFormulaEdit, enteredByTyping, last, row_index, col_index;
403
+ return __generator(this, function (_e) {
395
404
  if (e.shiftKey && e.code === "Space") {
396
405
  e.stopImmediatePropagation();
397
406
  e.stopPropagation();
398
407
  e.preventDefault();
399
408
  return [2];
400
409
  }
410
+ handledFlvShortcut = false;
401
411
  if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyE") {
402
412
  (0, _selection.textFormat)(ctx, "center");
413
+ handledFlvShortcut = true;
403
414
  } else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
404
415
  (0, _selection.textFormat)(ctx, "left");
416
+ handledFlvShortcut = true;
405
417
  } else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
406
418
  (0, _selection.textFormat)(ctx, "right");
419
+ handledFlvShortcut = true;
407
420
  }
408
421
  if ((e.metaKey || e.ctrlKey) && e.code === "KeyK") {
409
422
  (0, _toolbar.handleLink)(ctx, cellInput);
410
423
  }
411
424
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "Semicolon") {
412
425
  (0, _selection.fillDate)(ctx);
426
+ handledFlvShortcut = true;
413
427
  }
414
428
  if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.code === "Semicolon") {
415
429
  (0, _selection.fillTime)(ctx);
430
+ handledFlvShortcut = true;
416
431
  }
417
432
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "KeyR") {
418
433
  (0, _selection.fillRightData)(ctx);
434
+ handledFlvShortcut = true;
419
435
  }
420
436
  if ((e.metaKey || e.ctrlKey) && e.code === "KeyD") {
421
437
  (0, _selection.fillDownData)(ctx);
438
+ handledFlvShortcut = true;
439
+ }
440
+ if (handledFlvShortcut) {
441
+ (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
442
+ e.stopPropagation();
443
+ e.preventDefault();
444
+ return [2];
422
445
  }
423
446
  ctx.luckysheet_select_status = false;
424
447
  kcode = e.keyCode;
@@ -485,7 +508,18 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
485
508
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
486
509
  e.preventDefault();
487
510
  } else if (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight") {
488
- handleArrowKey(ctx, e);
511
+ isEditing = ctx.luckysheetCellUpdate.length > 0;
512
+ inputText = (_d = cellInput === null || cellInput === void 0 ? void 0 : cellInput.innerText) !== null && _d !== void 0 ? _d : "";
513
+ isFormulaEdit = isEditing && inputText.trim().startsWith("=");
514
+ enteredByTyping = cache.enteredEditByTyping === true;
515
+ if (isEditing && !isFormulaEdit && enteredByTyping) {
516
+ (0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
517
+ cache.enteredEditByTyping = false;
518
+ handleArrowKey(ctx, e);
519
+ e.preventDefault();
520
+ } else {
521
+ handleArrowKey(ctx, e);
522
+ }
489
523
  } else 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 || kcode === 0 || e.ctrlKey && kcode === 86) {
490
524
  if (!allowEdit) return [2];
491
525
  if (String.fromCharCode(kcode) != null && !_lodash.default.isEmpty(ctx.luckysheet_select_save) && kstr !== "CapsLock" && kstr !== "Win" && kcode !== 18) {
@@ -494,7 +528,10 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
494
528
  col_index = last.column_focus;
495
529
  ctx.luckysheetCellUpdate = [row_index, col_index];
496
530
  cache.overwriteCell = true;
531
+ cache.overwriteCellFirstChar = e.key;
532
+ cache.enteredEditByTyping = true;
497
533
  (0, _formula.handleFormulaInput)(ctx, fxInput, cellInput, kcode);
534
+ e.preventDefault();
498
535
  }
499
536
  }
500
537
  }
@@ -508,6 +508,7 @@ function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
508
508
  row_index = row_focus;
509
509
  col_index = column_focus;
510
510
  }
511
+ globalCache.enteredEditByTyping = false;
511
512
  (0, _cell.luckysheetUpdateCell)(ctx, row_index, col_index);
512
513
  }
513
514
  function handleContextMenu(ctx, settings, e, workbookContainer, container, area) {