@fileverse-dev/fortune-core 1.0.67 → 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);
@@ -108,6 +108,11 @@ export function setCellValue(ctx, r, c, d, v) {
108
108
  } else if ("f" in cell) {
109
109
  delete cell.f;
110
110
  }
111
+ if (!_.isNil(v.baseCurrency)) {
112
+ cell.baseValue = v.baseValue;
113
+ cell.baseCurrency = v.baseCurrency;
114
+ cell.baseCurrencyPrice = v.baseCurrencyPrice;
115
+ }
111
116
  if (!_.isNil(v.ct)) {
112
117
  cell.ct = v.ct;
113
118
  }
@@ -609,7 +614,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
609
614
  } else {
610
615
  delFunctionGroup(ctx, r, c);
611
616
  curv = _.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
612
- curv.v = value.toString();
617
+ curv.v = value;
613
618
  delete curv.f;
614
619
  delete curv.spl;
615
620
  var decemialCount_1 = ((_f = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _f === void 0 ? void 0 : _f.toString().includes(".")) ? (_g = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _g === void 0 ? void 0 : _g.toString().split(" ")[0].split(".")[1].length : 0;
@@ -618,7 +623,6 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
618
623
  curv.m = "".concat((parseFloat(value) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount_1), " ").concat(coin_1);
619
624
  curv.baseValue = value;
620
625
  }
621
- console.log("curv", curv);
622
626
  execFunctionGroup(ctx, r, c, curv);
623
627
  isRunExecFunction = false;
624
628
  if (curv.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
@@ -681,10 +685,19 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
681
685
  var coin = (_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().split(" ")[1];
682
686
  if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
683
687
  value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount), " ").concat(coin);
684
- value.baseValue = Number(value === null || value === void 0 ? void 0 : value.v);
685
- value.v = value === null || value === void 0 ? void 0 : value.v.toString();
686
688
  }
687
- console.log(value);
689
+ if (typeof value === "string") {
690
+ value = {
691
+ ct: {
692
+ fa: "General",
693
+ t: "g"
694
+ },
695
+ v: value,
696
+ tb: "1"
697
+ };
698
+ } else if (_typeof(value) === "object" && !value.tb) {
699
+ value.tb = "1";
700
+ }
688
701
  setCellValue(ctx, r, c, d, value);
689
702
  cancelNormalSelected(ctx);
690
703
  if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || isInlineStringCell(d[r][c])) {
@@ -708,7 +721,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
708
721
  }
709
722
  }
710
723
  }
711
- if (ctx.hooks.afterUpdateCell) {
724
+ if (!(value === null || value === void 0 ? void 0 : value.baseValue) && ctx.hooks.afterUpdateCell) {
712
725
  var newValue_1 = _.cloneDeep(flowdata[r][c]);
713
726
  var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
714
727
  setTimeout(function () {
@@ -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
  }
@@ -707,14 +707,19 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
707
707
  }
708
708
  if (!_.isNil(r) && !_.isNil(c)) {
709
709
  if (isrefresh) {
710
- execFunctionGroup(ctx, r, c, _.isNil(formulaError) ? result : formulaError, id);
710
+ var finalResult_1 = result;
711
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
712
+ var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
713
+ finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
714
+ }
715
+ execFunctionGroup(ctx, r, c, _.isNil(formulaError) ? finalResult_1 : formulaError, id);
711
716
  }
712
717
  if (!notInsertFunc) {
713
718
  insertUpdateFunctionGroup(ctx, r, c, id, calcChainSet);
714
719
  }
715
720
  }
716
721
  var finalResult = result;
717
- 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")) {
718
723
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
719
724
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
720
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);
@@ -138,6 +138,11 @@ function setCellValue(ctx, r, c, d, v) {
138
138
  } else if ("f" in cell) {
139
139
  delete cell.f;
140
140
  }
141
+ if (!_lodash.default.isNil(v.baseCurrency)) {
142
+ cell.baseValue = v.baseValue;
143
+ cell.baseCurrency = v.baseCurrency;
144
+ cell.baseCurrencyPrice = v.baseCurrencyPrice;
145
+ }
141
146
  if (!_lodash.default.isNil(v.ct)) {
142
147
  cell.ct = v.ct;
143
148
  }
@@ -639,7 +644,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
639
644
  } else {
640
645
  (0, _formula.delFunctionGroup)(ctx, r, c);
641
646
  curv = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
642
- curv.v = value.toString();
647
+ curv.v = value;
643
648
  delete curv.f;
644
649
  delete curv.spl;
645
650
  var decemialCount_1 = ((_f = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _f === void 0 ? void 0 : _f.toString().includes(".")) ? (_g = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _g === void 0 ? void 0 : _g.toString().split(" ")[0].split(".")[1].length : 0;
@@ -648,7 +653,6 @@ function updateCell(ctx, r, c, $input, value, canvas) {
648
653
  curv.m = "".concat((parseFloat(value) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount_1), " ").concat(coin_1);
649
654
  curv.baseValue = value;
650
655
  }
651
- console.log("curv", curv);
652
656
  (0, _formula.execFunctionGroup)(ctx, r, c, curv);
653
657
  isRunExecFunction = false;
654
658
  if (curv.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
@@ -711,10 +715,19 @@ function updateCell(ctx, r, c, $input, value, canvas) {
711
715
  var coin = (_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().split(" ")[1];
712
716
  if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
713
717
  value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount), " ").concat(coin);
714
- value.baseValue = Number(value === null || value === void 0 ? void 0 : value.v);
715
- value.v = value === null || value === void 0 ? void 0 : value.v.toString();
716
718
  }
717
- console.log(value);
719
+ if (typeof value === "string") {
720
+ value = {
721
+ ct: {
722
+ fa: "General",
723
+ t: "g"
724
+ },
725
+ v: value,
726
+ tb: "1"
727
+ };
728
+ } else if (_typeof(value) === "object" && !value.tb) {
729
+ value.tb = "1";
730
+ }
718
731
  setCellValue(ctx, r, c, d, value);
719
732
  cancelNormalSelected(ctx);
720
733
  if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
@@ -738,7 +751,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
738
751
  }
739
752
  }
740
753
  }
741
- if (ctx.hooks.afterUpdateCell) {
754
+ if (!(value === null || value === void 0 ? void 0 : value.baseValue) && ctx.hooks.afterUpdateCell) {
742
755
  var newValue_1 = _lodash.default.cloneDeep(flowdata[r][c]);
743
756
  var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
744
757
  setTimeout(function () {
@@ -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
  }
@@ -736,14 +736,19 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
736
736
  }
737
737
  if (!_lodash.default.isNil(r) && !_lodash.default.isNil(c)) {
738
738
  if (isrefresh) {
739
- execFunctionGroup(ctx, r, c, _lodash.default.isNil(formulaError) ? result : formulaError, id);
739
+ var finalResult_1 = result;
740
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
741
+ var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
742
+ finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
743
+ }
744
+ execFunctionGroup(ctx, r, c, _lodash.default.isNil(formulaError) ? finalResult_1 : formulaError, id);
740
745
  }
741
746
  if (!notInsertFunc) {
742
747
  insertUpdateFunctionGroup(ctx, r, c, id, calcChainSet);
743
748
  }
744
749
  }
745
750
  var finalResult = result;
746
- 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")) {
747
752
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
748
753
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
749
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.67",
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.44",
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",