@fileverse-dev/fortune-core 1.0.68 → 1.0.69

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.
package/es/api/sheet.js CHANGED
@@ -112,15 +112,15 @@ export function copySheet(ctx, sheetId) {
112
112
  api.setSheetOrder(ctx, sheetOrderList);
113
113
  }
114
114
  export function calculateSheetFromula(ctx, id) {
115
- var _a, _b;
115
+ var _a, _b, _c;
116
116
  var index = getSheetIndex(ctx, id);
117
117
  if (!ctx.luckysheetfile[index].data) return;
118
118
  for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
119
119
  for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
120
- if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f)) {
120
+ if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
121
121
  continue;
122
122
  }
123
- var result = execfunction(ctx, (_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.f, r, c, id);
123
+ var result = execfunction(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
124
124
  api.setCellValue(ctx, r, c, result[1], null);
125
125
  insertUpdateFunctionGroup(ctx, r, c, id);
126
126
  }
@@ -12,7 +12,7 @@ var __assign = this && this.__assign || function () {
12
12
  import _ from "lodash";
13
13
  import { getFlowdata } from "../context";
14
14
  import { locale } from "../locale";
15
- import { delFunctionGroup, execfunction, execFunctionGroup, functionCopy } from "../modules/formula";
15
+ import { execfunction, functionCopy } from "../modules/formula";
16
16
  import { getdatabyselection, getQKBorder } from "../modules/cell";
17
17
  import { genarate, update } from "../modules/format";
18
18
  import { normalizeSelection, selectionCache } from "../modules/selection";
@@ -105,14 +105,12 @@ function postPasteCut(ctx, source, target, RowlChange) {
105
105
  ctx.luckysheetfile[getSheetIndex(ctx, source.sheetId)].dataVerification = source.curDataVerification;
106
106
  ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].dataVerification = target.curDataVerification;
107
107
  ctx.formulaCache.execFunctionExist.reverse();
108
- execFunctionGroup(ctx, null, null, null, null, target.curData);
109
108
  ctx.formulaCache.execFunctionGlobalData = null;
110
109
  storeSheetParamALL(ctx);
111
110
  }
112
111
  function pasteHandler(ctx, data, borderInfo) {
113
112
  var _a;
114
113
  var _b, _c, _d, _e, _f, _g;
115
- console.log("pasteHandler", ctx.isFlvReadOnly);
116
114
  var allowEdit = isAllowEdit(ctx);
117
115
  if (!allowEdit || ctx.isFlvReadOnly) return;
118
116
  if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
@@ -273,7 +271,6 @@ function pasteHandler(ctx, data, borderInfo) {
273
271
  }
274
272
  if (originCell.f != null && originCell.f.length > 0) {
275
273
  originCell.f = "";
276
- delFunctionGroup(ctx, r + curR, c + curC, ctx.currentSheetId);
277
274
  }
278
275
  } else {
279
276
  var cell = {};
@@ -858,6 +855,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
858
855
  var value = null;
859
856
  if ((_f = copyData[h - mth]) === null || _f === void 0 ? void 0 : _f[c - mtc]) {
860
857
  value = _.cloneDeep(copyData[h - mth][c - mtc]);
858
+ if ((value === null || value === void 0 ? void 0 : value.v) && (value === null || value === void 0 ? void 0 : value.isDataBlockFormula)) {
859
+ value.m = "Loading...";
860
+ }
861
861
  }
862
862
  if (!_.isNil(value) && !_.isNil(value.f)) {
863
863
  var func = value.f;
@@ -874,14 +874,14 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
874
874
  func = "=".concat(functionCopy(ctx, func, "left", Math.abs(offsetCol)));
875
875
  }
876
876
  var funcV = execfunction(ctx, func, h, c, undefined, undefined, true);
877
- if (!_.isNil(value.spl)) {} else {
878
- value.v = funcV[1], value.f = funcV[2];
879
- if (!_.isNil(value.ct) && !_.isNil(value.ct.fa)) {
880
- value.m = update(value.ct.fa, funcV[1]);
881
- } else {
882
- value.m = update("General", funcV[1]);
883
- }
877
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
878
+ if (afterUpdateCell && arr.length === 1) {
879
+ afterUpdateCell(h, c, null, __assign(__assign({}, value), {
880
+ v: funcV[1],
881
+ m: "[object Promise]"
882
+ }));
884
883
  }
884
+ if (!_.isNil(value.spl)) {}
885
885
  }
886
886
  x[c] = _.cloneDeep(value);
887
887
  if (value != null && copyHasMC && ((_g = x === null || x === void 0 ? void 0 : x[c]) === null || _g === void 0 ? void 0 : _g.mc)) {
@@ -970,12 +970,17 @@ function handleFormulaStringPaste(ctx, formulaStr) {
970
970
  var c = ctx.luckysheet_select_save[0].column[0];
971
971
  var funcV = execfunction(ctx, formulaStr, r, c, undefined, undefined, true);
972
972
  var val = funcV[1];
973
+ var isDataBlockRespose = typeof val !== "string" && typeof val !== "number";
973
974
  var d = getFlowdata(ctx);
974
975
  if (!d) return;
975
976
  if (!d[r][c]) d[r][c] = {};
976
- d[r][c].m = val.toString();
977
+ d[r][c].m = isDataBlockRespose ? "Loading..." : val.toString();
977
978
  d[r][c].v = val;
978
979
  d[r][c].f = formulaStr;
980
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
981
+ if (afterUpdateCell && isDataBlockRespose) {
982
+ afterUpdateCell(r, c, null, d[r][c]);
983
+ }
979
984
  }
980
985
  export function handlePaste(ctx, e) {
981
986
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
@@ -1369,7 +1374,7 @@ export function handlePasteByClick(ctx, clipboardData, triggerType) {
1369
1374
  }
1370
1375
  } else if (data.indexOf("fortune-copy-action-image") > -1) {} else if (triggerType !== "btn") {
1371
1376
  var isExcelFormula = clipboardData.startsWith("=");
1372
- if (isExcelFormula) {
1377
+ if (isExcelFormula && false) {
1373
1378
  handleFormulaStringPaste(ctx, clipboardData);
1374
1379
  } else {
1375
1380
  pasteHandler(ctx, clipboardData);
@@ -688,12 +688,12 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
688
688
  }
689
689
  if (typeof value === "string") {
690
690
  value = {
691
- "ct": {
692
- "fa": "General",
693
- "t": "g"
691
+ ct: {
692
+ fa: "General",
693
+ t: "g"
694
694
  },
695
- "v": value,
696
- "tb": "1"
695
+ v: value,
696
+ tb: "1"
697
697
  };
698
698
  } else if (_typeof(value) === "object" && !value.tb) {
699
699
  value.tb = "1";
@@ -121,8 +121,8 @@ var FormulaCache = function () {
121
121
  }
122
122
  FormulaCache.prototype.tryGetCellAsNumber = function (cell) {
123
123
  var _a, _b, _c, _d;
124
- var isCryptoDeno = ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC"));
125
- if (isCryptoDeno) {
124
+ var isCryptoDeno = typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string" ? ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC")) : false;
125
+ if (isCryptoDeno && typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string") {
126
126
  var splitedNumberString = cell.m.split(" ")[0];
127
127
  return Number(splitedNumberString);
128
128
  }
@@ -708,7 +708,7 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
708
708
  if (!_.isNil(r) && !_.isNil(c)) {
709
709
  if (isrefresh) {
710
710
  var finalResult_1 = result;
711
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
711
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
712
712
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
713
713
  finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
714
714
  }
@@ -719,7 +719,7 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
719
719
  }
720
720
  }
721
721
  var finalResult = result;
722
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
722
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
723
723
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
724
724
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
725
725
  }
package/es/types.d.ts CHANGED
@@ -45,6 +45,10 @@ export type Cell = {
45
45
  bg?: string;
46
46
  lo?: number;
47
47
  rt?: number;
48
+ baseValue?: number | string;
49
+ baseCurrency?: string;
50
+ baseCurrencyPrice?: string | number;
51
+ isDataBlockFormula?: boolean;
48
52
  ps?: {
49
53
  left: number | null;
50
54
  top: number | null;
package/lib/api/sheet.js CHANGED
@@ -129,15 +129,15 @@ function copySheet(ctx, sheetId) {
129
129
  _2.api.setSheetOrder(ctx, sheetOrderList);
130
130
  }
131
131
  function calculateSheetFromula(ctx, id) {
132
- var _a, _b;
132
+ var _a, _b, _c;
133
133
  var index = (0, _utils.getSheetIndex)(ctx, id);
134
134
  if (!ctx.luckysheetfile[index].data) return;
135
135
  for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
136
136
  for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
137
- if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f)) {
137
+ if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
138
138
  continue;
139
139
  }
140
- var result = (0, _2.execfunction)(ctx, (_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.f, r, c, id);
140
+ var result = (0, _2.execfunction)(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
141
141
  _2.api.setCellValue(ctx, r, c, result[1], null);
142
142
  (0, _2.insertUpdateFunctionGroup)(ctx, r, c, id);
143
143
  }
@@ -113,14 +113,12 @@ function postPasteCut(ctx, source, target, RowlChange) {
113
113
  ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, source.sheetId)].dataVerification = source.curDataVerification;
114
114
  ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, target.sheetId)].dataVerification = target.curDataVerification;
115
115
  ctx.formulaCache.execFunctionExist.reverse();
116
- (0, _formula.execFunctionGroup)(ctx, null, null, null, null, target.curData);
117
116
  ctx.formulaCache.execFunctionGlobalData = null;
118
117
  (0, _sheet.storeSheetParamALL)(ctx);
119
118
  }
120
119
  function pasteHandler(ctx, data, borderInfo) {
121
120
  var _a;
122
121
  var _b, _c, _d, _e, _f, _g;
123
- console.log("pasteHandler", ctx.isFlvReadOnly);
124
122
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
125
123
  if (!allowEdit || ctx.isFlvReadOnly) return;
126
124
  if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
@@ -281,7 +279,6 @@ function pasteHandler(ctx, data, borderInfo) {
281
279
  }
282
280
  if (originCell.f != null && originCell.f.length > 0) {
283
281
  originCell.f = "";
284
- (0, _formula.delFunctionGroup)(ctx, r + curR, c + curC, ctx.currentSheetId);
285
282
  }
286
283
  } else {
287
284
  var cell = {};
@@ -866,6 +863,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
866
863
  var value = null;
867
864
  if ((_f = copyData[h - mth]) === null || _f === void 0 ? void 0 : _f[c - mtc]) {
868
865
  value = _lodash.default.cloneDeep(copyData[h - mth][c - mtc]);
866
+ if ((value === null || value === void 0 ? void 0 : value.v) && (value === null || value === void 0 ? void 0 : value.isDataBlockFormula)) {
867
+ value.m = "Loading...";
868
+ }
869
869
  }
870
870
  if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
871
871
  var func = value.f;
@@ -882,14 +882,14 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
882
882
  func = "=".concat((0, _formula.functionCopy)(ctx, func, "left", Math.abs(offsetCol)));
883
883
  }
884
884
  var funcV = (0, _formula.execfunction)(ctx, func, h, c, undefined, undefined, true);
885
- if (!_lodash.default.isNil(value.spl)) {} else {
886
- value.v = funcV[1], value.f = funcV[2];
887
- if (!_lodash.default.isNil(value.ct) && !_lodash.default.isNil(value.ct.fa)) {
888
- value.m = (0, _format.update)(value.ct.fa, funcV[1]);
889
- } else {
890
- value.m = (0, _format.update)("General", funcV[1]);
891
- }
885
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
886
+ if (afterUpdateCell && arr.length === 1) {
887
+ afterUpdateCell(h, c, null, __assign(__assign({}, value), {
888
+ v: funcV[1],
889
+ m: "[object Promise]"
890
+ }));
892
891
  }
892
+ if (!_lodash.default.isNil(value.spl)) {}
893
893
  }
894
894
  x[c] = _lodash.default.cloneDeep(value);
895
895
  if (value != null && copyHasMC && ((_g = x === null || x === void 0 ? void 0 : x[c]) === null || _g === void 0 ? void 0 : _g.mc)) {
@@ -978,12 +978,17 @@ function handleFormulaStringPaste(ctx, formulaStr) {
978
978
  var c = ctx.luckysheet_select_save[0].column[0];
979
979
  var funcV = (0, _formula.execfunction)(ctx, formulaStr, r, c, undefined, undefined, true);
980
980
  var val = funcV[1];
981
+ var isDataBlockRespose = typeof val !== "string" && typeof val !== "number";
981
982
  var d = (0, _context.getFlowdata)(ctx);
982
983
  if (!d) return;
983
984
  if (!d[r][c]) d[r][c] = {};
984
- d[r][c].m = val.toString();
985
+ d[r][c].m = isDataBlockRespose ? "Loading..." : val.toString();
985
986
  d[r][c].v = val;
986
987
  d[r][c].f = formulaStr;
988
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
989
+ if (afterUpdateCell && isDataBlockRespose) {
990
+ afterUpdateCell(r, c, null, d[r][c]);
991
+ }
987
992
  }
988
993
  function handlePaste(ctx, e) {
989
994
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
@@ -1377,7 +1382,7 @@ function handlePasteByClick(ctx, clipboardData, triggerType) {
1377
1382
  }
1378
1383
  } else if (data.indexOf("fortune-copy-action-image") > -1) {} else if (triggerType !== "btn") {
1379
1384
  var isExcelFormula = clipboardData.startsWith("=");
1380
- if (isExcelFormula) {
1385
+ if (isExcelFormula && false) {
1381
1386
  handleFormulaStringPaste(ctx, clipboardData);
1382
1387
  } else {
1383
1388
  pasteHandler(ctx, clipboardData);
@@ -718,12 +718,12 @@ function updateCell(ctx, r, c, $input, value, canvas) {
718
718
  }
719
719
  if (typeof value === "string") {
720
720
  value = {
721
- "ct": {
722
- "fa": "General",
723
- "t": "g"
721
+ ct: {
722
+ fa: "General",
723
+ t: "g"
724
724
  },
725
- "v": value,
726
- "tb": "1"
725
+ v: value,
726
+ tb: "1"
727
727
  };
728
728
  } else if (_typeof(value) === "object" && !value.tb) {
729
729
  value.tb = "1";
@@ -151,8 +151,8 @@ var FormulaCache = exports.FormulaCache = function () {
151
151
  }
152
152
  FormulaCache.prototype.tryGetCellAsNumber = function (cell) {
153
153
  var _a, _b, _c, _d;
154
- var isCryptoDeno = ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC"));
155
- if (isCryptoDeno) {
154
+ var isCryptoDeno = typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string" ? ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC")) : false;
155
+ if (isCryptoDeno && typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string") {
156
156
  var splitedNumberString = cell.m.split(" ")[0];
157
157
  return Number(splitedNumberString);
158
158
  }
@@ -737,7 +737,7 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
737
737
  if (!_lodash.default.isNil(r) && !_lodash.default.isNil(c)) {
738
738
  if (isrefresh) {
739
739
  var finalResult_1 = result;
740
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
740
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
741
741
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
742
742
  finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
743
743
  }
@@ -748,7 +748,7 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
748
748
  }
749
749
  }
750
750
  var finalResult = result;
751
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
751
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
752
752
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
753
753
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
754
754
  }
package/lib/types.d.ts CHANGED
@@ -45,6 +45,10 @@ export type Cell = {
45
45
  bg?: string;
46
46
  lo?: number;
47
47
  rt?: number;
48
+ baseValue?: number | string;
49
+ baseCurrency?: string;
50
+ baseCurrencyPrice?: string | number;
51
+ isDataBlockFormula?: boolean;
48
52
  ps?: {
49
53
  left: number | null;
50
54
  top: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dev": "father-build --watch"
16
16
  },
17
17
  "dependencies": {
18
- "@fileverse-dev/formula-parser": "0.2.45",
18
+ "@fileverse-dev/formula-parser": "0.2.46",
19
19
  "dayjs": "^1.11.0",
20
20
  "immer": "^9.0.12",
21
21
  "lodash": "^4.17.21",