@fileverse-dev/fortune-core 1.3.10 → 1.3.11-mixed
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 +74 -37
- package/es/events/mouse.js +1 -0
- package/es/events/paste.js +124 -56
- package/es/locale/en.d.ts +3 -0
- package/es/locale/en.js +3 -0
- package/es/locale/es.d.ts +3 -0
- package/es/locale/es.js +3 -0
- package/es/locale/hi.d.ts +3 -0
- package/es/locale/hi.js +3 -0
- package/es/locale/index.d.ts +3 -0
- package/es/locale/zh.d.ts +3 -0
- package/es/locale/zh.js +3 -0
- package/es/locale/zh_tw.d.ts +3 -0
- package/es/locale/zh_tw.js +3 -0
- package/es/modules/ConditionFormat.js +26 -0
- 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/format.js +12 -7
- 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/modules/validation.js +6 -3
- package/es/settings.d.ts +5 -0
- package/es/types.d.ts +2 -0
- package/lib/api/range.js +20 -0
- package/lib/api/sheet.js +29 -1
- package/lib/events/keyboard.js +74 -37
- package/lib/events/mouse.js +1 -0
- package/lib/events/paste.js +122 -54
- package/lib/locale/en.d.ts +3 -0
- package/lib/locale/en.js +3 -0
- package/lib/locale/es.d.ts +3 -0
- package/lib/locale/es.js +3 -0
- package/lib/locale/hi.d.ts +3 -0
- package/lib/locale/hi.js +3 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/zh.d.ts +3 -0
- package/lib/locale/zh.js +3 -0
- package/lib/locale/zh_tw.d.ts +3 -0
- package/lib/locale/zh_tw.js +3 -0
- package/lib/modules/ConditionFormat.js +26 -0
- 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/format.js +12 -7
- 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/modules/validation.js +6 -3
- package/lib/settings.d.ts +5 -0
- package/lib/types.d.ts +2 -0
- package/package.json +1 -1
package/es/modules/dropCell.js
CHANGED
|
@@ -1779,7 +1779,7 @@ function getApplyData(copyD, csLen, asLen) {
|
|
|
1779
1779
|
}
|
|
1780
1780
|
export function updateDropCell(ctx) {
|
|
1781
1781
|
var _a, _b, _c, _d;
|
|
1782
|
-
var _e, _f, _g;
|
|
1782
|
+
var _e, _f, _g, _h;
|
|
1783
1783
|
var d = getFlowdata(ctx);
|
|
1784
1784
|
var allowEdit = isAllowEdit(ctx);
|
|
1785
1785
|
var isReadOnly = isAllowEditReadOnly(ctx);
|
|
@@ -1815,6 +1815,7 @@ export function updateDropCell(ctx) {
|
|
|
1815
1815
|
var apply_end_r = applyRange.row[1];
|
|
1816
1816
|
var apply_str_c = applyRange.column[0];
|
|
1817
1817
|
var apply_end_c = applyRange.column[1];
|
|
1818
|
+
var cellChanges = [];
|
|
1818
1819
|
if (direction === "down" || direction === "up") {
|
|
1819
1820
|
var asLen = apply_end_r - apply_str_r + 1;
|
|
1820
1821
|
for (var i = apply_str_c; i <= apply_end_c; i += 1) {
|
|
@@ -1825,6 +1826,7 @@ export function updateDropCell(ctx) {
|
|
|
1825
1826
|
for (var j = apply_str_r; j <= apply_end_r; j += 1) {
|
|
1826
1827
|
if (hiddenRows.has("".concat(j))) continue;
|
|
1827
1828
|
var cell = applyData[j - apply_str_r];
|
|
1829
|
+
var afterHookCalled = false;
|
|
1828
1830
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
|
|
1829
1831
|
var f = "=".concat(formula.functionCopy(ctx, cell.f, "down", j - apply_str_r + 1));
|
|
1830
1832
|
var v = formula.execfunction(ctx, f, j, i);
|
|
@@ -1836,6 +1838,7 @@ export function updateDropCell(ctx) {
|
|
|
1836
1838
|
v: v[1] instanceof Promise ? v[1] : cell.v,
|
|
1837
1839
|
m: v[1] instanceof Promise ? "[object Promise]" : v[1]
|
|
1838
1840
|
}));
|
|
1841
|
+
afterHookCalled = true;
|
|
1839
1842
|
}
|
|
1840
1843
|
if (cell.spl != null) {
|
|
1841
1844
|
cell.spl = v[3].data;
|
|
@@ -1873,6 +1876,19 @@ export function updateDropCell(ctx) {
|
|
|
1873
1876
|
}
|
|
1874
1877
|
}
|
|
1875
1878
|
d[j][i] = cell || null;
|
|
1879
|
+
if (!afterHookCalled) {
|
|
1880
|
+
cellChanges.push({
|
|
1881
|
+
sheetId: ctx.currentSheetId,
|
|
1882
|
+
path: ["celldata"],
|
|
1883
|
+
value: {
|
|
1884
|
+
r: j,
|
|
1885
|
+
c: i,
|
|
1886
|
+
v: d[j][i]
|
|
1887
|
+
},
|
|
1888
|
+
key: "".concat(j, "_").concat(i),
|
|
1889
|
+
type: "update"
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1876
1892
|
var bd_r = copy_str_r + (j - apply_str_r) % csLen;
|
|
1877
1893
|
var bd_c = i;
|
|
1878
1894
|
if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
|
|
@@ -1911,6 +1927,7 @@ export function updateDropCell(ctx) {
|
|
|
1911
1927
|
for (var j = apply_end_r; j >= apply_str_r; j -= 1) {
|
|
1912
1928
|
if (hiddenRows.has("".concat(j))) continue;
|
|
1913
1929
|
var cell = applyData[apply_end_r - j];
|
|
1930
|
+
var afterHookCalled = false;
|
|
1914
1931
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
|
|
1915
1932
|
var f = "=".concat(formula.functionCopy(ctx, cell.f, "up", apply_end_r - j + 1));
|
|
1916
1933
|
var v = formula.execfunction(ctx, f, j, i);
|
|
@@ -1922,6 +1939,7 @@ export function updateDropCell(ctx) {
|
|
|
1922
1939
|
v: v[1] instanceof Promise ? v[1] : cell.v,
|
|
1923
1940
|
m: v[1] instanceof Promise ? "[object Promise]" : v[1]
|
|
1924
1941
|
}));
|
|
1942
|
+
afterHookCalled = true;
|
|
1925
1943
|
}
|
|
1926
1944
|
if (cell.spl != null) {
|
|
1927
1945
|
cell.spl = v[3].data;
|
|
@@ -1953,6 +1971,19 @@ export function updateDropCell(ctx) {
|
|
|
1953
1971
|
}
|
|
1954
1972
|
}
|
|
1955
1973
|
d[j][i] = cell || null;
|
|
1974
|
+
if (!afterHookCalled) {
|
|
1975
|
+
cellChanges.push({
|
|
1976
|
+
sheetId: ctx.currentSheetId,
|
|
1977
|
+
path: ["celldata"],
|
|
1978
|
+
value: {
|
|
1979
|
+
r: j,
|
|
1980
|
+
c: i,
|
|
1981
|
+
v: d[j][i]
|
|
1982
|
+
},
|
|
1983
|
+
key: "".concat(j, "_").concat(i),
|
|
1984
|
+
type: "update"
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1956
1987
|
var bd_r = copy_end_r - (apply_end_r - j) % csLen;
|
|
1957
1988
|
var bd_c = i;
|
|
1958
1989
|
if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
|
|
@@ -1998,6 +2029,7 @@ export function updateDropCell(ctx) {
|
|
|
1998
2029
|
for (var j = apply_str_c; j <= apply_end_c; j += 1) {
|
|
1999
2030
|
if (hiddenCols.has("".concat(j))) continue;
|
|
2000
2031
|
var cell = applyData[j - apply_str_c];
|
|
2032
|
+
var afterHookCalled = false;
|
|
2001
2033
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
|
|
2002
2034
|
var f = "=".concat(formula.functionCopy(ctx, cell.f, "right", j - apply_str_c + 1));
|
|
2003
2035
|
var v = formula.execfunction(ctx, f, i, j);
|
|
@@ -2009,6 +2041,7 @@ export function updateDropCell(ctx) {
|
|
|
2009
2041
|
v: v[1] instanceof Promise ? v[1] : cell.v,
|
|
2010
2042
|
m: v[1] instanceof Promise ? "[object Promise]" : v[1]
|
|
2011
2043
|
}));
|
|
2044
|
+
afterHookCalled = true;
|
|
2012
2045
|
}
|
|
2013
2046
|
if (cell.spl != null) {
|
|
2014
2047
|
cell.spl = v[3].data;
|
|
@@ -2040,6 +2073,19 @@ export function updateDropCell(ctx) {
|
|
|
2040
2073
|
}
|
|
2041
2074
|
}
|
|
2042
2075
|
d[i][j] = cell || null;
|
|
2076
|
+
if (!afterHookCalled) {
|
|
2077
|
+
cellChanges.push({
|
|
2078
|
+
sheetId: ctx.currentSheetId,
|
|
2079
|
+
path: ["celldata"],
|
|
2080
|
+
value: {
|
|
2081
|
+
r: i,
|
|
2082
|
+
c: j,
|
|
2083
|
+
v: d[i][j]
|
|
2084
|
+
},
|
|
2085
|
+
key: "".concat(i, "_").concat(j),
|
|
2086
|
+
type: "update"
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2043
2089
|
var bd_r = i;
|
|
2044
2090
|
var bd_c = copy_str_c + (j - apply_str_c) % csLen;
|
|
2045
2091
|
if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
|
|
@@ -2078,6 +2124,7 @@ export function updateDropCell(ctx) {
|
|
|
2078
2124
|
for (var j = apply_end_c; j >= apply_str_c; j -= 1) {
|
|
2079
2125
|
if (hiddenCols.has("".concat(j))) continue;
|
|
2080
2126
|
var cell = applyData[apply_end_c - j];
|
|
2127
|
+
var afterHookCalled = false;
|
|
2081
2128
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
|
|
2082
2129
|
var f = "=".concat(formula.functionCopy(ctx, cell.f, "left", apply_end_c - j + 1));
|
|
2083
2130
|
var v = formula.execfunction(ctx, f, i, j);
|
|
@@ -2089,6 +2136,7 @@ export function updateDropCell(ctx) {
|
|
|
2089
2136
|
v: v[1] instanceof Promise ? v[1] : cell.v,
|
|
2090
2137
|
m: v[1] instanceof Promise ? "[object Promise]" : v[1]
|
|
2091
2138
|
}));
|
|
2139
|
+
afterHookCalled = true;
|
|
2092
2140
|
}
|
|
2093
2141
|
if (cell.spl != null) {
|
|
2094
2142
|
cell.spl = v[3].data;
|
|
@@ -2120,6 +2168,19 @@ export function updateDropCell(ctx) {
|
|
|
2120
2168
|
}
|
|
2121
2169
|
}
|
|
2122
2170
|
d[i][j] = cell || null;
|
|
2171
|
+
if (!afterHookCalled) {
|
|
2172
|
+
cellChanges.push({
|
|
2173
|
+
sheetId: ctx.currentSheetId,
|
|
2174
|
+
path: ["celldata"],
|
|
2175
|
+
value: {
|
|
2176
|
+
r: i,
|
|
2177
|
+
c: j,
|
|
2178
|
+
v: d[i][j]
|
|
2179
|
+
},
|
|
2180
|
+
key: "".concat(i, "_").concat(j),
|
|
2181
|
+
type: "update"
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2123
2184
|
var bd_r = i;
|
|
2124
2185
|
var bd_c = copy_end_c - (apply_end_c - j) % csLen;
|
|
2125
2186
|
if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
|
|
@@ -2156,6 +2217,9 @@ export function updateDropCell(ctx) {
|
|
|
2156
2217
|
}
|
|
2157
2218
|
}
|
|
2158
2219
|
}
|
|
2220
|
+
if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
2221
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
2222
|
+
}
|
|
2159
2223
|
var cdformat = file.luckysheet_conditionformat_save;
|
|
2160
2224
|
if (cdformat != null && cdformat.length > 0) {
|
|
2161
2225
|
for (var i = 0; i < cdformat.length; i += 1) {
|
package/es/modules/format.js
CHANGED
|
@@ -240,20 +240,24 @@ export function genarate(value) {
|
|
|
240
240
|
v = datenum_local(dateObj);
|
|
241
241
|
ct.t = "d";
|
|
242
242
|
var map = {
|
|
243
|
-
"yyyy-MM-dd": "dd
|
|
244
|
-
"yyyy-MM-dd HH:mm": "dd
|
|
245
|
-
"yyyy-MM-ddTHH:mm": "dd
|
|
246
|
-
"yyyy/MM/dd": "
|
|
247
|
-
"yyyy/MM/dd HH:mm": "
|
|
243
|
+
"yyyy-MM-dd": "yyyy-MM-dd",
|
|
244
|
+
"yyyy-MM-dd HH:mm": "yyyy-MM-dd HH:mm",
|
|
245
|
+
"yyyy-MM-ddTHH:mm": "yyyy-MM-dd HH:mm",
|
|
246
|
+
"yyyy/MM/dd": "yyyy/MM/dd",
|
|
247
|
+
"yyyy/MM/dd HH:mm": "yyyy/MM/dd HH:mm",
|
|
248
248
|
"yyyy.MM.dd": "yyyy.MM.dd",
|
|
249
249
|
"MM/dd/yyyy h:mm AM/PM": "MM/dd/yyyy h:mm AM/PM",
|
|
250
250
|
"MM/dd/yyyy": "MM/dd/yyyy",
|
|
251
251
|
"M/d/yyyy": "M/d/yyyy",
|
|
252
252
|
"MM/dd/yy": "MM/dd/yy",
|
|
253
253
|
"dd/MM/yyyy": "dd/MM/yyyy",
|
|
254
|
-
"dd-MM-yyyy": "dd
|
|
254
|
+
"dd-MM-yyyy": "dd-MM-yyyy",
|
|
255
255
|
"dd.MM.yyyy": "dd.MM.yyyy",
|
|
256
|
-
named: "
|
|
256
|
+
"named-mdy-full": "mmmm d, yyyy",
|
|
257
|
+
"named-mdy-abbr": "mmm d, yyyy",
|
|
258
|
+
"named-dmy-full": "d mmmm yyyy",
|
|
259
|
+
"named-dmy-abbr": "d mmm yyyy",
|
|
260
|
+
"named-abbr-dashes": "mmm-d-yyyy"
|
|
257
261
|
};
|
|
258
262
|
ct.fa = map[df.formatType] || "dd/MM/yyyy";
|
|
259
263
|
m = SSF.format(ct.fa, v);
|
|
@@ -273,6 +277,7 @@ export function update(fmt, v) {
|
|
|
273
277
|
return SSF.format(fmt, v);
|
|
274
278
|
}
|
|
275
279
|
export function is_date(fmt, v) {
|
|
280
|
+
console.log(SSF.is_date(fmt, v), "is_date");
|
|
276
281
|
return SSF.is_date(fmt, v);
|
|
277
282
|
}
|
|
278
283
|
function fuzzynum(s) {
|
package/es/modules/formula.js
CHANGED
|
@@ -785,6 +785,7 @@ function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
|
785
785
|
return dynamicArray;
|
|
786
786
|
}
|
|
787
787
|
export function groupValuesRefresh(ctx) {
|
|
788
|
+
var _a, _b, _c;
|
|
788
789
|
var luckysheetfile = ctx.luckysheetfile;
|
|
789
790
|
if (ctx.groupValuesRefreshData.length > 0) {
|
|
790
791
|
for (var i = 0; i < ctx.groupValuesRefreshData.length; i += 1) {
|
|
@@ -807,6 +808,19 @@ export function groupValuesRefresh(ctx) {
|
|
|
807
808
|
updateValue.v = item.v;
|
|
808
809
|
updateValue.f = item.f;
|
|
809
810
|
setCellValue(ctx, item.r, item.c, data, updateValue);
|
|
811
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
812
|
+
ctx.hooks.updateCellYdoc([{
|
|
813
|
+
sheetId: item.id,
|
|
814
|
+
path: ["celldata"],
|
|
815
|
+
value: {
|
|
816
|
+
r: item.r,
|
|
817
|
+
c: item.c,
|
|
818
|
+
v: (_c = (_b = data === null || data === void 0 ? void 0 : data[item.r]) === null || _b === void 0 ? void 0 : _b[item.c]) !== null && _c !== void 0 ? _c : null
|
|
819
|
+
},
|
|
820
|
+
key: "".concat(item.r, "_").concat(item.c),
|
|
821
|
+
type: "update"
|
|
822
|
+
}]);
|
|
823
|
+
}
|
|
810
824
|
}
|
|
811
825
|
ctx.groupValuesRefreshData = [];
|
|
812
826
|
}
|
package/es/modules/hyperlink.js
CHANGED
|
@@ -41,7 +41,7 @@ export function getCellHyperlink(ctx, r, c) {
|
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
43
|
export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
|
|
44
|
-
var _a, _b, _c;
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
45
|
var applyToSelection = (options === null || options === void 0 ? void 0 : options.applyToSelection) && (options === null || options === void 0 ? void 0 : options.cellInput);
|
|
46
46
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
47
47
|
var flowdata = getFlowdata(ctx);
|
|
@@ -61,8 +61,30 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, option
|
|
|
61
61
|
id: ctx.currentSheetId
|
|
62
62
|
};
|
|
63
63
|
flowdata[r][c] = cell;
|
|
64
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
65
|
+
ctx.hooks.updateCellYdoc([{
|
|
66
|
+
sheetId: ctx.currentSheetId,
|
|
67
|
+
path: ["hyperlink"],
|
|
68
|
+
key: "".concat(r, "_").concat(c),
|
|
69
|
+
value: {
|
|
70
|
+
linkType: linkType,
|
|
71
|
+
linkAddress: linkAddress
|
|
72
|
+
},
|
|
73
|
+
type: "update"
|
|
74
|
+
}, {
|
|
75
|
+
sheetId: ctx.currentSheetId,
|
|
76
|
+
path: ["celldata"],
|
|
77
|
+
value: {
|
|
78
|
+
r: r,
|
|
79
|
+
c: c,
|
|
80
|
+
v: cell
|
|
81
|
+
},
|
|
82
|
+
key: "".concat(r, "_").concat(c),
|
|
83
|
+
type: "update"
|
|
84
|
+
}]);
|
|
85
|
+
}
|
|
64
86
|
}
|
|
65
|
-
var offsets = (
|
|
87
|
+
var offsets = (_b = ctx.linkCard) === null || _b === void 0 ? void 0 : _b.selectionOffsets;
|
|
66
88
|
if (offsets) {
|
|
67
89
|
setSelectionByCharacterOffset(options.cellInput, offsets.start, offsets.end);
|
|
68
90
|
}
|
|
@@ -91,8 +113,8 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, option
|
|
|
91
113
|
};
|
|
92
114
|
flowdata[r][c] = cell;
|
|
93
115
|
ctx.linkCard = undefined;
|
|
94
|
-
if ((
|
|
95
|
-
(
|
|
116
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
117
|
+
(_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc([{
|
|
96
118
|
sheetId: ctx.currentSheetId,
|
|
97
119
|
path: ["celldata"],
|
|
98
120
|
value: {
|
|
@@ -107,11 +129,12 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, option
|
|
|
107
129
|
}
|
|
108
130
|
}
|
|
109
131
|
export function removeHyperlink(ctx, r, c) {
|
|
110
|
-
var _a, _b, _c;
|
|
132
|
+
var _a, _b, _c, _d;
|
|
111
133
|
var allowEdit = isAllowEdit(ctx);
|
|
112
134
|
if (!allowEdit) return;
|
|
113
135
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
114
136
|
var flowdata = getFlowdata(ctx);
|
|
137
|
+
var updatedCell = null;
|
|
115
138
|
if (flowdata != null && sheetIndex != null) {
|
|
116
139
|
var hyperlink = _.omit(ctx.luckysheetfile[sheetIndex].hyperlink, "".concat(r, "_").concat(c));
|
|
117
140
|
_.set(ctx.luckysheetfile[sheetIndex], "hyperlink", hyperlink);
|
|
@@ -120,9 +143,33 @@ export function removeHyperlink(ctx, r, c) {
|
|
|
120
143
|
(_a = flowdata[r][c]) === null || _a === void 0 ? true : delete _a.hl;
|
|
121
144
|
(_b = flowdata[r][c]) === null || _b === void 0 ? true : delete _b.un;
|
|
122
145
|
(_c = flowdata[r][c]) === null || _c === void 0 ? true : delete _c.fc;
|
|
146
|
+
updatedCell = flowdata[r][c];
|
|
123
147
|
}
|
|
124
148
|
}
|
|
125
149
|
ctx.linkCard = undefined;
|
|
150
|
+
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc) {
|
|
151
|
+
var changes = [{
|
|
152
|
+
sheetId: ctx.currentSheetId,
|
|
153
|
+
path: ["hyperlink"],
|
|
154
|
+
key: "".concat(r, "_").concat(c),
|
|
155
|
+
value: null,
|
|
156
|
+
type: "delete"
|
|
157
|
+
}];
|
|
158
|
+
if (updatedCell != null) {
|
|
159
|
+
changes.push({
|
|
160
|
+
sheetId: ctx.currentSheetId,
|
|
161
|
+
path: ["celldata"],
|
|
162
|
+
value: {
|
|
163
|
+
r: r,
|
|
164
|
+
c: c,
|
|
165
|
+
v: updatedCell
|
|
166
|
+
},
|
|
167
|
+
key: "".concat(r, "_").concat(c),
|
|
168
|
+
type: "update"
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
172
|
+
}
|
|
126
173
|
}
|
|
127
174
|
export function showLinkCard(ctx, r, c, options, isEditing, isMouseDown) {
|
|
128
175
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
package/es/modules/merge.js
CHANGED
|
@@ -2,7 +2,7 @@ import _ from "lodash";
|
|
|
2
2
|
import { getSheetIndex } from "../utils";
|
|
3
3
|
import { isInlineStringCT } from "./inline-string";
|
|
4
4
|
export function mergeCells(ctx, sheetId, ranges, type) {
|
|
5
|
-
var _a, _b, _c;
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
6
|
var idx = getSheetIndex(ctx, sheetId);
|
|
7
7
|
if (idx == null) return;
|
|
8
8
|
var sheet = ctx.luckysheetfile[idx];
|
|
@@ -11,6 +11,7 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
11
11
|
cfg.merge = {};
|
|
12
12
|
}
|
|
13
13
|
var d = sheet.data;
|
|
14
|
+
var cellChanges = [];
|
|
14
15
|
if (type === "merge-cancel") {
|
|
15
16
|
for (var i = 0; i < ranges.length; i += 1) {
|
|
16
17
|
var range = ranges[i];
|
|
@@ -40,6 +41,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
40
41
|
delete cell_clone.f;
|
|
41
42
|
delete cell_clone.spl;
|
|
42
43
|
d[r][c] = cell_clone;
|
|
44
|
+
cellChanges.push({
|
|
45
|
+
sheetId: sheetId,
|
|
46
|
+
path: ["celldata"],
|
|
47
|
+
value: {
|
|
48
|
+
r: r,
|
|
49
|
+
c: c,
|
|
50
|
+
v: d[r][c]
|
|
51
|
+
},
|
|
52
|
+
key: "".concat(r, "_").concat(c),
|
|
53
|
+
type: "update"
|
|
54
|
+
});
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
}
|
|
@@ -92,6 +104,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
92
104
|
delete cell_clone.f;
|
|
93
105
|
delete cell_clone.spl;
|
|
94
106
|
d[r][c] = cell_clone;
|
|
107
|
+
cellChanges.push({
|
|
108
|
+
sheetId: sheetId,
|
|
109
|
+
path: ["celldata"],
|
|
110
|
+
value: {
|
|
111
|
+
r: r,
|
|
112
|
+
c: c,
|
|
113
|
+
v: d[r][c]
|
|
114
|
+
},
|
|
115
|
+
key: "".concat(r, "_").concat(c),
|
|
116
|
+
type: "update"
|
|
117
|
+
});
|
|
95
118
|
}
|
|
96
119
|
}
|
|
97
120
|
}
|
|
@@ -123,6 +146,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
123
146
|
c: c1
|
|
124
147
|
}
|
|
125
148
|
};
|
|
149
|
+
cellChanges.push({
|
|
150
|
+
sheetId: sheetId,
|
|
151
|
+
path: ["celldata"],
|
|
152
|
+
value: {
|
|
153
|
+
r: r,
|
|
154
|
+
c: c,
|
|
155
|
+
v: d[r][c]
|
|
156
|
+
},
|
|
157
|
+
key: "".concat(r, "_").concat(c),
|
|
158
|
+
type: "update"
|
|
159
|
+
});
|
|
126
160
|
}
|
|
127
161
|
}
|
|
128
162
|
d[r1][c1] = fv;
|
|
@@ -134,6 +168,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
134
168
|
rs: r2 - r1 + 1,
|
|
135
169
|
cs: c2 - c1 + 1
|
|
136
170
|
};
|
|
171
|
+
cellChanges.push({
|
|
172
|
+
sheetId: sheetId,
|
|
173
|
+
path: ["celldata"],
|
|
174
|
+
value: {
|
|
175
|
+
r: r1,
|
|
176
|
+
c: c1,
|
|
177
|
+
v: d[r1][c1]
|
|
178
|
+
},
|
|
179
|
+
key: "".concat(r1, "_").concat(c1),
|
|
180
|
+
type: "update"
|
|
181
|
+
});
|
|
137
182
|
cfg.merge["".concat(r1, "_").concat(c1)] = {
|
|
138
183
|
r: r1,
|
|
139
184
|
c: c1,
|
|
@@ -156,6 +201,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
156
201
|
c: c
|
|
157
202
|
}
|
|
158
203
|
};
|
|
204
|
+
cellChanges.push({
|
|
205
|
+
sheetId: sheetId,
|
|
206
|
+
path: ["celldata"],
|
|
207
|
+
value: {
|
|
208
|
+
r: r,
|
|
209
|
+
c: c,
|
|
210
|
+
v: d[r][c]
|
|
211
|
+
},
|
|
212
|
+
key: "".concat(r, "_").concat(c),
|
|
213
|
+
type: "update"
|
|
214
|
+
});
|
|
159
215
|
}
|
|
160
216
|
d[r1][c] = fv;
|
|
161
217
|
var a = d[r1][c];
|
|
@@ -166,6 +222,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
166
222
|
rs: r2 - r1 + 1,
|
|
167
223
|
cs: 1
|
|
168
224
|
};
|
|
225
|
+
cellChanges.push({
|
|
226
|
+
sheetId: sheetId,
|
|
227
|
+
path: ["celldata"],
|
|
228
|
+
value: {
|
|
229
|
+
r: r1,
|
|
230
|
+
c: c,
|
|
231
|
+
v: d[r1][c]
|
|
232
|
+
},
|
|
233
|
+
key: "".concat(r1, "_").concat(c),
|
|
234
|
+
type: "update"
|
|
235
|
+
});
|
|
169
236
|
cfg.merge["".concat(r1, "_").concat(c)] = {
|
|
170
237
|
r: r1,
|
|
171
238
|
c: c,
|
|
@@ -189,6 +256,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
189
256
|
c: c1
|
|
190
257
|
}
|
|
191
258
|
};
|
|
259
|
+
cellChanges.push({
|
|
260
|
+
sheetId: sheetId,
|
|
261
|
+
path: ["celldata"],
|
|
262
|
+
value: {
|
|
263
|
+
r: r,
|
|
264
|
+
c: c,
|
|
265
|
+
v: d[r][c]
|
|
266
|
+
},
|
|
267
|
+
key: "".concat(r, "_").concat(c),
|
|
268
|
+
type: "update"
|
|
269
|
+
});
|
|
192
270
|
}
|
|
193
271
|
d[r][c1] = fv;
|
|
194
272
|
var a = d[r][c1];
|
|
@@ -199,6 +277,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
199
277
|
rs: 1,
|
|
200
278
|
cs: c2 - c1 + 1
|
|
201
279
|
};
|
|
280
|
+
cellChanges.push({
|
|
281
|
+
sheetId: sheetId,
|
|
282
|
+
path: ["celldata"],
|
|
283
|
+
value: {
|
|
284
|
+
r: r,
|
|
285
|
+
c: c1,
|
|
286
|
+
v: d[r][c1]
|
|
287
|
+
},
|
|
288
|
+
key: "".concat(r, "_").concat(c1),
|
|
289
|
+
type: "update"
|
|
290
|
+
});
|
|
202
291
|
cfg.merge["".concat(r, "_").concat(c1)] = {
|
|
203
292
|
r: r,
|
|
204
293
|
c: c1,
|
|
@@ -209,6 +298,9 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
209
298
|
}
|
|
210
299
|
}
|
|
211
300
|
}
|
|
301
|
+
if (cellChanges.length > 0 && ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc)) {
|
|
302
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
303
|
+
}
|
|
212
304
|
sheet.config = cfg;
|
|
213
305
|
if (sheet.id === ctx.currentSheetId) {
|
|
214
306
|
ctx.config = cfg;
|
package/es/modules/moveCells.js
CHANGED
|
@@ -122,7 +122,7 @@ export function onCellsMove(ctx, globalCache, e, scrollbarX, scrollbarY, contain
|
|
|
122
122
|
ele.style.display = "block";
|
|
123
123
|
}
|
|
124
124
|
export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
|
|
125
|
-
var _a, _b, _c, _d;
|
|
125
|
+
var _a, _b, _c, _d, _e;
|
|
126
126
|
if (!ctx.luckysheet_cell_selected_move) return;
|
|
127
127
|
ctx.luckysheet_cell_selected_move = false;
|
|
128
128
|
var ele = document.getElementById("fortune-cell-selected-move");
|
|
@@ -131,17 +131,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
131
131
|
globalCache.dragCellStartPos = undefined;
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
var
|
|
135
|
-
x =
|
|
136
|
-
y =
|
|
134
|
+
var _f = mousePosition(e.pageX, e.pageY, ctx),
|
|
135
|
+
x = _f[0],
|
|
136
|
+
y = _f[1];
|
|
137
137
|
var rect = container.getBoundingClientRect();
|
|
138
138
|
var winH = rect.height - 20 * ctx.zoomRatio;
|
|
139
139
|
var winW = rect.width - 60 * ctx.zoomRatio;
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
row_index =
|
|
143
|
-
|
|
144
|
-
col_index =
|
|
140
|
+
var _g = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
|
|
141
|
+
_h = _g.row,
|
|
142
|
+
row_index = _h[2],
|
|
143
|
+
_j = _g.column,
|
|
144
|
+
col_index = _j[2];
|
|
145
145
|
var allowEdit = isAllowEdit(ctx, [{
|
|
146
146
|
row: [row_index, row_index],
|
|
147
147
|
column: [col_index, col_index]
|
|
@@ -191,6 +191,7 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
191
191
|
throw new Error(locale_drag.noMerge);
|
|
192
192
|
}
|
|
193
193
|
var borderInfoCompute = getBorderInfoCompute(ctx, ctx.currentSheetId);
|
|
194
|
+
var cellChanges = [];
|
|
194
195
|
var hyperLinkList = {};
|
|
195
196
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
196
197
|
for (var r = last.row[0]; r <= last.row[1]; r += 1) {
|
|
@@ -203,6 +204,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
d[r][c] = null;
|
|
207
|
+
cellChanges.push({
|
|
208
|
+
sheetId: ctx.currentSheetId,
|
|
209
|
+
path: ["celldata"],
|
|
210
|
+
value: {
|
|
211
|
+
r: r,
|
|
212
|
+
c: c,
|
|
213
|
+
v: null
|
|
214
|
+
},
|
|
215
|
+
key: "".concat(r, "_").concat(c),
|
|
216
|
+
type: "update"
|
|
217
|
+
});
|
|
206
218
|
if ((_a = ctx.luckysheetfile[index].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)]) {
|
|
207
219
|
hyperLinkList["".concat(r, "_").concat(c)] = (_b = ctx.luckysheetfile[index].hyperlink) === null || _b === void 0 ? void 0 : _b["".concat(r, "_").concat(c)];
|
|
208
220
|
(_c = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink) === null || _c === void 0 ? true : delete _c["".concat(r, "_").concat(c)];
|
|
@@ -291,6 +303,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
291
303
|
}
|
|
292
304
|
}
|
|
293
305
|
d[r + row_s][c + col_s] = value;
|
|
306
|
+
cellChanges.push({
|
|
307
|
+
sheetId: ctx.currentSheetId,
|
|
308
|
+
path: ["celldata"],
|
|
309
|
+
value: {
|
|
310
|
+
r: r + row_s,
|
|
311
|
+
c: c + col_s,
|
|
312
|
+
v: d[r + row_s][c + col_s]
|
|
313
|
+
},
|
|
314
|
+
key: "".concat(r + row_s, "_").concat(c + col_s),
|
|
315
|
+
type: "update"
|
|
316
|
+
});
|
|
294
317
|
if (hyperLinkList === null || hyperLinkList === void 0 ? void 0 : hyperLinkList["".concat(r + last.row[0], "_").concat(c + last.column[0])]) {
|
|
295
318
|
ctx.luckysheetfile[index].hyperlink["".concat(r + row_s, "_").concat(c + col_s)] = hyperLinkList === null || hyperLinkList === void 0 ? void 0 : hyperLinkList["".concat(r + last.row[0], "_").concat(c + last.column[0])];
|
|
296
319
|
}
|
|
@@ -344,5 +367,8 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
344
367
|
if (sheetIndex != null) {
|
|
345
368
|
ctx.luckysheetfile[sheetIndex].config = _.assign({}, cfg);
|
|
346
369
|
}
|
|
370
|
+
if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
|
|
371
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
372
|
+
}
|
|
347
373
|
jfrefreshgrid(ctx, d, range);
|
|
348
374
|
}
|
package/es/modules/rowcol.js
CHANGED
|
@@ -54,8 +54,63 @@ var refreshLocalMergeData = function refreshLocalMergeData(merge_new, file) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
+
var getMergeBounds = function getMergeBounds(mergeMap) {
|
|
58
|
+
if (!mergeMap) return null;
|
|
59
|
+
var minR = Infinity;
|
|
60
|
+
var minC = Infinity;
|
|
61
|
+
var maxR = -Infinity;
|
|
62
|
+
var maxC = -Infinity;
|
|
63
|
+
Object.values(mergeMap).forEach(function (mc) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if (!mc) return;
|
|
66
|
+
var r = Number(mc.r);
|
|
67
|
+
var c = Number(mc.c);
|
|
68
|
+
var rs = Number((_a = mc.rs) !== null && _a !== void 0 ? _a : 1);
|
|
69
|
+
var cs = Number((_b = mc.cs) !== null && _b !== void 0 ? _b : 1);
|
|
70
|
+
if (!Number.isFinite(r) || !Number.isFinite(c)) return;
|
|
71
|
+
minR = Math.min(minR, r);
|
|
72
|
+
minC = Math.min(minC, c);
|
|
73
|
+
maxR = Math.max(maxR, r + Math.max(1, rs) - 1);
|
|
74
|
+
maxC = Math.max(maxC, c + Math.max(1, cs) - 1);
|
|
75
|
+
});
|
|
76
|
+
if (minR === Infinity) return null;
|
|
77
|
+
return {
|
|
78
|
+
minR: minR,
|
|
79
|
+
minC: minC,
|
|
80
|
+
maxR: maxR,
|
|
81
|
+
maxC: maxC
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2, c1, c2) {
|
|
85
|
+
var _a, _b, _c, _d;
|
|
86
|
+
if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) return;
|
|
87
|
+
if (!d || !Array.isArray(d) || d.length === 0) return;
|
|
88
|
+
var rowEnd = Math.min(r2, d.length - 1);
|
|
89
|
+
var colEnd = Math.min(c2, ((_c = (_b = d[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) - 1);
|
|
90
|
+
var rowStart = Math.max(0, r1);
|
|
91
|
+
var colStart = Math.max(0, c1);
|
|
92
|
+
if (rowStart > rowEnd || colStart > colEnd) return;
|
|
93
|
+
var changes = [];
|
|
94
|
+
for (var r = rowStart; r <= rowEnd; r += 1) {
|
|
95
|
+
var row = d[r] || [];
|
|
96
|
+
for (var c = colStart; c <= colEnd; c += 1) {
|
|
97
|
+
changes.push({
|
|
98
|
+
sheetId: sheetId,
|
|
99
|
+
path: ["celldata"],
|
|
100
|
+
value: {
|
|
101
|
+
r: r,
|
|
102
|
+
c: c,
|
|
103
|
+
v: (_d = row === null || row === void 0 ? void 0 : row[c]) !== null && _d !== void 0 ? _d : null
|
|
104
|
+
},
|
|
105
|
+
key: "".concat(r, "_").concat(c),
|
|
106
|
+
type: "update"
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
111
|
+
};
|
|
57
112
|
export function insertRowCol(ctx, op, changeSelection) {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
113
|
+
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;
|
|
59
114
|
if (changeSelection === void 0) {
|
|
60
115
|
changeSelection = true;
|
|
61
116
|
}
|
|
@@ -1020,9 +1075,19 @@ export function insertRowCol(ctx, op, changeSelection) {
|
|
|
1020
1075
|
}
|
|
1021
1076
|
}
|
|
1022
1077
|
refreshLocalMergeData(merge_new, file);
|
|
1078
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1079
|
+
if (type === "row") {
|
|
1080
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1081
|
+
var startR = mergeBounds ? Math.min(baseStart, mergeBounds.minR) : baseStart;
|
|
1082
|
+
emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_y = (_x = d[0]) === null || _x === void 0 ? void 0 : _x.length) !== null && _y !== void 0 ? _y : 1) - 1);
|
|
1083
|
+
} else {
|
|
1084
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1085
|
+
var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
|
|
1086
|
+
emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_0 = (_z = d[0]) === null || _z === void 0 ? void 0 : _z.length) !== null && _0 !== void 0 ? _0 : 1) - 1);
|
|
1087
|
+
}
|
|
1023
1088
|
}
|
|
1024
1089
|
export function deleteRowCol(ctx, op) {
|
|
1025
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1090
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1026
1091
|
var type = op.type;
|
|
1027
1092
|
var start = op.start,
|
|
1028
1093
|
end = op.end,
|
|
@@ -1742,6 +1807,14 @@ export function deleteRowCol(ctx, op) {
|
|
|
1742
1807
|
file.dataVerification = newDataVerification;
|
|
1743
1808
|
file.hyperlink = newHyperlink;
|
|
1744
1809
|
refreshLocalMergeData(merge_new, file);
|
|
1810
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1811
|
+
if (type === "row") {
|
|
1812
|
+
var startR = mergeBounds ? Math.min(start, mergeBounds.minR) : start;
|
|
1813
|
+
emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_s = (_r = d[0]) === null || _r === void 0 ? void 0 : _r.length) !== null && _s !== void 0 ? _s : 1) - 1);
|
|
1814
|
+
} else {
|
|
1815
|
+
var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
|
|
1816
|
+
emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_u = (_t = d[0]) === null || _t === void 0 ? void 0 : _t.length) !== null && _u !== void 0 ? _u : 1) - 1);
|
|
1817
|
+
}
|
|
1745
1818
|
if (file.id === ctx.currentSheetId) {
|
|
1746
1819
|
ctx.config = cfg;
|
|
1747
1820
|
} else {}
|