@fileverse-dev/fortune-core 1.2.32 → 1.2.33

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.
@@ -378,10 +378,10 @@ export function handleArrowKey(ctx, e) {
378
378
  }
379
379
  }
380
380
  export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
381
- var _a;
381
+ var _a, _b, _c;
382
382
  return __awaiter(this, void 0, void 0, function () {
383
- var kcode, kstr, allowEdit, last, row_index, col_index, last, row_index, col_index;
384
- return __generator(this, function (_b) {
383
+ var kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
384
+ return __generator(this, function (_d) {
385
385
  if (e.shiftKey && e.code === "Space") {
386
386
  e.stopImmediatePropagation();
387
387
  e.stopPropagation();
@@ -420,7 +420,10 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
420
420
  ctx.luckysheet_selection_range = [];
421
421
  }
422
422
  allowEdit = isAllowEdit(ctx);
423
- if (ctx.luckysheetCellUpdate.length > 0 && kstr !== "Enter" && kstr !== "Tab" && kstr !== "ArrowUp" && kstr !== "ArrowLeft" && kstr !== "ArrowRight") {
423
+ isFxInput = (_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains("fortune-fx-input");
424
+ ignoredKeys = new Set(isFxInput ? ["Enter", "Tab", "ArrowLeft", "ArrowRight"] : ["Enter", "Tab", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
425
+ restCod = !ignoredKeys.has(kstr);
426
+ if (ctx.luckysheetCellUpdate.length > 0 && restCod) {
424
427
  return [2];
425
428
  }
426
429
  if (kstr === "Enter") {
@@ -441,7 +444,7 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
441
444
  if (ctx.luckysheetCellUpdate.length > 0) {
442
445
  return [2];
443
446
  }
444
- last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
447
+ last = (_c = ctx.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[ctx.luckysheet_select_save.length - 1];
445
448
  if (!last) return [2];
446
449
  row_index = last.row_focus;
447
450
  col_index = last.column_focus;
@@ -29,7 +29,7 @@ var __assign = this && this.__assign || function () {
29
29
  };
30
30
  return __assign.apply(this, arguments);
31
31
  };
32
- import _ from "lodash";
32
+ import _, { isObject } from "lodash";
33
33
  import { handlePastedTable } from "../paste-table-helpers";
34
34
  import { getFlowdata } from "../context";
35
35
  import { execfunction } from "../modules/formula";
@@ -181,10 +181,28 @@ function postPasteCut(ctx, source, target, RowlChange) {
181
181
  ctx.formulaCache.execFunctionGlobalData = null;
182
182
  storeSheetParamALL(ctx);
183
183
  }
184
+ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
185
+ var _a;
186
+ for (var r = 0; r < d.length; r += 1) {
187
+ var x = d[r];
188
+ for (var c = 0; c < d[0].length; c += 1) {
189
+ var value = isObject(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
190
+ if (value && String(value).includes('=')) {
191
+ var cell = {};
192
+ var funcV = execfunction(ctx, String(value), r, c, undefined, undefined, true);
193
+ console.log(funcV);
194
+ cell.v = funcV[1];
195
+ cell.f = funcV[2];
196
+ cell.m = funcV[1].toString();
197
+ x[c] = cell;
198
+ }
199
+ d[r] = x;
200
+ }
201
+ }
202
+ };
184
203
  function pasteHandler(ctx, data, borderInfo) {
185
204
  var _a;
186
205
  var _b, _c, _d, _e, _f, _g;
187
- console.log("pasteHandler");
188
206
  if (ctx.luckysheet_selection_range) {
189
207
  ctx.luckysheet_selection_range = [];
190
208
  }
@@ -295,6 +313,7 @@ function pasteHandler(ctx, data, borderInfo) {
295
313
  ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config = cfg;
296
314
  }
297
315
  jfrefreshgrid(ctx, null, undefined);
316
+ handleFormulaOnPaste(ctx, d);
298
317
  } else {
299
318
  data = data.replace(/\r/g, "");
300
319
  var dataChe = [];
@@ -369,6 +388,7 @@ function pasteHandler(ctx, data, borderInfo) {
369
388
  last.row = [curR, curR + rlen - 1];
370
389
  last.column = [curC, curC + clen - 1];
371
390
  jfrefreshgrid(ctx, null, undefined);
391
+ handleFormulaOnPaste(ctx, d);
372
392
  }
373
393
  }
374
394
  function setCellHyperlink(ctx, id, r, c, link) {
@@ -388,10 +388,10 @@ function handleArrowKey(ctx, e) {
388
388
  }
389
389
  }
390
390
  function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
391
- var _a;
391
+ var _a, _b, _c;
392
392
  return __awaiter(this, void 0, void 0, function () {
393
- var kcode, kstr, allowEdit, last, row_index, col_index, last, row_index, col_index;
394
- return __generator(this, function (_b) {
393
+ var kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
394
+ return __generator(this, function (_d) {
395
395
  if (e.shiftKey && e.code === "Space") {
396
396
  e.stopImmediatePropagation();
397
397
  e.stopPropagation();
@@ -430,7 +430,10 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
430
430
  ctx.luckysheet_selection_range = [];
431
431
  }
432
432
  allowEdit = (0, _utils.isAllowEdit)(ctx);
433
- if (ctx.luckysheetCellUpdate.length > 0 && kstr !== "Enter" && kstr !== "Tab" && kstr !== "ArrowUp" && kstr !== "ArrowLeft" && kstr !== "ArrowRight") {
433
+ isFxInput = (_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains("fortune-fx-input");
434
+ ignoredKeys = new Set(isFxInput ? ["Enter", "Tab", "ArrowLeft", "ArrowRight"] : ["Enter", "Tab", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
435
+ restCod = !ignoredKeys.has(kstr);
436
+ if (ctx.luckysheetCellUpdate.length > 0 && restCod) {
434
437
  return [2];
435
438
  }
436
439
  if (kstr === "Enter") {
@@ -451,7 +454,7 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
451
454
  if (ctx.luckysheetCellUpdate.length > 0) {
452
455
  return [2];
453
456
  }
454
- last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
457
+ last = (_c = ctx.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[ctx.luckysheet_select_save.length - 1];
455
458
  if (!last) return [2];
456
459
  row_index = last.row_focus;
457
460
  col_index = last.column_focus;
@@ -10,7 +10,7 @@ exports.handlePaste = handlePaste;
10
10
  exports.handlePasteByClick = handlePasteByClick;
11
11
  exports.indexToColumnLabel = indexToColumnLabel;
12
12
  exports.parseAsLinkIfUrl = parseAsLinkIfUrl;
13
- var _lodash = _interopRequireDefault(require("lodash"));
13
+ var _lodash = _interopRequireWildcard(require("lodash"));
14
14
  var _pasteTableHelpers = require("../paste-table-helpers");
15
15
  var _context = require("../context");
16
16
  var _formula = require("../modules/formula");
@@ -26,6 +26,7 @@ var _modules = require("../modules");
26
26
  var _clipboard = _interopRequireDefault(require("../modules/clipboard"));
27
27
  var _calculateRangeCellSize = require("../paste-helpers/calculate-range-cell-size");
28
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
+ 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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
29
30
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
30
31
  var __extends = void 0 && (void 0).__extends || function () {
31
32
  var _extendStatics = function extendStatics(d, b) {
@@ -193,10 +194,28 @@ function postPasteCut(ctx, source, target, RowlChange) {
193
194
  ctx.formulaCache.execFunctionGlobalData = null;
194
195
  (0, _sheet.storeSheetParamALL)(ctx);
195
196
  }
197
+ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
198
+ var _a;
199
+ for (var r = 0; r < d.length; r += 1) {
200
+ var x = d[r];
201
+ for (var c = 0; c < d[0].length; c += 1) {
202
+ var value = (0, _lodash.isObject)(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
203
+ if (value && String(value).includes('=')) {
204
+ var cell = {};
205
+ var funcV = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true);
206
+ console.log(funcV);
207
+ cell.v = funcV[1];
208
+ cell.f = funcV[2];
209
+ cell.m = funcV[1].toString();
210
+ x[c] = cell;
211
+ }
212
+ d[r] = x;
213
+ }
214
+ }
215
+ };
196
216
  function pasteHandler(ctx, data, borderInfo) {
197
217
  var _a;
198
218
  var _b, _c, _d, _e, _f, _g;
199
- console.log("pasteHandler");
200
219
  if (ctx.luckysheet_selection_range) {
201
220
  ctx.luckysheet_selection_range = [];
202
221
  }
@@ -307,6 +326,7 @@ function pasteHandler(ctx, data, borderInfo) {
307
326
  ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config = cfg;
308
327
  }
309
328
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
329
+ handleFormulaOnPaste(ctx, d);
310
330
  } else {
311
331
  data = data.replace(/\r/g, "");
312
332
  var dataChe = [];
@@ -381,6 +401,7 @@ function pasteHandler(ctx, data, borderInfo) {
381
401
  last.row = [curR, curR + rlen - 1];
382
402
  last.column = [curC, curC + clen - 1];
383
403
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
404
+ handleFormulaOnPaste(ctx, d);
384
405
  }
385
406
  }
386
407
  function setCellHyperlink(ctx, id, r, c, link) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.32",
3
+ "version": "1.2.33",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",