@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.
- package/es/events/keyboard.js +11 -0
- package/es/events/mouse.js +0 -4
- package/es/modules/cell.js +273 -280
- package/es/modules/formula.js +1 -15
- package/es/modules/inline-string.js +1 -0
- package/es/modules/toolbar.js +4 -0
- package/es/modules/validation.js +1 -1
- package/lib/events/keyboard.js +11 -0
- package/lib/events/mouse.js +0 -4
- package/lib/modules/cell.js +273 -280
- package/lib/modules/formula.js +1 -15
- package/lib/modules/inline-string.js +1 -0
- package/lib/modules/toolbar.js +4 -0
- package/lib/modules/validation.js +1 -1
- package/package.json +2 -2
package/es/modules/cell.js
CHANGED
|
@@ -309,7 +309,7 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
309
309
|
var flag = vupdate.split("").every(function (ele) {
|
|
310
310
|
return ele === "0" || ele === ".";
|
|
311
311
|
});
|
|
312
|
-
if (flag
|
|
312
|
+
if (flag) {
|
|
313
313
|
vupdate = parseFloat(vupdate);
|
|
314
314
|
}
|
|
315
315
|
}
|
|
@@ -539,138 +539,211 @@ export function cancelNormalSelected(ctx) {
|
|
|
539
539
|
}
|
|
540
540
|
export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
541
541
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
|
|
548
|
-
var flowdata = getFlowdata(ctx);
|
|
549
|
-
if (!flowdata) return;
|
|
550
|
-
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
551
|
-
var dataVerification = ctx.luckysheetfile[index].dataVerification;
|
|
552
|
-
var sheetFile = ctx.luckysheetfile[index];
|
|
553
|
-
var getUrlFromText = function getUrlFromText(text) {
|
|
554
|
-
var t = (text !== null && text !== void 0 ? text : "").trim();
|
|
555
|
-
if (!t || /[\s\r\n]/.test(t)) return null;
|
|
556
|
-
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
557
|
-
return t.startsWith("http") ? t : "https://".concat(t);
|
|
558
|
-
};
|
|
559
|
-
if (!_.isNil(dataVerification)) {
|
|
560
|
-
var dvItem = dataVerification["".concat(r, "_").concat(c)];
|
|
561
|
-
if (!_.isNil(dvItem) && dvItem.prohibitInput && !validateCellData(ctx, dvItem, inputText)) {
|
|
562
|
-
var failureText = getFailureText(ctx, dvItem);
|
|
563
|
-
cancelNormalSelected(ctx);
|
|
564
|
-
ctx.warnDialog = failureText;
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
var curv = flowdata[r][c];
|
|
569
|
-
var oldValue = _.cloneDeep(curv);
|
|
570
|
-
var isPrevInline = isInlineStringCell(curv);
|
|
571
|
-
var isCurInline = false;
|
|
572
|
-
if ((inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span") {
|
|
573
|
-
var spans = ($input === null || $input === void 0 ? void 0 : $input.querySelectorAll("span")) || [];
|
|
574
|
-
var hasMultipleSpans = spans.length > 1;
|
|
575
|
-
var hasFormattingOrSpecialClasses = Array.from(spans).some(function (span) {
|
|
576
|
-
var hasSpecialClass = span.className.includes("luckysheet") || span.className.includes("fortune");
|
|
577
|
-
var cssText = span.style.cssText || "";
|
|
578
|
-
var meaningfulCss = cssText.replace(/color:\s*rgb\(0,\s*0,\s*0\);?/gi, "").replace(/color:\s*#000000;?/gi, "").replace(/color:\s*black;?/gi, "").trim();
|
|
579
|
-
return hasSpecialClass || meaningfulCss.length > 0;
|
|
580
|
-
});
|
|
581
|
-
isCurInline = hasMultipleSpans || hasFormattingOrSpecialClasses;
|
|
582
|
-
}
|
|
583
|
-
var isCopyVal = false;
|
|
584
|
-
if (!isCurInline && inputText && inputText.length > 0) {
|
|
585
|
-
var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/ /g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
|
|
586
|
-
if (splitArr.length > 1 && inputHtml !== "<br>") {
|
|
587
|
-
isCopyVal = true;
|
|
588
|
-
isCurInline = true;
|
|
589
|
-
inputText = splitArr.join("\r\n");
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if ((curv === null || curv === void 0 ? void 0 : curv.ct) && !value && !isCurInline && isPrevInline) {
|
|
593
|
-
delete curv.ct.s;
|
|
594
|
-
curv.ct.t = "g";
|
|
595
|
-
curv.ct.fa = "General";
|
|
596
|
-
curv.tb = "1";
|
|
597
|
-
value = "";
|
|
598
|
-
} else if (isCurInline) {
|
|
599
|
-
if (!_.isPlainObject(curv)) {
|
|
600
|
-
curv = {};
|
|
601
|
-
}
|
|
602
|
-
curv || (curv = {});
|
|
603
|
-
var fontSize = curv.fs || 10;
|
|
604
|
-
if (!curv.ct) {
|
|
605
|
-
curv.ct = {};
|
|
606
|
-
curv.ct.fa = "General";
|
|
607
|
-
curv.tb = "1";
|
|
608
|
-
}
|
|
609
|
-
curv.ct.t = "inlineStr";
|
|
610
|
-
curv.ct.s = convertSpanToShareString($input.querySelectorAll("span"), curv);
|
|
611
|
-
delete curv.fs;
|
|
612
|
-
delete curv.f;
|
|
613
|
-
delete curv.v;
|
|
614
|
-
delete curv.m;
|
|
615
|
-
curv.fs = fontSize;
|
|
616
|
-
if (isCopyVal) {
|
|
617
|
-
curv.ct.s = [{
|
|
618
|
-
v: inputText,
|
|
619
|
-
fs: fontSize
|
|
620
|
-
}];
|
|
542
|
+
try {
|
|
543
|
+
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
544
|
+
var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
|
|
545
|
+
if (inputText === null || inputText === void 0 ? void 0 : inputText.startsWith("=")) {
|
|
546
|
+
inputText = inputText === null || inputText === void 0 ? void 0 : inputText.replace(/[\r\n]/g, "");
|
|
621
547
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
} else if (curv && curv.qp !== 1) {
|
|
639
|
-
if (_.isPlainObject(curv) && (value === curv.f || value === curv.v || value === curv.m)) {
|
|
548
|
+
var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
|
|
549
|
+
var flowdata = getFlowdata(ctx);
|
|
550
|
+
if (!flowdata) return;
|
|
551
|
+
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
552
|
+
var dataVerification = ctx.luckysheetfile[index].dataVerification;
|
|
553
|
+
var sheetFile = ctx.luckysheetfile[index];
|
|
554
|
+
var getUrlFromText = function getUrlFromText(text) {
|
|
555
|
+
var t = (text !== null && text !== void 0 ? text : "").trim();
|
|
556
|
+
if (!t || /[\s\r\n]/.test(t)) return null;
|
|
557
|
+
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
558
|
+
return t.startsWith("http") ? t : "https://".concat(t);
|
|
559
|
+
};
|
|
560
|
+
if (!_.isNil(dataVerification)) {
|
|
561
|
+
var dvItem = dataVerification["".concat(r, "_").concat(c)];
|
|
562
|
+
if (!_.isNil(dvItem) && dvItem.prohibitInput && !validateCellData(ctx, dvItem, inputText)) {
|
|
563
|
+
var failureText = getFailureText(ctx, dvItem);
|
|
640
564
|
cancelNormalSelected(ctx);
|
|
565
|
+
ctx.warnDialog = failureText;
|
|
641
566
|
return;
|
|
642
567
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
568
|
+
}
|
|
569
|
+
var curv_1 = flowdata[r][c];
|
|
570
|
+
var oldValue_1 = _.cloneDeep(curv_1);
|
|
571
|
+
var isPrevInline = isInlineStringCell(curv_1);
|
|
572
|
+
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";
|
|
573
|
+
var isCopyVal = false;
|
|
574
|
+
if (!isCurInline && inputText && inputText.length > 0) {
|
|
575
|
+
var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/ /g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
|
|
576
|
+
if (splitArr.length > 1 && inputHtml !== "<br>") {
|
|
577
|
+
isCopyVal = true;
|
|
578
|
+
isCurInline = true;
|
|
579
|
+
inputText = splitArr.join("\r\n");
|
|
646
580
|
}
|
|
647
581
|
}
|
|
648
|
-
if (
|
|
649
|
-
delete
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
582
|
+
if ((curv_1 === null || curv_1 === void 0 ? void 0 : curv_1.ct) && !value && !isCurInline && isPrevInline) {
|
|
583
|
+
delete curv_1.ct.s;
|
|
584
|
+
curv_1.ct.t = "g";
|
|
585
|
+
curv_1.ct.fa = "General";
|
|
586
|
+
curv_1.tb = "1";
|
|
587
|
+
value = "";
|
|
588
|
+
} else if (isCurInline) {
|
|
589
|
+
if (!_.isPlainObject(curv_1)) {
|
|
590
|
+
curv_1 = {};
|
|
591
|
+
}
|
|
592
|
+
curv_1 || (curv_1 = {});
|
|
593
|
+
var fontSize = curv_1.fs || 10;
|
|
594
|
+
if (!curv_1.ct) {
|
|
595
|
+
curv_1.ct = {};
|
|
596
|
+
curv_1.ct.fa = "General";
|
|
597
|
+
curv_1.tb = "1";
|
|
598
|
+
}
|
|
599
|
+
curv_1.ct.t = "inlineStr";
|
|
600
|
+
curv_1.ct.s = convertSpanToShareString($input.querySelectorAll("span"), curv_1);
|
|
601
|
+
delete curv_1.fs;
|
|
602
|
+
delete curv_1.f;
|
|
603
|
+
delete curv_1.v;
|
|
604
|
+
delete curv_1.m;
|
|
605
|
+
curv_1.fs = fontSize;
|
|
606
|
+
if (isCopyVal) {
|
|
607
|
+
curv_1.ct.s = [{
|
|
608
|
+
v: inputText,
|
|
609
|
+
fs: fontSize
|
|
610
|
+
}];
|
|
653
611
|
}
|
|
654
612
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
613
|
+
value = value || inputText;
|
|
614
|
+
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;
|
|
615
|
+
if (shouldClearError) {
|
|
616
|
+
clearCellError(ctx, r, c);
|
|
617
|
+
}
|
|
618
|
+
if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
|
|
619
|
+
cancelNormalSelected(ctx);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
660
622
|
if (!isCurInline) {
|
|
623
|
+
if (isRealNull(value) && !isPrevInline) {
|
|
624
|
+
if (!curv_1 || isRealNull(curv_1.v) && !curv_1.spl && !curv_1.f) {
|
|
625
|
+
cancelNormalSelected(ctx);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
} else if (curv_1 && curv_1.qp !== 1) {
|
|
629
|
+
if (_.isPlainObject(curv_1) && (value === curv_1.f || value === curv_1.v || value === curv_1.m)) {
|
|
630
|
+
cancelNormalSelected(ctx);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (value === curv_1) {
|
|
634
|
+
cancelNormalSelected(ctx);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (_.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {} else if (_.isPlainObject(curv_1) && curv_1 && curv_1.ct && curv_1.ct.fa && curv_1.ct.fa !== "@" && !isRealNull(value)) {
|
|
639
|
+
delete curv_1.m;
|
|
640
|
+
if (curv_1.f) {
|
|
641
|
+
delete curv_1.f;
|
|
642
|
+
delete curv_1.spl;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
var isRunExecFunction = true;
|
|
647
|
+
var d = flowdata;
|
|
648
|
+
var dynamicArrayItem = null;
|
|
649
|
+
if (_.isPlainObject(curv_1)) {
|
|
650
|
+
if (!isCurInline) {
|
|
651
|
+
if (_.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
|
|
652
|
+
var v = execfunction(ctx, value, r, c, undefined, undefined, true);
|
|
653
|
+
isRunExecFunction = false;
|
|
654
|
+
curv_1 = _.cloneDeep(((_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) || {});
|
|
655
|
+
curv_1.v = v[1], curv_1.f = v[2];
|
|
656
|
+
if (v.length === 4 && v[3].type === "sparklines") {
|
|
657
|
+
delete curv_1.m;
|
|
658
|
+
delete curv_1.v;
|
|
659
|
+
var curCalv = v[3].data;
|
|
660
|
+
if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
|
|
661
|
+
curv_1.v = curCalv[0];
|
|
662
|
+
} else {
|
|
663
|
+
curv_1.spl = v[3].data;
|
|
664
|
+
}
|
|
665
|
+
} else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
|
|
666
|
+
dynamicArrayItem = v[3].data;
|
|
667
|
+
}
|
|
668
|
+
} else if (_.isPlainObject(value)) {
|
|
669
|
+
var valueFunction = value.f;
|
|
670
|
+
if (_.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
|
|
671
|
+
var v = execfunction(ctx, valueFunction, r, c, undefined, undefined, true);
|
|
672
|
+
isRunExecFunction = false;
|
|
673
|
+
curv_1 = _.cloneDeep(((_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) || {});
|
|
674
|
+
curv_1.v = v[1], curv_1.f = v[2];
|
|
675
|
+
if (v.length === 4 && v[3].type === "sparklines") {
|
|
676
|
+
delete curv_1.m;
|
|
677
|
+
delete curv_1.v;
|
|
678
|
+
var curCalv = v[3].data;
|
|
679
|
+
if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
|
|
680
|
+
curv_1.v = curCalv[0];
|
|
681
|
+
} else {
|
|
682
|
+
curv_1.spl = v[3].data;
|
|
683
|
+
}
|
|
684
|
+
} else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
|
|
685
|
+
dynamicArrayItem = v[3].data;
|
|
686
|
+
}
|
|
687
|
+
} else {
|
|
688
|
+
Object.keys(value).forEach(function (attr) {
|
|
689
|
+
curv_1[attr] = value[attr];
|
|
690
|
+
});
|
|
691
|
+
clearCellError(ctx, r, c);
|
|
692
|
+
}
|
|
693
|
+
} else {
|
|
694
|
+
clearCellError(ctx, r, c);
|
|
695
|
+
delFunctionGroup(ctx, r, c);
|
|
696
|
+
curv_1 = _.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
|
|
697
|
+
curv_1.v = value;
|
|
698
|
+
delete curv_1.f;
|
|
699
|
+
delete curv_1.spl;
|
|
700
|
+
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;
|
|
701
|
+
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];
|
|
702
|
+
if (_typeof(curv_1) === "object" && (curv_1 === null || curv_1 === void 0 ? void 0 : curv_1.baseValue)) {
|
|
703
|
+
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);
|
|
704
|
+
curv_1.baseValue = value;
|
|
705
|
+
}
|
|
706
|
+
execFunctionGroup(ctx, r, c, curv_1);
|
|
707
|
+
isRunExecFunction = false;
|
|
708
|
+
if (curv_1.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
|
|
709
|
+
curv_1.qp = 0;
|
|
710
|
+
if (curv_1.ct) {
|
|
711
|
+
curv_1.ct.fa = "General";
|
|
712
|
+
curv_1.ct.t = "n";
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
value = curv_1;
|
|
718
|
+
} else {
|
|
661
719
|
if (_.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
|
|
662
720
|
var v = execfunction(ctx, value, r, c, undefined, undefined, true);
|
|
663
721
|
isRunExecFunction = false;
|
|
664
|
-
|
|
665
|
-
|
|
722
|
+
value = {
|
|
723
|
+
v: v[1],
|
|
724
|
+
f: v[2]
|
|
725
|
+
};
|
|
726
|
+
if (/^[\d.,]+$/.test(value.v)) {
|
|
727
|
+
var args = (_k = getContentInParentheses(value === null || value === void 0 ? void 0 : value.f)) === null || _k === void 0 ? void 0 : _k.split(",");
|
|
728
|
+
var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
|
|
729
|
+
return arg.trim().toUpperCase();
|
|
730
|
+
});
|
|
731
|
+
var formatted = processArray(cellRefs, d, flowdata);
|
|
732
|
+
if (formatted) {
|
|
733
|
+
value.m = update(formatted, value.v);
|
|
734
|
+
value.ct = {
|
|
735
|
+
fa: formatted,
|
|
736
|
+
t: "n"
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
value.ht = 2;
|
|
740
|
+
}
|
|
666
741
|
if (v.length === 4 && v[3].type === "sparklines") {
|
|
667
|
-
delete curv.m;
|
|
668
|
-
delete curv.v;
|
|
669
742
|
var curCalv = v[3].data;
|
|
670
743
|
if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
|
|
671
|
-
|
|
744
|
+
value.v = curCalv[0];
|
|
672
745
|
} else {
|
|
673
|
-
|
|
746
|
+
value.spl = v[3].data;
|
|
674
747
|
}
|
|
675
748
|
} else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
|
|
676
749
|
dynamicArrayItem = v[3].data;
|
|
@@ -680,198 +753,118 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
680
753
|
if (_.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
|
|
681
754
|
var v = execfunction(ctx, valueFunction, r, c, undefined, undefined, true);
|
|
682
755
|
isRunExecFunction = false;
|
|
683
|
-
|
|
684
|
-
curv.v = v[1], curv.f = v[2];
|
|
756
|
+
value.v = v[1], value.f = v[2];
|
|
685
757
|
if (v.length === 4 && v[3].type === "sparklines") {
|
|
686
|
-
delete curv.m;
|
|
687
|
-
delete curv.v;
|
|
688
758
|
var curCalv = v[3].data;
|
|
689
759
|
if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
|
|
690
|
-
|
|
760
|
+
value.v = curCalv[0];
|
|
691
761
|
} else {
|
|
692
|
-
|
|
762
|
+
value.spl = v[3].data;
|
|
693
763
|
}
|
|
694
764
|
} else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
|
|
695
765
|
dynamicArrayItem = v[3].data;
|
|
696
766
|
}
|
|
697
767
|
} else {
|
|
698
|
-
Object.keys(value).forEach(function (attr) {
|
|
699
|
-
curv[attr] = value[attr];
|
|
700
|
-
});
|
|
701
768
|
clearCellError(ctx, r, c);
|
|
769
|
+
var v = curv_1;
|
|
770
|
+
if (_.isNil(value.v)) {
|
|
771
|
+
value.v = v;
|
|
772
|
+
}
|
|
702
773
|
}
|
|
703
774
|
} else {
|
|
704
775
|
clearCellError(ctx, r, c);
|
|
705
776
|
delFunctionGroup(ctx, r, c);
|
|
706
|
-
|
|
707
|
-
curv.v = value;
|
|
708
|
-
delete curv.f;
|
|
709
|
-
delete curv.spl;
|
|
710
|
-
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;
|
|
711
|
-
var coin_1 = (_j = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _j === void 0 ? void 0 : _j.toString().split(" ")[1];
|
|
712
|
-
if (_typeof(curv) === "object" && (curv === null || curv === void 0 ? void 0 : curv.baseValue)) {
|
|
713
|
-
curv.m = "".concat((parseFloat(value) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount_1 || 2), " ").concat(coin_1);
|
|
714
|
-
curv.baseValue = value;
|
|
715
|
-
}
|
|
716
|
-
execFunctionGroup(ctx, r, c, curv);
|
|
777
|
+
execFunctionGroup(ctx, r, c, value);
|
|
717
778
|
isRunExecFunction = false;
|
|
718
|
-
if (curv.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
|
|
719
|
-
curv.qp = 0;
|
|
720
|
-
if (curv.ct) {
|
|
721
|
-
curv.ct.fa = "General";
|
|
722
|
-
curv.ct.t = "n";
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
779
|
}
|
|
726
780
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
if (
|
|
730
|
-
|
|
731
|
-
|
|
781
|
+
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;
|
|
782
|
+
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];
|
|
783
|
+
if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
|
|
784
|
+
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);
|
|
785
|
+
}
|
|
786
|
+
if (typeof value === "string") {
|
|
732
787
|
value = {
|
|
733
|
-
|
|
734
|
-
|
|
788
|
+
ct: {
|
|
789
|
+
fa: "General",
|
|
790
|
+
t: "g"
|
|
791
|
+
},
|
|
792
|
+
v: value,
|
|
793
|
+
tb: "1"
|
|
735
794
|
};
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
795
|
+
} else if (_typeof(value) === "object" && !value.tb) {
|
|
796
|
+
value.tb = "1";
|
|
797
|
+
}
|
|
798
|
+
var isValueArray = Array.isArray((_q = value === null || value === void 0 ? void 0 : value.v) === null || _q === void 0 ? void 0 : _q[0]);
|
|
799
|
+
try {
|
|
800
|
+
if (isValueArray) {
|
|
801
|
+
if (spillSortResult(ctx, r, c, value, d)) {
|
|
802
|
+
cancelNormalSelected(ctx);
|
|
803
|
+
if (ctx.hooks.afterUpdateCell) {
|
|
804
|
+
var newValue_1 = _.cloneDeep(d[r][c]);
|
|
805
|
+
setTimeout(function () {
|
|
806
|
+
var _a, _b;
|
|
807
|
+
return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
ctx.formulaCache.execFunctionGlobalData = null;
|
|
811
|
+
return;
|
|
748
812
|
}
|
|
749
|
-
value.ht = 2;
|
|
750
813
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
814
|
+
} catch (e) {
|
|
815
|
+
console.log("[updateCell] spill failed; falling back", e);
|
|
816
|
+
}
|
|
817
|
+
var url = getUrlFromText($input === null || $input === void 0 ? void 0 : $input.innerText);
|
|
818
|
+
if (url && _typeof(value) === "object" && value) {
|
|
819
|
+
value.hl = 1;
|
|
820
|
+
if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
|
|
821
|
+
sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
|
|
822
|
+
linkType: "webpage",
|
|
823
|
+
linkAddress: url
|
|
824
|
+
};
|
|
825
|
+
if (typeof value.v !== "string") {
|
|
826
|
+
value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
|
|
760
827
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (_.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
|
|
764
|
-
var v = execfunction(ctx, valueFunction, r, c, undefined, undefined, true);
|
|
765
|
-
isRunExecFunction = false;
|
|
766
|
-
value.v = v[1], value.f = v[2];
|
|
767
|
-
if (v.length === 4 && v[3].type === "sparklines") {
|
|
768
|
-
var curCalv = v[3].data;
|
|
769
|
-
if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
|
|
770
|
-
value.v = curCalv[0];
|
|
771
|
-
} else {
|
|
772
|
-
value.spl = v[3].data;
|
|
773
|
-
}
|
|
774
|
-
} else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
|
|
775
|
-
dynamicArrayItem = v[3].data;
|
|
776
|
-
}
|
|
777
|
-
} else {
|
|
778
|
-
clearCellError(ctx, r, c);
|
|
779
|
-
var v = curv;
|
|
780
|
-
if (_.isNil(value.v)) {
|
|
781
|
-
value.v = v;
|
|
782
|
-
}
|
|
828
|
+
if (value.m == null) {
|
|
829
|
+
value.m = value.v;
|
|
783
830
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
delFunctionGroup(ctx, r, c);
|
|
787
|
-
execFunctionGroup(ctx, r, c, value);
|
|
788
|
-
isRunExecFunction = false;
|
|
831
|
+
if (value.fc == null) value.fc = "rgb(0, 0, 255)";
|
|
832
|
+
if (value.un == null) value.un = 1;
|
|
789
833
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
if (isValueArray) {
|
|
811
|
-
if (spillSortResult(ctx, r, c, value, d)) {
|
|
812
|
-
cancelNormalSelected(ctx);
|
|
813
|
-
if (ctx.hooks.afterUpdateCell) {
|
|
814
|
-
var newValue_1 = _.cloneDeep(d[r][c]);
|
|
815
|
-
setTimeout(function () {
|
|
816
|
-
var _a, _b;
|
|
817
|
-
return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
|
|
818
|
-
});
|
|
834
|
+
setCellValue(ctx, r, c, d, value);
|
|
835
|
+
cancelNormalSelected(ctx);
|
|
836
|
+
if ((curv_1 === null || curv_1 === void 0 ? void 0 : curv_1.tb) === "2" && curv_1.v || isInlineStringCell(d[r][c])) {
|
|
837
|
+
var defaultrowlen = ctx.defaultrowlen;
|
|
838
|
+
var cfg = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config || {};
|
|
839
|
+
if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
|
|
840
|
+
var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
|
|
841
|
+
var textInfo = canvas ? getCellTextInfo(d[r][c], canvas, ctx, {
|
|
842
|
+
r: r,
|
|
843
|
+
c: c,
|
|
844
|
+
cellWidth: cellWidth
|
|
845
|
+
}) : null;
|
|
846
|
+
var currentRowLen = defaultrowlen;
|
|
847
|
+
if (textInfo) {
|
|
848
|
+
currentRowLen = textInfo.textHeightAll + 2;
|
|
849
|
+
}
|
|
850
|
+
var previousRowHeight = getRowHeight(ctx, [r])[r];
|
|
851
|
+
if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
|
|
852
|
+
if (_.isNil(cfg.rowlen)) cfg.rowlen = {};
|
|
853
|
+
cfg.rowlen[r] = currentRowLen;
|
|
819
854
|
}
|
|
820
|
-
ctx.formulaCache.execFunctionGlobalData = null;
|
|
821
|
-
return;
|
|
822
855
|
}
|
|
823
856
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
|
|
831
|
-
sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
|
|
832
|
-
linkType: "webpage",
|
|
833
|
-
linkAddress: url
|
|
834
|
-
};
|
|
835
|
-
if (typeof value.v !== "string") {
|
|
836
|
-
value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
|
|
837
|
-
}
|
|
838
|
-
if (value.m == null) {
|
|
839
|
-
value.m = value.v;
|
|
840
|
-
}
|
|
841
|
-
if (value.fc == null) value.fc = "rgb(0, 0, 255)";
|
|
842
|
-
if (value.un == null) value.un = 1;
|
|
843
|
-
}
|
|
844
|
-
setCellValue(ctx, r, c, d, value);
|
|
845
|
-
cancelNormalSelected(ctx);
|
|
846
|
-
if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || isInlineStringCell(d[r][c])) {
|
|
847
|
-
var defaultrowlen = ctx.defaultrowlen;
|
|
848
|
-
var cfg = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config || {};
|
|
849
|
-
if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
|
|
850
|
-
var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
|
|
851
|
-
var textInfo = canvas ? getCellTextInfo(d[r][c], canvas, ctx, {
|
|
852
|
-
r: r,
|
|
853
|
-
c: c,
|
|
854
|
-
cellWidth: cellWidth
|
|
855
|
-
}) : null;
|
|
856
|
-
var currentRowLen = defaultrowlen;
|
|
857
|
-
if (textInfo) {
|
|
858
|
-
currentRowLen = textInfo.textHeightAll + 2;
|
|
859
|
-
}
|
|
860
|
-
var previousRowHeight = getRowHeight(ctx, [r])[r];
|
|
861
|
-
if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
|
|
862
|
-
if (_.isNil(cfg.rowlen)) cfg.rowlen = {};
|
|
863
|
-
cfg.rowlen[r] = currentRowLen;
|
|
864
|
-
}
|
|
857
|
+
if (ctx.hooks.afterUpdateCell) {
|
|
858
|
+
var newValue_2 = _.cloneDeep(flowdata[r][c]);
|
|
859
|
+
var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
|
|
860
|
+
setTimeout(function () {
|
|
861
|
+
afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue_1, newValue_2);
|
|
862
|
+
});
|
|
865
863
|
}
|
|
864
|
+
ctx.formulaCache.execFunctionGlobalData = null;
|
|
865
|
+
} catch (e) {
|
|
866
|
+
cancelNormalSelected(ctx);
|
|
866
867
|
}
|
|
867
|
-
if (ctx.hooks.afterUpdateCell) {
|
|
868
|
-
var newValue_2 = _.cloneDeep(flowdata[r][c]);
|
|
869
|
-
var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
|
|
870
|
-
setTimeout(function () {
|
|
871
|
-
afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue, newValue_2);
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
ctx.formulaCache.execFunctionGlobalData = null;
|
|
875
868
|
}
|
|
876
869
|
export function getOrigincell(ctx, r, c, i) {
|
|
877
870
|
var data = getFlowdata(ctx, i);
|
package/es/modules/formula.js
CHANGED
|
@@ -124,7 +124,7 @@ var FormulaCache = function () {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
FormulaCache.prototype.tryGetCellAsNumber = function (cell) {
|
|
127
|
-
var _a, _b, _c, _d
|
|
127
|
+
var _a, _b, _c, _d;
|
|
128
128
|
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;
|
|
129
129
|
if (isCryptoDeno && typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string") {
|
|
130
130
|
var splitedNumberString = cell.m.split(" ")[0];
|
|
@@ -134,20 +134,6 @@ var FormulaCache = function () {
|
|
|
134
134
|
var n = Number(cell === null || cell === void 0 ? void 0 : cell.v);
|
|
135
135
|
return Number.isNaN(n) ? cell.v : n;
|
|
136
136
|
}
|
|
137
|
-
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) {
|
|
138
|
-
var inlineValue = cell.ct.s.map(function (segment) {
|
|
139
|
-
return (segment === null || segment === void 0 ? void 0 : segment.v) || "";
|
|
140
|
-
}).join("");
|
|
141
|
-
var trimmedValue = inlineValue.trim();
|
|
142
|
-
if (trimmedValue.length > 0) {
|
|
143
|
-
var cleanedValue = trimmedValue.replace(/,/g, "");
|
|
144
|
-
var n = Number(cleanedValue);
|
|
145
|
-
if (!Number.isNaN(n)) {
|
|
146
|
-
return n;
|
|
147
|
-
}
|
|
148
|
-
return inlineValue;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
137
|
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;
|
|
152
138
|
};
|
|
153
139
|
return FormulaCache;
|
|
@@ -286,6 +286,7 @@ function extendCssText(origin, cover, isLimit) {
|
|
|
286
286
|
}
|
|
287
287
|
export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
288
288
|
var _a, _b, _c;
|
|
289
|
+
console.log("updateInlineStringFormat", attr, value);
|
|
289
290
|
var w = window.getSelection();
|
|
290
291
|
if (!w) return;
|
|
291
292
|
if (w.rangeCount === 0) return;
|