@fileverse-dev/fortune-core 1.3.10 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/range.js +20 -0
- package/es/api/sheet.js +30 -2
- package/es/events/keyboard.js +15 -1
- package/es/events/paste.js +77 -28
- package/es/modules/cell.js +58 -2
- package/es/modules/comment.js +129 -24
- package/es/modules/dataVerification.js +34 -1
- package/es/modules/dropCell.js +65 -1
- package/es/modules/formula.js +14 -0
- package/es/modules/hyperlink.js +52 -5
- package/es/modules/merge.js +93 -1
- package/es/modules/moveCells.js +35 -9
- package/es/modules/rowcol.js +75 -2
- package/es/modules/searchReplace.js +58 -2
- package/es/modules/selection.js +152 -42
- package/es/modules/sort.js +74 -9
- package/es/modules/splitColumn.js +21 -0
- package/es/modules/toolbar.js +46 -3
- package/es/settings.d.ts +5 -0
- package/lib/api/range.js +20 -0
- package/lib/api/sheet.js +29 -1
- package/lib/events/keyboard.js +15 -1
- package/lib/events/paste.js +77 -28
- package/lib/modules/cell.js +58 -2
- package/lib/modules/comment.js +129 -24
- package/lib/modules/dataVerification.js +34 -1
- package/lib/modules/dropCell.js +65 -1
- package/lib/modules/formula.js +14 -0
- package/lib/modules/hyperlink.js +52 -5
- package/lib/modules/merge.js +93 -1
- package/lib/modules/moveCells.js +35 -9
- package/lib/modules/rowcol.js +75 -2
- package/lib/modules/searchReplace.js +58 -2
- package/lib/modules/selection.js +152 -42
- package/lib/modules/sort.js +74 -9
- package/lib/modules/splitColumn.js +21 -0
- package/lib/modules/toolbar.js +46 -3
- package/lib/settings.d.ts +5 -0
- package/package.json +1 -1
package/lib/modules/selection.js
CHANGED
|
@@ -215,7 +215,7 @@ function selectTitlesRange(map) {
|
|
|
215
215
|
return rangeArr;
|
|
216
216
|
}
|
|
217
217
|
function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
218
|
-
var _a;
|
|
218
|
+
var _a, _b, _c;
|
|
219
219
|
var cfg = ctx.config;
|
|
220
220
|
if (cfg.merge == null) {
|
|
221
221
|
cfg.merge = {};
|
|
@@ -254,6 +254,7 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
254
254
|
var timesC = Math.ceil((maxc - minc + 1) / copyc);
|
|
255
255
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
256
256
|
if (flowdata == null) return;
|
|
257
|
+
var cellChanges = [];
|
|
257
258
|
var cellMaxLength = flowdata[0].length;
|
|
258
259
|
var rowMaxLength = flowdata.length;
|
|
259
260
|
var borderInfoCompute = (0, _border.getBorderInfoCompute)(ctx, copySheetIndex);
|
|
@@ -391,6 +392,17 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
}
|
|
395
|
+
cellChanges.push({
|
|
396
|
+
sheetId: ctx.currentSheetId,
|
|
397
|
+
path: ["celldata"],
|
|
398
|
+
value: {
|
|
399
|
+
r: h,
|
|
400
|
+
c: c,
|
|
401
|
+
v: (_a = x[c]) !== null && _a !== void 0 ? _a : null
|
|
402
|
+
},
|
|
403
|
+
key: "".concat(h, "_").concat(c),
|
|
404
|
+
type: "update"
|
|
405
|
+
});
|
|
394
406
|
};
|
|
395
407
|
for (var c = mtc; c < maxcellCahe; c += 1) {
|
|
396
408
|
_loop_2(c);
|
|
@@ -403,6 +415,9 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
403
415
|
}
|
|
404
416
|
}
|
|
405
417
|
}
|
|
418
|
+
if (cellChanges.length > 0 && ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc)) {
|
|
419
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
420
|
+
}
|
|
406
421
|
var currFile = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)];
|
|
407
422
|
currFile.config = cfg;
|
|
408
423
|
if (dataVerification != null) {
|
|
@@ -414,7 +429,7 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
414
429
|
if (!_lodash.default.isNil(ruleArr) && ruleArr.length > 0) {
|
|
415
430
|
var currentIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
416
431
|
var existingCf = ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save;
|
|
417
|
-
var cdformat = (
|
|
432
|
+
var cdformat = (_c = _lodash.default.cloneDeep(existingCf)) !== null && _c !== void 0 ? _c : [];
|
|
418
433
|
for (var i = 0; i < ruleArr.length; i += 1) {
|
|
419
434
|
var cdformat_cellrange = ruleArr[i].cellrange;
|
|
420
435
|
var emptyRange = [];
|
|
@@ -1536,7 +1551,7 @@ function copy(ctx) {
|
|
|
1536
1551
|
}
|
|
1537
1552
|
}
|
|
1538
1553
|
function deleteSelectedCellText(ctx) {
|
|
1539
|
-
var _a, _b, _c, _d;
|
|
1554
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1540
1555
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1541
1556
|
if (allowEdit === false || ctx.isFlvReadOnly) {
|
|
1542
1557
|
return "allowEdit";
|
|
@@ -1599,22 +1614,30 @@ function deleteSelectedCellText(ctx) {
|
|
|
1599
1614
|
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
|
|
1600
1615
|
ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
|
|
1601
1616
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1617
|
+
if (!((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.afterUpdateCell)) {
|
|
1618
|
+
changes.push({
|
|
1619
|
+
sheetId: ctx.currentSheetId,
|
|
1620
|
+
path: ["celldata"],
|
|
1621
|
+
value: {
|
|
1622
|
+
r: r,
|
|
1623
|
+
c: c,
|
|
1624
|
+
v: d[r][c]
|
|
1625
|
+
},
|
|
1626
|
+
key: "".concat(r, "_").concat(c),
|
|
1627
|
+
type: "update"
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1611
1630
|
}
|
|
1612
1631
|
}
|
|
1632
|
+
if (changes.length > 0 && ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc)) {
|
|
1633
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
1634
|
+
}
|
|
1613
1635
|
}
|
|
1614
1636
|
}
|
|
1615
1637
|
return "success";
|
|
1616
1638
|
}
|
|
1617
1639
|
function deleteSelectedCellFormat(ctx) {
|
|
1640
|
+
var _a;
|
|
1618
1641
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1619
1642
|
if (allowEdit === false) {
|
|
1620
1643
|
return "allowEdit";
|
|
@@ -1637,6 +1660,7 @@ function deleteSelectedCellFormat(ctx) {
|
|
|
1637
1660
|
if (has_PartMC) {
|
|
1638
1661
|
return "partMC";
|
|
1639
1662
|
}
|
|
1663
|
+
var cellChanges = [];
|
|
1640
1664
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1641
1665
|
var r1 = selection[s].row[0];
|
|
1642
1666
|
var r2 = selection[s].row[1];
|
|
@@ -1655,16 +1679,30 @@ function deleteSelectedCellFormat(ctx) {
|
|
|
1655
1679
|
delete cell.bg;
|
|
1656
1680
|
delete cell.tb;
|
|
1657
1681
|
}
|
|
1682
|
+
cellChanges.push({
|
|
1683
|
+
sheetId: ctx.currentSheetId,
|
|
1684
|
+
path: ["celldata"],
|
|
1685
|
+
value: {
|
|
1686
|
+
r: r,
|
|
1687
|
+
c: c,
|
|
1688
|
+
v: d[r][c]
|
|
1689
|
+
},
|
|
1690
|
+
key: "".concat(r, "_").concat(c),
|
|
1691
|
+
type: "update"
|
|
1692
|
+
});
|
|
1658
1693
|
}
|
|
1659
1694
|
}
|
|
1660
1695
|
}
|
|
1661
1696
|
}
|
|
1697
|
+
if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
1698
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
1699
|
+
}
|
|
1662
1700
|
}
|
|
1663
1701
|
return "success";
|
|
1664
1702
|
}
|
|
1665
1703
|
function fillRightData(ctx) {
|
|
1666
1704
|
var _a, _b, _c, _d;
|
|
1667
|
-
var _e, _f, _g;
|
|
1705
|
+
var _e, _f, _g, _h;
|
|
1668
1706
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1669
1707
|
if (allowEdit === false) {
|
|
1670
1708
|
return "allowEdit";
|
|
@@ -1687,6 +1725,7 @@ function fillRightData(ctx) {
|
|
|
1687
1725
|
if (has_PartMC) {
|
|
1688
1726
|
return "partMC";
|
|
1689
1727
|
}
|
|
1728
|
+
var cellChanges = [];
|
|
1690
1729
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1691
1730
|
var r1 = selection[s].row[0];
|
|
1692
1731
|
var r2 = selection[s].row[1];
|
|
@@ -1704,19 +1743,23 @@ function fillRightData(ctx) {
|
|
|
1704
1743
|
var srcCol = c1 - 1;
|
|
1705
1744
|
var prev = d[r1][c1 - 1];
|
|
1706
1745
|
d[r1][c1] = prev != null ? __assign({}, prev) : {};
|
|
1746
|
+
cellChanges.push({
|
|
1747
|
+
sheetId: ctx.currentSheetId,
|
|
1748
|
+
path: ["celldata"],
|
|
1749
|
+
value: {
|
|
1750
|
+
r: r1,
|
|
1751
|
+
c: c1,
|
|
1752
|
+
v: d[r1][c1]
|
|
1753
|
+
},
|
|
1754
|
+
key: "".concat(r1, "_").concat(c1),
|
|
1755
|
+
type: "update"
|
|
1756
|
+
});
|
|
1707
1757
|
if (file != null) {
|
|
1708
1758
|
var srcKey = "".concat(srcRow, "_").concat(srcCol);
|
|
1709
1759
|
var tgtKey = "".concat(r1, "_").concat(c1);
|
|
1710
1760
|
if (dataVerification != null) {
|
|
1711
1761
|
var dv = dataVerification[srcKey];
|
|
1712
1762
|
if (dv != null) {
|
|
1713
|
-
console.log("[fillRightData] dataVerification copy from", {
|
|
1714
|
-
row: srcRow,
|
|
1715
|
-
col: srcCol
|
|
1716
|
-
}, "→", {
|
|
1717
|
-
row: r1,
|
|
1718
|
-
col: c1
|
|
1719
|
-
}, dv);
|
|
1720
1763
|
file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_a = {}, _a[tgtKey] = _lodash.default.cloneDeep(dv), _a));
|
|
1721
1764
|
}
|
|
1722
1765
|
}
|
|
@@ -1753,6 +1796,17 @@ function fillRightData(ctx) {
|
|
|
1753
1796
|
for (var c = c1 + 1; c <= c2; c += 1) {
|
|
1754
1797
|
if (d[r]) {
|
|
1755
1798
|
d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
|
|
1799
|
+
cellChanges.push({
|
|
1800
|
+
sheetId: ctx.currentSheetId,
|
|
1801
|
+
path: ["celldata"],
|
|
1802
|
+
value: {
|
|
1803
|
+
r: r,
|
|
1804
|
+
c: c,
|
|
1805
|
+
v: d[r][c]
|
|
1806
|
+
},
|
|
1807
|
+
key: "".concat(r, "_").concat(c),
|
|
1808
|
+
type: "update"
|
|
1809
|
+
});
|
|
1756
1810
|
}
|
|
1757
1811
|
if (file != null) {
|
|
1758
1812
|
var srcKey = "".concat(r, "_").concat(c1);
|
|
@@ -1760,13 +1814,6 @@ function fillRightData(ctx) {
|
|
|
1760
1814
|
if (dataVerification != null) {
|
|
1761
1815
|
var dv = dataVerification[srcKey];
|
|
1762
1816
|
if (dv != null) {
|
|
1763
|
-
console.log("[fillRightData] dataVerification copy from", {
|
|
1764
|
-
row: r,
|
|
1765
|
-
col: c1
|
|
1766
|
-
}, "→", {
|
|
1767
|
-
row: r,
|
|
1768
|
-
col: c
|
|
1769
|
-
}, dv);
|
|
1770
1817
|
file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_c = {}, _c[tgtKey] = _lodash.default.cloneDeep(dv), _c));
|
|
1771
1818
|
}
|
|
1772
1819
|
}
|
|
@@ -1800,12 +1847,15 @@ function fillRightData(ctx) {
|
|
|
1800
1847
|
}
|
|
1801
1848
|
}
|
|
1802
1849
|
}
|
|
1850
|
+
if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
1851
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
1852
|
+
}
|
|
1803
1853
|
}
|
|
1804
1854
|
return "success";
|
|
1805
1855
|
}
|
|
1806
1856
|
function fillDownData(ctx) {
|
|
1807
1857
|
var _a, _b, _c, _d;
|
|
1808
|
-
var _e, _f, _g;
|
|
1858
|
+
var _e, _f, _g, _h;
|
|
1809
1859
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1810
1860
|
if (allowEdit === false) {
|
|
1811
1861
|
return "allowEdit";
|
|
@@ -1828,6 +1878,7 @@ function fillDownData(ctx) {
|
|
|
1828
1878
|
if (has_PartMC) {
|
|
1829
1879
|
return "partMC";
|
|
1830
1880
|
}
|
|
1881
|
+
var cellChanges = [];
|
|
1831
1882
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1832
1883
|
var r1 = selection[s].row[0];
|
|
1833
1884
|
var r2 = selection[s].row[1];
|
|
@@ -1846,19 +1897,23 @@ function fillDownData(ctx) {
|
|
|
1846
1897
|
var prev = d[r1 - 1][c1];
|
|
1847
1898
|
if (!d[r1]) d[r1] = [];
|
|
1848
1899
|
d[r1][c1] = prev != null ? __assign({}, prev) : {};
|
|
1900
|
+
cellChanges.push({
|
|
1901
|
+
sheetId: ctx.currentSheetId,
|
|
1902
|
+
path: ["celldata"],
|
|
1903
|
+
value: {
|
|
1904
|
+
r: r1,
|
|
1905
|
+
c: c1,
|
|
1906
|
+
v: d[r1][c1]
|
|
1907
|
+
},
|
|
1908
|
+
key: "".concat(r1, "_").concat(c1),
|
|
1909
|
+
type: "update"
|
|
1910
|
+
});
|
|
1849
1911
|
if (file != null) {
|
|
1850
1912
|
var srcKey = "".concat(srcRow, "_").concat(srcCol);
|
|
1851
1913
|
var tgtKey = "".concat(r1, "_").concat(c1);
|
|
1852
1914
|
if (dataVerification != null) {
|
|
1853
1915
|
var dv = dataVerification[srcKey];
|
|
1854
1916
|
if (dv != null) {
|
|
1855
|
-
console.log("[fillDownData] dataVerification copy from", {
|
|
1856
|
-
row: srcRow,
|
|
1857
|
-
col: srcCol
|
|
1858
|
-
}, "→", {
|
|
1859
|
-
row: r1,
|
|
1860
|
-
col: c1
|
|
1861
|
-
}, dv);
|
|
1862
1917
|
file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_a = {}, _a[tgtKey] = _lodash.default.cloneDeep(dv), _a));
|
|
1863
1918
|
}
|
|
1864
1919
|
}
|
|
@@ -1895,19 +1950,23 @@ function fillDownData(ctx) {
|
|
|
1895
1950
|
for (var r = r1 + 1; r <= r2; r += 1) {
|
|
1896
1951
|
if (!d[r]) d[r] = [];
|
|
1897
1952
|
d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
|
|
1953
|
+
cellChanges.push({
|
|
1954
|
+
sheetId: ctx.currentSheetId,
|
|
1955
|
+
path: ["celldata"],
|
|
1956
|
+
value: {
|
|
1957
|
+
r: r,
|
|
1958
|
+
c: c,
|
|
1959
|
+
v: d[r][c]
|
|
1960
|
+
},
|
|
1961
|
+
key: "".concat(r, "_").concat(c),
|
|
1962
|
+
type: "update"
|
|
1963
|
+
});
|
|
1898
1964
|
if (file != null) {
|
|
1899
1965
|
var srcKey = "".concat(r1, "_").concat(c);
|
|
1900
1966
|
var tgtKey = "".concat(r, "_").concat(c);
|
|
1901
1967
|
if (dataVerification != null) {
|
|
1902
1968
|
var dv = dataVerification[srcKey];
|
|
1903
1969
|
if (dv != null) {
|
|
1904
|
-
console.log("[fillDownData] dataVerification copy from", {
|
|
1905
|
-
row: r1,
|
|
1906
|
-
col: c
|
|
1907
|
-
}, "→", {
|
|
1908
|
-
row: r,
|
|
1909
|
-
col: c
|
|
1910
|
-
}, dv);
|
|
1911
1970
|
file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_c = {}, _c[tgtKey] = _lodash.default.cloneDeep(dv), _c));
|
|
1912
1971
|
}
|
|
1913
1972
|
}
|
|
@@ -1941,10 +2000,14 @@ function fillDownData(ctx) {
|
|
|
1941
2000
|
}
|
|
1942
2001
|
}
|
|
1943
2002
|
}
|
|
2003
|
+
if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
2004
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
2005
|
+
}
|
|
1944
2006
|
}
|
|
1945
2007
|
return "success";
|
|
1946
2008
|
}
|
|
1947
2009
|
function textFormat(ctx, type) {
|
|
2010
|
+
var _a;
|
|
1948
2011
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1949
2012
|
if (allowEdit === false) {
|
|
1950
2013
|
return "allowEdit";
|
|
@@ -1953,6 +2016,7 @@ function textFormat(ctx, type) {
|
|
|
1953
2016
|
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
1954
2017
|
var d = (0, _context.getFlowdata)(ctx);
|
|
1955
2018
|
if (!d) return "dataNullError";
|
|
2019
|
+
var cellChanges = [];
|
|
1956
2020
|
var has_PartMC = false;
|
|
1957
2021
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1958
2022
|
var r1 = selection[s].row[0];
|
|
@@ -1986,14 +2050,29 @@ function textFormat(ctx, type) {
|
|
|
1986
2050
|
cell.tb = "1";
|
|
1987
2051
|
cell.ht = 2;
|
|
1988
2052
|
}
|
|
2053
|
+
cellChanges.push({
|
|
2054
|
+
sheetId: ctx.currentSheetId,
|
|
2055
|
+
path: ["celldata"],
|
|
2056
|
+
value: {
|
|
2057
|
+
r: r,
|
|
2058
|
+
c: c,
|
|
2059
|
+
v: d[r][c]
|
|
2060
|
+
},
|
|
2061
|
+
key: "".concat(r, "_").concat(c),
|
|
2062
|
+
type: "update"
|
|
2063
|
+
});
|
|
1989
2064
|
}
|
|
1990
2065
|
}
|
|
1991
2066
|
}
|
|
1992
2067
|
}
|
|
2068
|
+
if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
2069
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
2070
|
+
}
|
|
1993
2071
|
}
|
|
1994
2072
|
return "success";
|
|
1995
2073
|
}
|
|
1996
2074
|
function fillDate(ctx) {
|
|
2075
|
+
var _a;
|
|
1997
2076
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1998
2077
|
if (allowEdit === false) {
|
|
1999
2078
|
return "allowEdit";
|
|
@@ -2002,6 +2081,7 @@ function fillDate(ctx) {
|
|
|
2002
2081
|
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
2003
2082
|
var d = (0, _context.getFlowdata)(ctx);
|
|
2004
2083
|
if (!d) return "dataNullError";
|
|
2084
|
+
var cellChanges = [];
|
|
2005
2085
|
var has_PartMC = false;
|
|
2006
2086
|
for (var s = 0; s < selection.length; s += 1) {
|
|
2007
2087
|
var r1 = selection[s].row[0];
|
|
@@ -2028,13 +2108,28 @@ function fillDate(ctx) {
|
|
|
2028
2108
|
d[r][c] = {
|
|
2029
2109
|
v: formattedDate
|
|
2030
2110
|
};
|
|
2111
|
+
cellChanges.push({
|
|
2112
|
+
sheetId: ctx.currentSheetId,
|
|
2113
|
+
path: ["celldata"],
|
|
2114
|
+
value: {
|
|
2115
|
+
r: r,
|
|
2116
|
+
c: c,
|
|
2117
|
+
v: d[r][c]
|
|
2118
|
+
},
|
|
2119
|
+
key: "".concat(r, "_").concat(c),
|
|
2120
|
+
type: "update"
|
|
2121
|
+
});
|
|
2031
2122
|
}
|
|
2032
2123
|
}
|
|
2033
2124
|
}
|
|
2125
|
+
if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
2126
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
2127
|
+
}
|
|
2034
2128
|
}
|
|
2035
2129
|
return "success";
|
|
2036
2130
|
}
|
|
2037
2131
|
function fillTime(ctx) {
|
|
2132
|
+
var _a;
|
|
2038
2133
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
2039
2134
|
if (allowEdit === false) {
|
|
2040
2135
|
return "allowEdit";
|
|
@@ -2043,6 +2138,7 @@ function fillTime(ctx) {
|
|
|
2043
2138
|
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
2044
2139
|
var d = (0, _context.getFlowdata)(ctx);
|
|
2045
2140
|
if (!d) return "dataNullError";
|
|
2141
|
+
var cellChanges = [];
|
|
2046
2142
|
var has_PartMC = false;
|
|
2047
2143
|
for (var s = 0; s < selection.length; s += 1) {
|
|
2048
2144
|
var r1 = selection[s].row[0];
|
|
@@ -2069,9 +2165,23 @@ function fillTime(ctx) {
|
|
|
2069
2165
|
d[r][c] = {
|
|
2070
2166
|
v: formattedTime
|
|
2071
2167
|
};
|
|
2168
|
+
cellChanges.push({
|
|
2169
|
+
sheetId: ctx.currentSheetId,
|
|
2170
|
+
path: ["celldata"],
|
|
2171
|
+
value: {
|
|
2172
|
+
r: r,
|
|
2173
|
+
c: c,
|
|
2174
|
+
v: d[r][c]
|
|
2175
|
+
},
|
|
2176
|
+
key: "".concat(r, "_").concat(c),
|
|
2177
|
+
type: "update"
|
|
2178
|
+
});
|
|
2072
2179
|
}
|
|
2073
2180
|
}
|
|
2074
2181
|
}
|
|
2182
|
+
if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
2183
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
2184
|
+
}
|
|
2075
2185
|
}
|
|
2076
2186
|
return "success";
|
|
2077
2187
|
}
|
package/lib/modules/sort.js
CHANGED
|
@@ -78,6 +78,7 @@ function orderbydata(isAsc, index, data) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
function sortDataRange(ctx, sheetData, dataRange, index, isAsc, str, edr, stc, edc) {
|
|
81
|
+
var _a, _b;
|
|
81
82
|
var sortedData = orderbydata(isAsc, index, dataRange).sortedData;
|
|
82
83
|
for (var r = str; r <= edr; r += 1) {
|
|
83
84
|
for (var c = stc; c <= edc; c += 1) {
|
|
@@ -89,6 +90,26 @@ function sortDataRange(ctx, sheetData, dataRange, index, isAsc, str, edr, stc, e
|
|
|
89
90
|
row: [str, edr],
|
|
90
91
|
column: [stc, edc]
|
|
91
92
|
}]);
|
|
93
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
94
|
+
var changes = [];
|
|
95
|
+
for (var r = str; r <= edr; r += 1) {
|
|
96
|
+
var row = sheetData[r] || [];
|
|
97
|
+
for (var c = stc; c <= edc; c += 1) {
|
|
98
|
+
changes.push({
|
|
99
|
+
sheetId: ctx.currentSheetId,
|
|
100
|
+
path: ["celldata"],
|
|
101
|
+
value: {
|
|
102
|
+
r: r,
|
|
103
|
+
c: c,
|
|
104
|
+
v: (_b = row === null || row === void 0 ? void 0 : row[c]) !== null && _b !== void 0 ? _b : null
|
|
105
|
+
},
|
|
106
|
+
key: "".concat(r, "_").concat(c),
|
|
107
|
+
type: "update"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
112
|
+
}
|
|
92
113
|
}
|
|
93
114
|
function sortSelection(ctx, isAsc, colIndex) {
|
|
94
115
|
var _a;
|
|
@@ -153,35 +174,57 @@ function sortSelection(ctx, isAsc, colIndex) {
|
|
|
153
174
|
sortDataRange(ctx, d, data, colIndex, isAsc, str, edr, c1, c2);
|
|
154
175
|
}
|
|
155
176
|
function createRowsOrColumnsForSpilledValues(ctx, startRow, startColumn, spillRows, spillCols) {
|
|
177
|
+
var _a, _b;
|
|
156
178
|
var flowdata = (0, _2.getFlowdata)(ctx);
|
|
157
179
|
if (!flowdata) return;
|
|
180
|
+
var cellChanges = [];
|
|
158
181
|
try {
|
|
159
182
|
var sheetIndex = (0, _2.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
160
183
|
var sheet = ctx.luckysheetfile[sheetIndex];
|
|
161
|
-
var
|
|
162
|
-
var
|
|
163
|
-
if (sheet.row && sheet.row <
|
|
164
|
-
sheet.row =
|
|
184
|
+
var requiredRowCount_1 = startRow + spillRows;
|
|
185
|
+
var requiredColCount_1 = startColumn + spillCols;
|
|
186
|
+
if (sheet.row && sheet.row < requiredRowCount_1) {
|
|
187
|
+
sheet.row = requiredRowCount_1;
|
|
165
188
|
}
|
|
166
|
-
if (sheet.column && sheet.column <
|
|
167
|
-
sheet.column =
|
|
189
|
+
if (sheet.column && sheet.column < requiredColCount_1) {
|
|
190
|
+
sheet.column = requiredColCount_1;
|
|
168
191
|
}
|
|
169
192
|
} catch (error) {
|
|
170
193
|
console.error("Failed to update sheet metadata for spill operation", error);
|
|
171
194
|
}
|
|
172
|
-
|
|
195
|
+
var requiredRowCount = startRow + spillRows;
|
|
196
|
+
var requiredColCount = startColumn + spillCols;
|
|
197
|
+
while (flowdata.length < requiredRowCount) {
|
|
173
198
|
flowdata.push([]);
|
|
174
199
|
}
|
|
175
|
-
for (var rowIndex = startRow; rowIndex <
|
|
200
|
+
for (var rowIndex = startRow; rowIndex < requiredRowCount; rowIndex++) {
|
|
176
201
|
if (!Array.isArray(flowdata[rowIndex])) {
|
|
177
202
|
flowdata[rowIndex] = [];
|
|
178
203
|
}
|
|
179
|
-
|
|
204
|
+
var prevLen = flowdata[rowIndex].length;
|
|
205
|
+
while (flowdata[rowIndex].length < requiredColCount) {
|
|
180
206
|
flowdata[rowIndex].push(null);
|
|
181
207
|
}
|
|
208
|
+
for (var c = Math.max(prevLen, startColumn); c < requiredColCount; c += 1) {
|
|
209
|
+
cellChanges.push({
|
|
210
|
+
sheetId: ctx.currentSheetId,
|
|
211
|
+
path: ["celldata"],
|
|
212
|
+
value: {
|
|
213
|
+
r: rowIndex,
|
|
214
|
+
c: c,
|
|
215
|
+
v: (_a = flowdata[rowIndex][c]) !== null && _a !== void 0 ? _a : null
|
|
216
|
+
},
|
|
217
|
+
key: "".concat(rowIndex, "_").concat(c),
|
|
218
|
+
type: "update"
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (cellChanges.length > 0 && ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc)) {
|
|
223
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
182
224
|
}
|
|
183
225
|
}
|
|
184
226
|
function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
|
|
227
|
+
var _a, _b;
|
|
185
228
|
var formulaString = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.f;
|
|
186
229
|
var formulaValue = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.v;
|
|
187
230
|
if (typeof formulaString !== "string" || !(/= *SORT\s*\(/i.test(formulaString) || /= *XLOOKUP\s*\(/i.test(formulaString) || /= *SEQUENCE\s*\(/i.test(formulaString))) return false;
|
|
@@ -213,5 +256,27 @@ function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
|
|
|
213
256
|
});
|
|
214
257
|
}
|
|
215
258
|
}
|
|
259
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
260
|
+
var cellChanges = [];
|
|
261
|
+
for (var r = 0; r < rowCount; r += 1) {
|
|
262
|
+
var rr = startRow + r;
|
|
263
|
+
var row = (sheetData === null || sheetData === void 0 ? void 0 : sheetData[rr]) || [];
|
|
264
|
+
for (var c = 0; c < colCount; c += 1) {
|
|
265
|
+
var cc = startCol + c;
|
|
266
|
+
cellChanges.push({
|
|
267
|
+
sheetId: ctx.currentSheetId,
|
|
268
|
+
path: ["celldata"],
|
|
269
|
+
value: {
|
|
270
|
+
r: rr,
|
|
271
|
+
c: cc,
|
|
272
|
+
v: (_b = row === null || row === void 0 ? void 0 : row[cc]) !== null && _b !== void 0 ? _b : null
|
|
273
|
+
},
|
|
274
|
+
key: "".concat(rr, "_").concat(cc),
|
|
275
|
+
type: "update"
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (cellChanges.length > 0) ctx.hooks.updateCellYdoc(cellChanges);
|
|
280
|
+
}
|
|
216
281
|
return true;
|
|
217
282
|
}
|
|
@@ -23,14 +23,35 @@ function getNullData(rlen, clen) {
|
|
|
23
23
|
return arr;
|
|
24
24
|
}
|
|
25
25
|
function updateMoreCell(r, c, dataMatrix, ctx) {
|
|
26
|
+
var _a;
|
|
26
27
|
if (ctx.allowEdit === false) return;
|
|
27
28
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
29
|
+
var cellChanges = [];
|
|
28
30
|
dataMatrix.forEach(function (datas, i) {
|
|
29
31
|
datas.forEach(function (data, j) {
|
|
32
|
+
var _a, _b, _c;
|
|
30
33
|
var v = dataMatrix[i][j];
|
|
31
34
|
(0, _cell.setCellValue)(ctx, r + i, c + j, flowdata, v);
|
|
35
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
36
|
+
var rr = r + i;
|
|
37
|
+
var cc = c + j;
|
|
38
|
+
cellChanges.push({
|
|
39
|
+
sheetId: ctx.currentSheetId,
|
|
40
|
+
path: ["celldata"],
|
|
41
|
+
value: {
|
|
42
|
+
r: rr,
|
|
43
|
+
c: cc,
|
|
44
|
+
v: (_c = (_b = flowdata === null || flowdata === void 0 ? void 0 : flowdata[rr]) === null || _b === void 0 ? void 0 : _b[cc]) !== null && _c !== void 0 ? _c : null
|
|
45
|
+
},
|
|
46
|
+
key: "".concat(rr, "_").concat(cc),
|
|
47
|
+
type: "update"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
32
50
|
});
|
|
33
51
|
});
|
|
52
|
+
if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
53
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
54
|
+
}
|
|
34
55
|
}
|
|
35
56
|
function getRegStr(regStr, splitSymbols) {
|
|
36
57
|
regStr = "";
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -429,7 +429,8 @@ function activeFormulaInput(cellInput, fxInput, ctx, row_index, col_index, rowh,
|
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
|
|
432
|
-
var _a;
|
|
432
|
+
var _a, _b, _c;
|
|
433
|
+
var _d;
|
|
433
434
|
var f = "=".concat(formula.toUpperCase(), "(").concat((0, _cell.getRangetxt)(ctx, ctx.currentSheetId, {
|
|
434
435
|
row: rowh,
|
|
435
436
|
column: columnh
|
|
@@ -440,7 +441,20 @@ function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
|
|
|
440
441
|
f: v[2]
|
|
441
442
|
};
|
|
442
443
|
(0, _cell.setCellValue)(ctx, r, c, d, value);
|
|
443
|
-
(_a = ctx.
|
|
444
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
445
|
+
ctx.hooks.updateCellYdoc([{
|
|
446
|
+
sheetId: ctx.currentSheetId,
|
|
447
|
+
path: ["celldata"],
|
|
448
|
+
value: {
|
|
449
|
+
r: r,
|
|
450
|
+
c: c,
|
|
451
|
+
v: (_c = (_b = d === null || d === void 0 ? void 0 : d[r]) === null || _b === void 0 ? void 0 : _b[c]) !== null && _c !== void 0 ? _c : null
|
|
452
|
+
},
|
|
453
|
+
key: "".concat(r, "_").concat(c),
|
|
454
|
+
type: "update"
|
|
455
|
+
}]);
|
|
456
|
+
}
|
|
457
|
+
(_d = ctx.formulaCache).execFunctionExist || (_d.execFunctionExist = []);
|
|
444
458
|
ctx.formulaCache.execFunctionExist.push({
|
|
445
459
|
r: r,
|
|
446
460
|
c: c,
|
|
@@ -869,10 +883,12 @@ function handleFormatPainter(ctx) {
|
|
|
869
883
|
ctx.luckysheetPaintSingle = true;
|
|
870
884
|
}
|
|
871
885
|
function handleClearFormat(ctx) {
|
|
872
|
-
var _a;
|
|
886
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
873
887
|
if (ctx.allowEdit === false) return;
|
|
874
888
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
875
889
|
if (!flowdata) return;
|
|
890
|
+
var ydocChanges = [];
|
|
891
|
+
var borderInfoChanged = false;
|
|
876
892
|
(_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.every(function (selection) {
|
|
877
893
|
var _a = selection.row,
|
|
878
894
|
rowSt = _a[0],
|
|
@@ -888,6 +904,17 @@ function handleClearFormat(ctx) {
|
|
|
888
904
|
var cell = flowdata[r][c];
|
|
889
905
|
if (!cell) continue;
|
|
890
906
|
flowdata[r][c] = _lodash.default.pick(cell, "v", "m", "mc", "f", "ct");
|
|
907
|
+
ydocChanges.push({
|
|
908
|
+
sheetId: ctx.currentSheetId,
|
|
909
|
+
path: ["celldata"],
|
|
910
|
+
key: "".concat(r, "_").concat(c),
|
|
911
|
+
value: {
|
|
912
|
+
r: r,
|
|
913
|
+
c: c,
|
|
914
|
+
v: flowdata[r][c]
|
|
915
|
+
},
|
|
916
|
+
type: "update"
|
|
917
|
+
});
|
|
891
918
|
}
|
|
892
919
|
}
|
|
893
920
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
@@ -923,9 +950,25 @@ function handleClearFormat(ctx) {
|
|
|
923
950
|
}
|
|
924
951
|
}
|
|
925
952
|
ctx.luckysheetfile[index].config.borderInfo = source_borderInfo;
|
|
953
|
+
borderInfoChanged = true;
|
|
926
954
|
}
|
|
927
955
|
return true;
|
|
928
956
|
});
|
|
957
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
958
|
+
if (borderInfoChanged) {
|
|
959
|
+
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
960
|
+
var borderInfo = index == null ? (_d = (_c = ctx.config) === null || _c === void 0 ? void 0 : _c.borderInfo) !== null && _d !== void 0 ? _d : [] : (_g = (_f = (_e = ctx.luckysheetfile[index]) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.borderInfo) !== null && _g !== void 0 ? _g : [];
|
|
961
|
+
ydocChanges.push({
|
|
962
|
+
sheetId: ctx.currentSheetId,
|
|
963
|
+
path: ["config", "borderInfo"],
|
|
964
|
+
value: borderInfo,
|
|
965
|
+
type: "update"
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
if (ydocChanges.length > 0) {
|
|
969
|
+
ctx.hooks.updateCellYdoc(ydocChanges);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
929
972
|
}
|
|
930
973
|
function handleTextColor(ctx, cellInput, color) {
|
|
931
974
|
setAttr(ctx, cellInput, "fc", color);
|
package/lib/settings.d.ts
CHANGED
|
@@ -16,9 +16,12 @@ export type Hooks = {
|
|
|
16
16
|
iframeListChange?: () => void;
|
|
17
17
|
conditionRulesChange?: () => void;
|
|
18
18
|
conditionFormatChange?: () => void;
|
|
19
|
+
filterSelectChange?: () => void;
|
|
20
|
+
filterChange?: () => void;
|
|
19
21
|
cellDataChange?: () => void;
|
|
20
22
|
hyperlinkChange?: () => void;
|
|
21
23
|
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
24
|
+
updateAllCell?: (sheetId: string) => void;
|
|
22
25
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
23
26
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
24
27
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|
|
@@ -78,6 +81,8 @@ export type Hooks = {
|
|
|
78
81
|
afterIframesChange?: () => void;
|
|
79
82
|
afterFrozenChange?: () => void;
|
|
80
83
|
afterOrderChanges?: () => void;
|
|
84
|
+
afterColorChanges?: () => void;
|
|
85
|
+
afterHideChanges?: () => void;
|
|
81
86
|
afterConfigChanges?: () => void;
|
|
82
87
|
afterColRowChanges?: () => void;
|
|
83
88
|
afterShowGridLinesChange?: () => void;
|