@fileverse-dev/fortune-core 1.2.96-maitra-feb6-patch-1 → 1.2.96-scroll-1

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.
@@ -342,7 +342,7 @@ function setCellValue(ctx, r, c, d, v) {
342
342
  var flag = vupdate.split("").every(function (ele) {
343
343
  return ele === "0" || ele === ".";
344
344
  });
345
- if (flag || /^0+\d/.test(vupdate)) {
345
+ if (flag) {
346
346
  vupdate = parseFloat(vupdate);
347
347
  }
348
348
  }
@@ -572,138 +572,211 @@ function cancelNormalSelected(ctx) {
572
572
  }
573
573
  function updateCell(ctx, r, c, $input, value, canvas) {
574
574
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
575
- if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
576
- var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
577
- if (inputText === null || inputText === void 0 ? void 0 : inputText.startsWith("=")) {
578
- inputText = inputText === null || inputText === void 0 ? void 0 : inputText.replace(/[\r\n]/g, "");
579
- }
580
- var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
581
- var flowdata = (0, _context.getFlowdata)(ctx);
582
- if (!flowdata) return;
583
- var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
584
- var dataVerification = ctx.luckysheetfile[index].dataVerification;
585
- var sheetFile = ctx.luckysheetfile[index];
586
- var getUrlFromText = function getUrlFromText(text) {
587
- var t = (text !== null && text !== void 0 ? text : "").trim();
588
- if (!t || /[\s\r\n]/.test(t)) return null;
589
- if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
590
- return t.startsWith("http") ? t : "https://".concat(t);
591
- };
592
- if (!_lodash.default.isNil(dataVerification)) {
593
- var dvItem = dataVerification["".concat(r, "_").concat(c)];
594
- if (!_lodash.default.isNil(dvItem) && dvItem.prohibitInput && !(0, _dataVerification.validateCellData)(ctx, dvItem, inputText)) {
595
- var failureText = (0, _dataVerification.getFailureText)(ctx, dvItem);
596
- cancelNormalSelected(ctx);
597
- ctx.warnDialog = failureText;
598
- return;
599
- }
600
- }
601
- var curv = flowdata[r][c];
602
- var oldValue = _lodash.default.cloneDeep(curv);
603
- var isPrevInline = (0, _inlineString.isInlineStringCell)(curv);
604
- var isCurInline = false;
605
- if ((inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span") {
606
- var spans = ($input === null || $input === void 0 ? void 0 : $input.querySelectorAll("span")) || [];
607
- var hasMultipleSpans = spans.length > 1;
608
- var hasFormattingOrSpecialClasses = Array.from(spans).some(function (span) {
609
- var hasSpecialClass = span.className.includes("luckysheet") || span.className.includes("fortune");
610
- var cssText = span.style.cssText || "";
611
- var meaningfulCss = cssText.replace(/color:\s*rgb\(0,\s*0,\s*0\);?/gi, "").replace(/color:\s*#000000;?/gi, "").replace(/color:\s*black;?/gi, "").trim();
612
- return hasSpecialClass || meaningfulCss.length > 0;
613
- });
614
- isCurInline = hasMultipleSpans || hasFormattingOrSpecialClasses;
615
- }
616
- var isCopyVal = false;
617
- if (!isCurInline && inputText && inputText.length > 0) {
618
- var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
619
- if (splitArr.length > 1 && inputHtml !== "<br>") {
620
- isCopyVal = true;
621
- isCurInline = true;
622
- inputText = splitArr.join("\r\n");
623
- }
624
- }
625
- if ((curv === null || curv === void 0 ? void 0 : curv.ct) && !value && !isCurInline && isPrevInline) {
626
- delete curv.ct.s;
627
- curv.ct.t = "g";
628
- curv.ct.fa = "General";
629
- curv.tb = "1";
630
- value = "";
631
- } else if (isCurInline) {
632
- if (!_lodash.default.isPlainObject(curv)) {
633
- curv = {};
634
- }
635
- curv || (curv = {});
636
- var fontSize = curv.fs || 10;
637
- if (!curv.ct) {
638
- curv.ct = {};
639
- curv.ct.fa = "General";
640
- curv.tb = "1";
641
- }
642
- curv.ct.t = "inlineStr";
643
- curv.ct.s = (0, _inlineString.convertSpanToShareString)($input.querySelectorAll("span"), curv);
644
- delete curv.fs;
645
- delete curv.f;
646
- delete curv.v;
647
- delete curv.m;
648
- curv.fs = fontSize;
649
- if (isCopyVal) {
650
- curv.ct.s = [{
651
- v: inputText,
652
- fs: fontSize
653
- }];
575
+ try {
576
+ if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
577
+ var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
578
+ if (inputText === null || inputText === void 0 ? void 0 : inputText.startsWith("=")) {
579
+ inputText = inputText === null || inputText === void 0 ? void 0 : inputText.replace(/[\r\n]/g, "");
654
580
  }
655
- }
656
- value = value || inputText;
657
- var shouldClearError = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.f) ? oldValue.f !== value : (oldValue === null || oldValue === void 0 ? void 0 : oldValue.v) !== value;
658
- if (shouldClearError) {
659
- (0, _api.clearCellError)(ctx, r, c);
660
- }
661
- if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
662
- cancelNormalSelected(ctx);
663
- return;
664
- }
665
- if (!isCurInline) {
666
- if ((0, _validation.isRealNull)(value) && !isPrevInline) {
667
- if (!curv || (0, _validation.isRealNull)(curv.v) && !curv.spl && !curv.f) {
668
- cancelNormalSelected(ctx);
669
- return;
670
- }
671
- } else if (curv && curv.qp !== 1) {
672
- if (_lodash.default.isPlainObject(curv) && (value === curv.f || value === curv.v || value === curv.m)) {
581
+ var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
582
+ var flowdata = (0, _context.getFlowdata)(ctx);
583
+ if (!flowdata) return;
584
+ var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
585
+ var dataVerification = ctx.luckysheetfile[index].dataVerification;
586
+ var sheetFile = ctx.luckysheetfile[index];
587
+ var getUrlFromText = function getUrlFromText(text) {
588
+ var t = (text !== null && text !== void 0 ? text : "").trim();
589
+ if (!t || /[\s\r\n]/.test(t)) return null;
590
+ if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
591
+ return t.startsWith("http") ? t : "https://".concat(t);
592
+ };
593
+ if (!_lodash.default.isNil(dataVerification)) {
594
+ var dvItem = dataVerification["".concat(r, "_").concat(c)];
595
+ if (!_lodash.default.isNil(dvItem) && dvItem.prohibitInput && !(0, _dataVerification.validateCellData)(ctx, dvItem, inputText)) {
596
+ var failureText = (0, _dataVerification.getFailureText)(ctx, dvItem);
673
597
  cancelNormalSelected(ctx);
598
+ ctx.warnDialog = failureText;
674
599
  return;
675
600
  }
676
- if (value === curv) {
677
- cancelNormalSelected(ctx);
678
- return;
601
+ }
602
+ var curv_1 = flowdata[r][c];
603
+ var oldValue_1 = _lodash.default.cloneDeep(curv_1);
604
+ var isPrevInline = (0, _inlineString.isInlineStringCell)(curv_1);
605
+ var isCurInline = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span";
606
+ var isCopyVal = false;
607
+ if (!isCurInline && inputText && inputText.length > 0) {
608
+ var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
609
+ if (splitArr.length > 1 && inputHtml !== "<br>") {
610
+ isCopyVal = true;
611
+ isCurInline = true;
612
+ inputText = splitArr.join("\r\n");
679
613
  }
680
614
  }
681
- if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {} else if (_lodash.default.isPlainObject(curv) && curv && curv.ct && curv.ct.fa && curv.ct.fa !== "@" && !(0, _validation.isRealNull)(value)) {
682
- delete curv.m;
683
- if (curv.f) {
684
- delete curv.f;
685
- delete curv.spl;
615
+ if ((curv_1 === null || curv_1 === void 0 ? void 0 : curv_1.ct) && !value && !isCurInline && isPrevInline) {
616
+ delete curv_1.ct.s;
617
+ curv_1.ct.t = "g";
618
+ curv_1.ct.fa = "General";
619
+ curv_1.tb = "1";
620
+ value = "";
621
+ } else if (isCurInline) {
622
+ if (!_lodash.default.isPlainObject(curv_1)) {
623
+ curv_1 = {};
624
+ }
625
+ curv_1 || (curv_1 = {});
626
+ var fontSize = curv_1.fs || 10;
627
+ if (!curv_1.ct) {
628
+ curv_1.ct = {};
629
+ curv_1.ct.fa = "General";
630
+ curv_1.tb = "1";
631
+ }
632
+ curv_1.ct.t = "inlineStr";
633
+ curv_1.ct.s = (0, _inlineString.convertSpanToShareString)($input.querySelectorAll("span"), curv_1);
634
+ delete curv_1.fs;
635
+ delete curv_1.f;
636
+ delete curv_1.v;
637
+ delete curv_1.m;
638
+ curv_1.fs = fontSize;
639
+ if (isCopyVal) {
640
+ curv_1.ct.s = [{
641
+ v: inputText,
642
+ fs: fontSize
643
+ }];
686
644
  }
687
645
  }
688
- }
689
- var isRunExecFunction = true;
690
- var d = flowdata;
691
- var dynamicArrayItem = null;
692
- if (_lodash.default.isPlainObject(curv)) {
646
+ value = value || inputText;
647
+ var shouldClearError = (oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.f) ? oldValue_1.f !== value : (oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.v) !== value;
648
+ if (shouldClearError) {
649
+ (0, _api.clearCellError)(ctx, r, c);
650
+ }
651
+ if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
652
+ cancelNormalSelected(ctx);
653
+ return;
654
+ }
693
655
  if (!isCurInline) {
656
+ if ((0, _validation.isRealNull)(value) && !isPrevInline) {
657
+ if (!curv_1 || (0, _validation.isRealNull)(curv_1.v) && !curv_1.spl && !curv_1.f) {
658
+ cancelNormalSelected(ctx);
659
+ return;
660
+ }
661
+ } else if (curv_1 && curv_1.qp !== 1) {
662
+ if (_lodash.default.isPlainObject(curv_1) && (value === curv_1.f || value === curv_1.v || value === curv_1.m)) {
663
+ cancelNormalSelected(ctx);
664
+ return;
665
+ }
666
+ if (value === curv_1) {
667
+ cancelNormalSelected(ctx);
668
+ return;
669
+ }
670
+ }
671
+ if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {} else if (_lodash.default.isPlainObject(curv_1) && curv_1 && curv_1.ct && curv_1.ct.fa && curv_1.ct.fa !== "@" && !(0, _validation.isRealNull)(value)) {
672
+ delete curv_1.m;
673
+ if (curv_1.f) {
674
+ delete curv_1.f;
675
+ delete curv_1.spl;
676
+ }
677
+ }
678
+ }
679
+ var isRunExecFunction = true;
680
+ var d = flowdata;
681
+ var dynamicArrayItem = null;
682
+ if (_lodash.default.isPlainObject(curv_1)) {
683
+ if (!isCurInline) {
684
+ if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
685
+ var v = (0, _formula.execfunction)(ctx, value, r, c, undefined, undefined, true);
686
+ isRunExecFunction = false;
687
+ curv_1 = _lodash.default.cloneDeep(((_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) || {});
688
+ curv_1.v = v[1], curv_1.f = v[2];
689
+ if (v.length === 4 && v[3].type === "sparklines") {
690
+ delete curv_1.m;
691
+ delete curv_1.v;
692
+ var curCalv = v[3].data;
693
+ if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
694
+ curv_1.v = curCalv[0];
695
+ } else {
696
+ curv_1.spl = v[3].data;
697
+ }
698
+ } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
699
+ dynamicArrayItem = v[3].data;
700
+ }
701
+ } else if (_lodash.default.isPlainObject(value)) {
702
+ var valueFunction = value.f;
703
+ if (_lodash.default.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
704
+ var v = (0, _formula.execfunction)(ctx, valueFunction, r, c, undefined, undefined, true);
705
+ isRunExecFunction = false;
706
+ curv_1 = _lodash.default.cloneDeep(((_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) || {});
707
+ curv_1.v = v[1], curv_1.f = v[2];
708
+ if (v.length === 4 && v[3].type === "sparklines") {
709
+ delete curv_1.m;
710
+ delete curv_1.v;
711
+ var curCalv = v[3].data;
712
+ if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
713
+ curv_1.v = curCalv[0];
714
+ } else {
715
+ curv_1.spl = v[3].data;
716
+ }
717
+ } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
718
+ dynamicArrayItem = v[3].data;
719
+ }
720
+ } else {
721
+ Object.keys(value).forEach(function (attr) {
722
+ curv_1[attr] = value[attr];
723
+ });
724
+ (0, _api.clearCellError)(ctx, r, c);
725
+ }
726
+ } else {
727
+ (0, _api.clearCellError)(ctx, r, c);
728
+ (0, _formula.delFunctionGroup)(ctx, r, c);
729
+ curv_1 = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
730
+ curv_1.v = value;
731
+ delete curv_1.f;
732
+ delete curv_1.spl;
733
+ var decemialCount_1 = ((_f = oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.m) === null || _f === void 0 ? void 0 : _f.toString().includes(".")) ? (_h = (_g = oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.m) === null || _g === void 0 ? void 0 : _g.toString().split(" ")[0].split(".")[1]) === null || _h === void 0 ? void 0 : _h.length : 0;
734
+ var coin_1 = (_j = oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.m) === null || _j === void 0 ? void 0 : _j.toString().split(" ")[1];
735
+ if (_typeof(curv_1) === "object" && (curv_1 === null || curv_1 === void 0 ? void 0 : curv_1.baseValue)) {
736
+ curv_1.m = "".concat((parseFloat(value) / (oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.baseCurrencyPrice)).toFixed(decemialCount_1 || 2), " ").concat(coin_1);
737
+ curv_1.baseValue = value;
738
+ }
739
+ (0, _formula.execFunctionGroup)(ctx, r, c, curv_1);
740
+ isRunExecFunction = false;
741
+ if (curv_1.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
742
+ curv_1.qp = 0;
743
+ if (curv_1.ct) {
744
+ curv_1.ct.fa = "General";
745
+ curv_1.ct.t = "n";
746
+ }
747
+ }
748
+ }
749
+ }
750
+ value = curv_1;
751
+ } else {
694
752
  if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
695
753
  var v = (0, _formula.execfunction)(ctx, value, r, c, undefined, undefined, true);
696
754
  isRunExecFunction = false;
697
- curv = _lodash.default.cloneDeep(((_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) || {});
698
- curv.v = v[1], curv.f = v[2];
755
+ value = {
756
+ v: v[1],
757
+ f: v[2]
758
+ };
759
+ if (/^[\d.,]+$/.test(value.v)) {
760
+ var args = (_k = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f)) === null || _k === void 0 ? void 0 : _k.split(",");
761
+ var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
762
+ return arg.trim().toUpperCase();
763
+ });
764
+ var formatted = (0, _utils.processArray)(cellRefs, d, flowdata);
765
+ if (formatted) {
766
+ value.m = (0, _format.update)(formatted, value.v);
767
+ value.ct = {
768
+ fa: formatted,
769
+ t: "n"
770
+ };
771
+ }
772
+ value.ht = 2;
773
+ }
699
774
  if (v.length === 4 && v[3].type === "sparklines") {
700
- delete curv.m;
701
- delete curv.v;
702
775
  var curCalv = v[3].data;
703
776
  if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
704
- curv.v = curCalv[0];
777
+ value.v = curCalv[0];
705
778
  } else {
706
- curv.spl = v[3].data;
779
+ value.spl = v[3].data;
707
780
  }
708
781
  } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
709
782
  dynamicArrayItem = v[3].data;
@@ -713,198 +786,118 @@ function updateCell(ctx, r, c, $input, value, canvas) {
713
786
  if (_lodash.default.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
714
787
  var v = (0, _formula.execfunction)(ctx, valueFunction, r, c, undefined, undefined, true);
715
788
  isRunExecFunction = false;
716
- curv = _lodash.default.cloneDeep(((_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) || {});
717
- curv.v = v[1], curv.f = v[2];
789
+ value.v = v[1], value.f = v[2];
718
790
  if (v.length === 4 && v[3].type === "sparklines") {
719
- delete curv.m;
720
- delete curv.v;
721
791
  var curCalv = v[3].data;
722
792
  if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
723
- curv.v = curCalv[0];
793
+ value.v = curCalv[0];
724
794
  } else {
725
- curv.spl = v[3].data;
795
+ value.spl = v[3].data;
726
796
  }
727
797
  } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
728
798
  dynamicArrayItem = v[3].data;
729
799
  }
730
800
  } else {
731
- Object.keys(value).forEach(function (attr) {
732
- curv[attr] = value[attr];
733
- });
734
801
  (0, _api.clearCellError)(ctx, r, c);
802
+ var v = curv_1;
803
+ if (_lodash.default.isNil(value.v)) {
804
+ value.v = v;
805
+ }
735
806
  }
736
807
  } else {
737
808
  (0, _api.clearCellError)(ctx, r, c);
738
809
  (0, _formula.delFunctionGroup)(ctx, r, c);
739
- curv = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
740
- curv.v = value;
741
- delete curv.f;
742
- delete curv.spl;
743
- var decemialCount_1 = ((_f = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _f === void 0 ? void 0 : _f.toString().includes(".")) ? (_h = (_g = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _g === void 0 ? void 0 : _g.toString().split(" ")[0].split(".")[1]) === null || _h === void 0 ? void 0 : _h.length : 0;
744
- var coin_1 = (_j = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _j === void 0 ? void 0 : _j.toString().split(" ")[1];
745
- if (_typeof(curv) === "object" && (curv === null || curv === void 0 ? void 0 : curv.baseValue)) {
746
- curv.m = "".concat((parseFloat(value) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount_1 || 2), " ").concat(coin_1);
747
- curv.baseValue = value;
748
- }
749
- (0, _formula.execFunctionGroup)(ctx, r, c, curv);
810
+ (0, _formula.execFunctionGroup)(ctx, r, c, value);
750
811
  isRunExecFunction = false;
751
- if (curv.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
752
- curv.qp = 0;
753
- if (curv.ct) {
754
- curv.ct.fa = "General";
755
- curv.ct.t = "n";
756
- }
757
- }
758
812
  }
759
813
  }
760
- value = curv;
761
- } else {
762
- if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
763
- var v = (0, _formula.execfunction)(ctx, value, r, c, undefined, undefined, true);
764
- isRunExecFunction = false;
814
+ var decemialCount = ((_l = oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.m) === null || _l === void 0 ? void 0 : _l.toString().includes(".")) ? (_o = (_m = oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.m) === null || _m === void 0 ? void 0 : _m.toString().split(" ")[0].split(".")[1]) === null || _o === void 0 ? void 0 : _o.length : 0;
815
+ var coin = (_p = oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.m) === null || _p === void 0 ? void 0 : _p.toString().split(" ")[1];
816
+ if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
817
+ value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.baseCurrencyPrice)).toFixed(decemialCount || 2), " ").concat(coin);
818
+ }
819
+ if (typeof value === "string") {
765
820
  value = {
766
- v: v[1],
767
- f: v[2]
821
+ ct: {
822
+ fa: "General",
823
+ t: "g"
824
+ },
825
+ v: value,
826
+ tb: "1"
768
827
  };
769
- if (/^[\d.,]+$/.test(value.v)) {
770
- var args = (_k = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f)) === null || _k === void 0 ? void 0 : _k.split(",");
771
- var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
772
- return arg.trim().toUpperCase();
773
- });
774
- var formatted = (0, _utils.processArray)(cellRefs, d, flowdata);
775
- if (formatted) {
776
- value.m = (0, _format.update)(formatted, value.v);
777
- value.ct = {
778
- fa: formatted,
779
- t: "n"
780
- };
828
+ } else if (_typeof(value) === "object" && !value.tb) {
829
+ value.tb = "1";
830
+ }
831
+ var isValueArray = Array.isArray((_q = value === null || value === void 0 ? void 0 : value.v) === null || _q === void 0 ? void 0 : _q[0]);
832
+ try {
833
+ if (isValueArray) {
834
+ if ((0, _sort.spillSortResult)(ctx, r, c, value, d)) {
835
+ cancelNormalSelected(ctx);
836
+ if (ctx.hooks.afterUpdateCell) {
837
+ var newValue_1 = _lodash.default.cloneDeep(d[r][c]);
838
+ setTimeout(function () {
839
+ var _a, _b;
840
+ return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
841
+ });
842
+ }
843
+ ctx.formulaCache.execFunctionGlobalData = null;
844
+ return;
781
845
  }
782
- value.ht = 2;
783
846
  }
784
- if (v.length === 4 && v[3].type === "sparklines") {
785
- var curCalv = v[3].data;
786
- if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
787
- value.v = curCalv[0];
788
- } else {
789
- value.spl = v[3].data;
790
- }
791
- } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
792
- dynamicArrayItem = v[3].data;
847
+ } catch (e) {
848
+ console.log("[updateCell] spill failed; falling back", e);
849
+ }
850
+ var url = getUrlFromText($input === null || $input === void 0 ? void 0 : $input.innerText);
851
+ if (url && _typeof(value) === "object" && value) {
852
+ value.hl = 1;
853
+ if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
854
+ sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
855
+ linkType: "webpage",
856
+ linkAddress: url
857
+ };
858
+ if (typeof value.v !== "string") {
859
+ value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
793
860
  }
794
- } else if (_lodash.default.isPlainObject(value)) {
795
- var valueFunction = value.f;
796
- if (_lodash.default.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
797
- var v = (0, _formula.execfunction)(ctx, valueFunction, r, c, undefined, undefined, true);
798
- isRunExecFunction = false;
799
- value.v = v[1], value.f = v[2];
800
- if (v.length === 4 && v[3].type === "sparklines") {
801
- var curCalv = v[3].data;
802
- if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
803
- value.v = curCalv[0];
804
- } else {
805
- value.spl = v[3].data;
806
- }
807
- } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
808
- dynamicArrayItem = v[3].data;
809
- }
810
- } else {
811
- (0, _api.clearCellError)(ctx, r, c);
812
- var v = curv;
813
- if (_lodash.default.isNil(value.v)) {
814
- value.v = v;
815
- }
861
+ if (value.m == null) {
862
+ value.m = value.v;
816
863
  }
817
- } else {
818
- (0, _api.clearCellError)(ctx, r, c);
819
- (0, _formula.delFunctionGroup)(ctx, r, c);
820
- (0, _formula.execFunctionGroup)(ctx, r, c, value);
821
- isRunExecFunction = false;
864
+ if (value.fc == null) value.fc = "rgb(0, 0, 255)";
865
+ if (value.un == null) value.un = 1;
822
866
  }
823
- }
824
- var decemialCount = ((_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().includes(".")) ? (_o = (_m = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _m === void 0 ? void 0 : _m.toString().split(" ")[0].split(".")[1]) === null || _o === void 0 ? void 0 : _o.length : 0;
825
- var coin = (_p = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _p === void 0 ? void 0 : _p.toString().split(" ")[1];
826
- if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
827
- value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount || 2), " ").concat(coin);
828
- }
829
- if (typeof value === "string") {
830
- value = {
831
- ct: {
832
- fa: "General",
833
- t: "g"
834
- },
835
- v: value,
836
- tb: "1"
837
- };
838
- } else if (_typeof(value) === "object" && !value.tb) {
839
- value.tb = "1";
840
- }
841
- var isValueArray = Array.isArray((_q = value === null || value === void 0 ? void 0 : value.v) === null || _q === void 0 ? void 0 : _q[0]);
842
- try {
843
- if (isValueArray) {
844
- if ((0, _sort.spillSortResult)(ctx, r, c, value, d)) {
845
- cancelNormalSelected(ctx);
846
- if (ctx.hooks.afterUpdateCell) {
847
- var newValue_1 = _lodash.default.cloneDeep(d[r][c]);
848
- setTimeout(function () {
849
- var _a, _b;
850
- return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
851
- });
867
+ setCellValue(ctx, r, c, d, value);
868
+ cancelNormalSelected(ctx);
869
+ if ((curv_1 === null || curv_1 === void 0 ? void 0 : curv_1.tb) === "2" && curv_1.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
870
+ var defaultrowlen = ctx.defaultrowlen;
871
+ var cfg = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config || {};
872
+ if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
873
+ var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
874
+ var textInfo = canvas ? (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
875
+ r: r,
876
+ c: c,
877
+ cellWidth: cellWidth
878
+ }) : null;
879
+ var currentRowLen = defaultrowlen;
880
+ if (textInfo) {
881
+ currentRowLen = textInfo.textHeightAll + 2;
882
+ }
883
+ var previousRowHeight = (0, _api.getRowHeight)(ctx, [r])[r];
884
+ if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
885
+ if (_lodash.default.isNil(cfg.rowlen)) cfg.rowlen = {};
886
+ cfg.rowlen[r] = currentRowLen;
852
887
  }
853
- ctx.formulaCache.execFunctionGlobalData = null;
854
- return;
855
888
  }
856
889
  }
857
- } catch (e) {
858
- console.log("[updateCell] spill failed; falling back", e);
859
- }
860
- var url = getUrlFromText($input === null || $input === void 0 ? void 0 : $input.innerText);
861
- if (url && _typeof(value) === "object" && value) {
862
- value.hl = 1;
863
- if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
864
- sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
865
- linkType: "webpage",
866
- linkAddress: url
867
- };
868
- if (typeof value.v !== "string") {
869
- value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
870
- }
871
- if (value.m == null) {
872
- value.m = value.v;
873
- }
874
- if (value.fc == null) value.fc = "rgb(0, 0, 255)";
875
- if (value.un == null) value.un = 1;
876
- }
877
- setCellValue(ctx, r, c, d, value);
878
- cancelNormalSelected(ctx);
879
- if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
880
- var defaultrowlen = ctx.defaultrowlen;
881
- var cfg = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config || {};
882
- if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
883
- var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
884
- var textInfo = canvas ? (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
885
- r: r,
886
- c: c,
887
- cellWidth: cellWidth
888
- }) : null;
889
- var currentRowLen = defaultrowlen;
890
- if (textInfo) {
891
- currentRowLen = textInfo.textHeightAll + 2;
892
- }
893
- var previousRowHeight = (0, _api.getRowHeight)(ctx, [r])[r];
894
- if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
895
- if (_lodash.default.isNil(cfg.rowlen)) cfg.rowlen = {};
896
- cfg.rowlen[r] = currentRowLen;
897
- }
890
+ if (ctx.hooks.afterUpdateCell) {
891
+ var newValue_2 = _lodash.default.cloneDeep(flowdata[r][c]);
892
+ var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
893
+ setTimeout(function () {
894
+ afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue_1, newValue_2);
895
+ });
898
896
  }
897
+ ctx.formulaCache.execFunctionGlobalData = null;
898
+ } catch (e) {
899
+ cancelNormalSelected(ctx);
899
900
  }
900
- if (ctx.hooks.afterUpdateCell) {
901
- var newValue_2 = _lodash.default.cloneDeep(flowdata[r][c]);
902
- var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
903
- setTimeout(function () {
904
- afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue, newValue_2);
905
- });
906
- }
907
- ctx.formulaCache.execFunctionGlobalData = null;
908
901
  }
909
902
  function getOrigincell(ctx, r, c, i) {
910
903
  var data = (0, _context.getFlowdata)(ctx, i);
@@ -155,7 +155,7 @@ var FormulaCache = exports.FormulaCache = function () {
155
155
  });
156
156
  }
157
157
  FormulaCache.prototype.tryGetCellAsNumber = function (cell) {
158
- var _a, _b, _c, _d, _e, _f;
158
+ var _a, _b, _c, _d;
159
159
  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;
160
160
  if (isCryptoDeno && typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string") {
161
161
  var splitedNumberString = cell.m.split(" ")[0];
@@ -165,20 +165,6 @@ var FormulaCache = exports.FormulaCache = function () {
165
165
  var n = Number(cell === null || cell === void 0 ? void 0 : cell.v);
166
166
  return Number.isNaN(n) ? cell.v : n;
167
167
  }
168
- if (((_e = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _e === void 0 ? void 0 : _e.t) === "inlineStr" && Array.isArray((_f = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _f === void 0 ? void 0 : _f.s) && cell.ct.s.length > 0) {
169
- var inlineValue = cell.ct.s.map(function (segment) {
170
- return (segment === null || segment === void 0 ? void 0 : segment.v) || "";
171
- }).join("");
172
- var trimmedValue = inlineValue.trim();
173
- if (trimmedValue.length > 0) {
174
- var cleanedValue = trimmedValue.replace(/,/g, "");
175
- var n = Number(cleanedValue);
176
- if (!Number.isNaN(n)) {
177
- return n;
178
- }
179
- return inlineValue;
180
- }
181
- }
182
168
  return String(cell === null || cell === void 0 ? void 0 : cell.m).includes("%") ? cell === null || cell === void 0 ? void 0 : cell.m : cell === null || cell === void 0 ? void 0 : cell.v;
183
169
  };
184
170
  return FormulaCache;