@fileverse-dev/fortune-core 1.2.96-scroll → 1.2.96-scroll-2

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.
@@ -572,127 +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 = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span";
605
- var isCopyVal = false;
606
- if (!isCurInline && inputText && inputText.length > 0) {
607
- var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
608
- if (splitArr.length > 1 && inputHtml !== "<br>") {
609
- isCopyVal = true;
610
- isCurInline = true;
611
- inputText = splitArr.join("\r\n");
612
- }
613
- }
614
- if ((curv === null || curv === void 0 ? void 0 : curv.ct) && !value && !isCurInline && isPrevInline) {
615
- delete curv.ct.s;
616
- curv.ct.t = "g";
617
- curv.ct.fa = "General";
618
- curv.tb = "1";
619
- value = "";
620
- } else if (isCurInline) {
621
- if (!_lodash.default.isPlainObject(curv)) {
622
- curv = {};
623
- }
624
- curv || (curv = {});
625
- var fontSize = curv.fs || 10;
626
- if (!curv.ct) {
627
- curv.ct = {};
628
- curv.ct.fa = "General";
629
- curv.tb = "1";
630
- }
631
- curv.ct.t = "inlineStr";
632
- curv.ct.s = (0, _inlineString.convertSpanToShareString)($input.querySelectorAll("span"), curv);
633
- delete curv.fs;
634
- delete curv.f;
635
- delete curv.v;
636
- delete curv.m;
637
- curv.fs = fontSize;
638
- if (isCopyVal) {
639
- curv.ct.s = [{
640
- v: inputText,
641
- fs: fontSize
642
- }];
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, "");
643
580
  }
644
- }
645
- value = value || inputText;
646
- var shouldClearError = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.f) ? oldValue.f !== value : (oldValue === null || oldValue === void 0 ? void 0 : oldValue.v) !== value;
647
- if (shouldClearError) {
648
- (0, _api.clearCellError)(ctx, r, c);
649
- }
650
- if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
651
- cancelNormalSelected(ctx);
652
- return;
653
- }
654
- if (!isCurInline) {
655
- if ((0, _validation.isRealNull)(value) && !isPrevInline) {
656
- if (!curv || (0, _validation.isRealNull)(curv.v) && !curv.spl && !curv.f) {
657
- cancelNormalSelected(ctx);
658
- return;
659
- }
660
- } else if (curv && curv.qp !== 1) {
661
- 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);
662
597
  cancelNormalSelected(ctx);
598
+ ctx.warnDialog = failureText;
663
599
  return;
664
600
  }
665
- if (value === curv) {
666
- cancelNormalSelected(ctx);
667
- 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");
668
613
  }
669
614
  }
670
- 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)) {
671
- delete curv.m;
672
- if (curv.f) {
673
- delete curv.f;
674
- 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
+ }];
675
644
  }
676
645
  }
677
- }
678
- var isRunExecFunction = true;
679
- var d = flowdata;
680
- var dynamicArrayItem = null;
681
- 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
+ }
682
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 {
683
752
  if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
684
753
  var v = (0, _formula.execfunction)(ctx, value, r, c, undefined, undefined, true);
685
754
  isRunExecFunction = false;
686
- curv = _lodash.default.cloneDeep(((_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) || {});
687
- 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
+ }
688
774
  if (v.length === 4 && v[3].type === "sparklines") {
689
- delete curv.m;
690
- delete curv.v;
691
775
  var curCalv = v[3].data;
692
776
  if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
693
- curv.v = curCalv[0];
777
+ value.v = curCalv[0];
694
778
  } else {
695
- curv.spl = v[3].data;
779
+ value.spl = v[3].data;
696
780
  }
697
781
  } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
698
782
  dynamicArrayItem = v[3].data;
@@ -702,198 +786,118 @@ function updateCell(ctx, r, c, $input, value, canvas) {
702
786
  if (_lodash.default.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
703
787
  var v = (0, _formula.execfunction)(ctx, valueFunction, r, c, undefined, undefined, true);
704
788
  isRunExecFunction = false;
705
- curv = _lodash.default.cloneDeep(((_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) || {});
706
- curv.v = v[1], curv.f = v[2];
789
+ value.v = v[1], value.f = v[2];
707
790
  if (v.length === 4 && v[3].type === "sparklines") {
708
- delete curv.m;
709
- delete curv.v;
710
791
  var curCalv = v[3].data;
711
792
  if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
712
- curv.v = curCalv[0];
793
+ value.v = curCalv[0];
713
794
  } else {
714
- curv.spl = v[3].data;
795
+ value.spl = v[3].data;
715
796
  }
716
797
  } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
717
798
  dynamicArrayItem = v[3].data;
718
799
  }
719
800
  } else {
720
- Object.keys(value).forEach(function (attr) {
721
- curv[attr] = value[attr];
722
- });
723
801
  (0, _api.clearCellError)(ctx, r, c);
802
+ var v = curv_1;
803
+ if (_lodash.default.isNil(value.v)) {
804
+ value.v = v;
805
+ }
724
806
  }
725
807
  } else {
726
808
  (0, _api.clearCellError)(ctx, r, c);
727
809
  (0, _formula.delFunctionGroup)(ctx, r, c);
728
- curv = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
729
- curv.v = value;
730
- delete curv.f;
731
- delete curv.spl;
732
- 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;
733
- var coin_1 = (_j = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _j === void 0 ? void 0 : _j.toString().split(" ")[1];
734
- if (_typeof(curv) === "object" && (curv === null || curv === void 0 ? void 0 : curv.baseValue)) {
735
- curv.m = "".concat((parseFloat(value) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount_1 || 2), " ").concat(coin_1);
736
- curv.baseValue = value;
737
- }
738
- (0, _formula.execFunctionGroup)(ctx, r, c, curv);
810
+ (0, _formula.execFunctionGroup)(ctx, r, c, value);
739
811
  isRunExecFunction = false;
740
- if (curv.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
741
- curv.qp = 0;
742
- if (curv.ct) {
743
- curv.ct.fa = "General";
744
- curv.ct.t = "n";
745
- }
746
- }
747
812
  }
748
813
  }
749
- value = curv;
750
- } else {
751
- if (_lodash.default.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
752
- var v = (0, _formula.execfunction)(ctx, value, r, c, undefined, undefined, true);
753
- 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") {
754
820
  value = {
755
- v: v[1],
756
- f: v[2]
821
+ ct: {
822
+ fa: "General",
823
+ t: "g"
824
+ },
825
+ v: value,
826
+ tb: "1"
757
827
  };
758
- if (/^[\d.,]+$/.test(value.v)) {
759
- var args = (_k = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f)) === null || _k === void 0 ? void 0 : _k.split(",");
760
- var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
761
- return arg.trim().toUpperCase();
762
- });
763
- var formatted = (0, _utils.processArray)(cellRefs, d, flowdata);
764
- if (formatted) {
765
- value.m = (0, _format.update)(formatted, value.v);
766
- value.ct = {
767
- fa: formatted,
768
- t: "n"
769
- };
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;
770
845
  }
771
- value.ht = 2;
772
846
  }
773
- if (v.length === 4 && v[3].type === "sparklines") {
774
- var curCalv = v[3].data;
775
- if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
776
- value.v = curCalv[0];
777
- } else {
778
- value.spl = v[3].data;
779
- }
780
- } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
781
- 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;
782
860
  }
783
- } else if (_lodash.default.isPlainObject(value)) {
784
- var valueFunction = value.f;
785
- if (_lodash.default.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
786
- var v = (0, _formula.execfunction)(ctx, valueFunction, r, c, undefined, undefined, true);
787
- isRunExecFunction = false;
788
- value.v = v[1], value.f = v[2];
789
- if (v.length === 4 && v[3].type === "sparklines") {
790
- var curCalv = v[3].data;
791
- if (_lodash.default.isArray(curCalv) && !_lodash.default.isPlainObject(curCalv[0])) {
792
- value.v = curCalv[0];
793
- } else {
794
- value.spl = v[3].data;
795
- }
796
- } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
797
- dynamicArrayItem = v[3].data;
798
- }
799
- } else {
800
- (0, _api.clearCellError)(ctx, r, c);
801
- var v = curv;
802
- if (_lodash.default.isNil(value.v)) {
803
- value.v = v;
804
- }
861
+ if (value.m == null) {
862
+ value.m = value.v;
805
863
  }
806
- } else {
807
- (0, _api.clearCellError)(ctx, r, c);
808
- (0, _formula.delFunctionGroup)(ctx, r, c);
809
- (0, _formula.execFunctionGroup)(ctx, r, c, value);
810
- isRunExecFunction = false;
864
+ if (value.fc == null) value.fc = "rgb(0, 0, 255)";
865
+ if (value.un == null) value.un = 1;
811
866
  }
812
- }
813
- 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;
814
- var coin = (_p = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _p === void 0 ? void 0 : _p.toString().split(" ")[1];
815
- if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
816
- 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);
817
- }
818
- if (typeof value === "string") {
819
- value = {
820
- ct: {
821
- fa: "General",
822
- t: "g"
823
- },
824
- v: value,
825
- tb: "1"
826
- };
827
- } else if (_typeof(value) === "object" && !value.tb) {
828
- value.tb = "1";
829
- }
830
- var isValueArray = Array.isArray((_q = value === null || value === void 0 ? void 0 : value.v) === null || _q === void 0 ? void 0 : _q[0]);
831
- try {
832
- if (isValueArray) {
833
- if ((0, _sort.spillSortResult)(ctx, r, c, value, d)) {
834
- cancelNormalSelected(ctx);
835
- if (ctx.hooks.afterUpdateCell) {
836
- var newValue_1 = _lodash.default.cloneDeep(d[r][c]);
837
- setTimeout(function () {
838
- var _a, _b;
839
- return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
840
- });
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;
841
887
  }
842
- ctx.formulaCache.execFunctionGlobalData = null;
843
- return;
844
888
  }
845
889
  }
846
- } catch (e) {
847
- console.log("[updateCell] spill failed; falling back", e);
848
- }
849
- var url = getUrlFromText($input === null || $input === void 0 ? void 0 : $input.innerText);
850
- if (url && _typeof(value) === "object" && value) {
851
- value.hl = 1;
852
- if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
853
- sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
854
- linkType: "webpage",
855
- linkAddress: url
856
- };
857
- if (typeof value.v !== "string") {
858
- value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
859
- }
860
- if (value.m == null) {
861
- value.m = value.v;
862
- }
863
- if (value.fc == null) value.fc = "rgb(0, 0, 255)";
864
- if (value.un == null) value.un = 1;
865
- }
866
- setCellValue(ctx, r, c, d, value);
867
- cancelNormalSelected(ctx);
868
- if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
869
- var defaultrowlen = ctx.defaultrowlen;
870
- var cfg = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config || {};
871
- if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
872
- var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
873
- var textInfo = canvas ? (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
874
- r: r,
875
- c: c,
876
- cellWidth: cellWidth
877
- }) : null;
878
- var currentRowLen = defaultrowlen;
879
- if (textInfo) {
880
- currentRowLen = textInfo.textHeightAll + 2;
881
- }
882
- var previousRowHeight = (0, _api.getRowHeight)(ctx, [r])[r];
883
- if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
884
- if (_lodash.default.isNil(cfg.rowlen)) cfg.rowlen = {};
885
- cfg.rowlen[r] = currentRowLen;
886
- }
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
+ });
887
896
  }
897
+ ctx.formulaCache.execFunctionGlobalData = null;
898
+ } catch (e) {
899
+ cancelNormalSelected(ctx);
888
900
  }
889
- if (ctx.hooks.afterUpdateCell) {
890
- var newValue_2 = _lodash.default.cloneDeep(flowdata[r][c]);
891
- var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
892
- setTimeout(function () {
893
- afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue, newValue_2);
894
- });
895
- }
896
- ctx.formulaCache.execFunctionGlobalData = null;
897
901
  }
898
902
  function getOrigincell(ctx, r, c, i) {
899
903
  var data = (0, _context.getFlowdata)(ctx, i);
@@ -301,6 +301,7 @@ function extendCssText(origin, cover, isLimit) {
301
301
  }
302
302
  function updateInlineStringFormat(ctx, attr, value, cellInput) {
303
303
  var _a, _b, _c;
304
+ console.log("updateInlineStringFormat", attr, value);
304
305
  var w = window.getSelection();
305
306
  if (!w) return;
306
307
  if (w.rangeCount === 0) return;
@@ -449,4 +450,5 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
449
450
  }
450
451
  }
451
452
  }
453
+ ctx.luckysheetCellUpdate = [];
452
454
  }
@@ -50,6 +50,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
50
50
  function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
51
51
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
52
52
  var _7;
53
+ console.log("updateFormatCell", attr, foucsStatus, row_st, row_ed, col_st, col_ed);
53
54
  if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
54
55
  return;
55
56
  }
@@ -237,6 +238,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
237
238
  }
238
239
  }
239
240
  function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
241
+ console.log("updateFormat", attr, foucsStatus);
240
242
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
241
243
  if (!allowEdit) return;
242
244
  if (attr in _inlineString.inlineStyleAffectAttribute) {
@@ -270,6 +272,7 @@ function toggleAttr(ctx, cellInput, attr) {
270
272
  updateFormat(ctx, cellInput, flowdata, attr, foucsStatus);
271
273
  }
272
274
  function setAttr(ctx, cellInput, attr, value, canvas) {
275
+ console.log("setAttr", attr, value);
273
276
  var flowdata = (0, _context.getFlowdata)(ctx);
274
277
  if (!flowdata) return;
275
278
  updateFormat(ctx, cellInput, flowdata, attr, value, canvas);
@@ -997,6 +1000,7 @@ function handleFreeze(ctx, type) {
997
1000
  }
998
1001
  }
999
1002
  function handleTextSize(ctx, cellInput, size, canvas) {
1003
+ console.log("handleTextSize", size);
1000
1004
  setAttr(ctx, cellInput, "fs", size, canvas);
1001
1005
  }
1002
1006
  function handleSum(ctx, cellInput, fxInput, cache) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.96-scroll",
3
+ "version": "1.2.96-scroll-2",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",