@fileverse-dev/fortune-core 1.3.10-test → 1.3.10-yjs

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.
@@ -1779,7 +1779,8 @@ 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
+ console.log("updateDropCell");
1783
1784
  var d = getFlowdata(ctx);
1784
1785
  var allowEdit = isAllowEdit(ctx);
1785
1786
  var isReadOnly = isAllowEditReadOnly(ctx);
@@ -1815,6 +1816,7 @@ export function updateDropCell(ctx) {
1815
1816
  var apply_end_r = applyRange.row[1];
1816
1817
  var apply_str_c = applyRange.column[0];
1817
1818
  var apply_end_c = applyRange.column[1];
1819
+ var cellChanges = [];
1818
1820
  if (direction === "down" || direction === "up") {
1819
1821
  var asLen = apply_end_r - apply_str_r + 1;
1820
1822
  for (var i = apply_str_c; i <= apply_end_c; i += 1) {
@@ -1873,6 +1875,17 @@ export function updateDropCell(ctx) {
1873
1875
  }
1874
1876
  }
1875
1877
  d[j][i] = cell || null;
1878
+ cellChanges.push({
1879
+ sheetId: ctx.currentSheetId,
1880
+ path: ["celldata"],
1881
+ value: {
1882
+ r: j,
1883
+ c: i,
1884
+ v: d[j][i]
1885
+ },
1886
+ key: "".concat(j, "_").concat(i),
1887
+ type: "update"
1888
+ });
1876
1889
  var bd_r = copy_str_r + (j - apply_str_r) % csLen;
1877
1890
  var bd_c = i;
1878
1891
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1953,6 +1966,17 @@ export function updateDropCell(ctx) {
1953
1966
  }
1954
1967
  }
1955
1968
  d[j][i] = cell || null;
1969
+ cellChanges.push({
1970
+ sheetId: ctx.currentSheetId,
1971
+ path: ["celldata"],
1972
+ value: {
1973
+ r: j,
1974
+ c: i,
1975
+ v: d[j][i]
1976
+ },
1977
+ key: "".concat(j, "_").concat(i),
1978
+ type: "update"
1979
+ });
1956
1980
  var bd_r = copy_end_r - (apply_end_r - j) % csLen;
1957
1981
  var bd_c = i;
1958
1982
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2040,6 +2064,17 @@ export function updateDropCell(ctx) {
2040
2064
  }
2041
2065
  }
2042
2066
  d[i][j] = cell || null;
2067
+ cellChanges.push({
2068
+ sheetId: ctx.currentSheetId,
2069
+ path: ["celldata"],
2070
+ value: {
2071
+ r: i,
2072
+ c: j,
2073
+ v: d[i][j]
2074
+ },
2075
+ key: "".concat(i, "_").concat(j),
2076
+ type: "update"
2077
+ });
2043
2078
  var bd_r = i;
2044
2079
  var bd_c = copy_str_c + (j - apply_str_c) % csLen;
2045
2080
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2120,6 +2155,17 @@ export function updateDropCell(ctx) {
2120
2155
  }
2121
2156
  }
2122
2157
  d[i][j] = cell || null;
2158
+ cellChanges.push({
2159
+ sheetId: ctx.currentSheetId,
2160
+ path: ["celldata"],
2161
+ value: {
2162
+ r: i,
2163
+ c: j,
2164
+ v: d[i][j]
2165
+ },
2166
+ key: "".concat(i, "_").concat(j),
2167
+ type: "update"
2168
+ });
2123
2169
  var bd_r = i;
2124
2170
  var bd_c = copy_end_c - (apply_end_c - j) % csLen;
2125
2171
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2156,6 +2202,9 @@ export function updateDropCell(ctx) {
2156
2202
  }
2157
2203
  }
2158
2204
  }
2205
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
2206
+ ctx.hooks.updateCellYdoc(cellChanges);
2207
+ }
2159
2208
  var cdformat = file.luckysheet_conditionformat_save;
2160
2209
  if (cdformat != null && cdformat.length > 0) {
2161
2210
  for (var i = 0; i < cdformat.length; i += 1) {
@@ -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;
@@ -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 _e = mousePosition(e.pageX, e.pageY, ctx),
135
- x = _e[0],
136
- y = _e[1];
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 _f = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
141
- _g = _f.row,
142
- row_index = _g[2],
143
- _h = _f.column,
144
- col_index = _h[2];
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
  }
@@ -1629,7 +1629,7 @@ export function deleteSelectedCellFormat(ctx) {
1629
1629
  }
1630
1630
  export function fillRightData(ctx) {
1631
1631
  var _a, _b, _c, _d;
1632
- var _e, _f, _g;
1632
+ var _e, _f, _g, _h;
1633
1633
  var allowEdit = isAllowEdit(ctx);
1634
1634
  if (allowEdit === false) {
1635
1635
  return "allowEdit";
@@ -1652,6 +1652,7 @@ export function fillRightData(ctx) {
1652
1652
  if (has_PartMC) {
1653
1653
  return "partMC";
1654
1654
  }
1655
+ var cellChanges = [];
1655
1656
  for (var s = 0; s < selection.length; s += 1) {
1656
1657
  var r1 = selection[s].row[0];
1657
1658
  var r2 = selection[s].row[1];
@@ -1669,6 +1670,17 @@ export function fillRightData(ctx) {
1669
1670
  var srcCol = c1 - 1;
1670
1671
  var prev = d[r1][c1 - 1];
1671
1672
  d[r1][c1] = prev != null ? __assign({}, prev) : {};
1673
+ cellChanges.push({
1674
+ sheetId: ctx.currentSheetId,
1675
+ path: ["celldata"],
1676
+ value: {
1677
+ r: r1,
1678
+ c: c1,
1679
+ v: d[r1][c1]
1680
+ },
1681
+ key: "".concat(r1, "_").concat(c1),
1682
+ type: "update"
1683
+ });
1672
1684
  if (file != null) {
1673
1685
  var srcKey = "".concat(srcRow, "_").concat(srcCol);
1674
1686
  var tgtKey = "".concat(r1, "_").concat(c1);
@@ -1718,6 +1730,17 @@ export function fillRightData(ctx) {
1718
1730
  for (var c = c1 + 1; c <= c2; c += 1) {
1719
1731
  if (d[r]) {
1720
1732
  d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1733
+ cellChanges.push({
1734
+ sheetId: ctx.currentSheetId,
1735
+ path: ["celldata"],
1736
+ value: {
1737
+ r: r,
1738
+ c: c,
1739
+ v: d[r][c]
1740
+ },
1741
+ key: "".concat(r, "_").concat(c),
1742
+ type: "update"
1743
+ });
1721
1744
  }
1722
1745
  if (file != null) {
1723
1746
  var srcKey = "".concat(r, "_").concat(c1);
@@ -1765,12 +1788,15 @@ export function fillRightData(ctx) {
1765
1788
  }
1766
1789
  }
1767
1790
  }
1791
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
1792
+ ctx.hooks.updateCellYdoc(cellChanges);
1793
+ }
1768
1794
  }
1769
1795
  return "success";
1770
1796
  }
1771
1797
  export function fillDownData(ctx) {
1772
1798
  var _a, _b, _c, _d;
1773
- var _e, _f, _g;
1799
+ var _e, _f, _g, _h;
1774
1800
  var allowEdit = isAllowEdit(ctx);
1775
1801
  if (allowEdit === false) {
1776
1802
  return "allowEdit";
@@ -1793,6 +1819,7 @@ export function fillDownData(ctx) {
1793
1819
  if (has_PartMC) {
1794
1820
  return "partMC";
1795
1821
  }
1822
+ var cellChanges = [];
1796
1823
  for (var s = 0; s < selection.length; s += 1) {
1797
1824
  var r1 = selection[s].row[0];
1798
1825
  var r2 = selection[s].row[1];
@@ -1811,6 +1838,17 @@ export function fillDownData(ctx) {
1811
1838
  var prev = d[r1 - 1][c1];
1812
1839
  if (!d[r1]) d[r1] = [];
1813
1840
  d[r1][c1] = prev != null ? __assign({}, prev) : {};
1841
+ cellChanges.push({
1842
+ sheetId: ctx.currentSheetId,
1843
+ path: ["celldata"],
1844
+ value: {
1845
+ r: r1,
1846
+ c: c1,
1847
+ v: d[r1][c1]
1848
+ },
1849
+ key: "".concat(r1, "_").concat(c1),
1850
+ type: "update"
1851
+ });
1814
1852
  if (file != null) {
1815
1853
  var srcKey = "".concat(srcRow, "_").concat(srcCol);
1816
1854
  var tgtKey = "".concat(r1, "_").concat(c1);
@@ -1860,6 +1898,17 @@ export function fillDownData(ctx) {
1860
1898
  for (var r = r1 + 1; r <= r2; r += 1) {
1861
1899
  if (!d[r]) d[r] = [];
1862
1900
  d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1901
+ cellChanges.push({
1902
+ sheetId: ctx.currentSheetId,
1903
+ path: ["celldata"],
1904
+ value: {
1905
+ r: r,
1906
+ c: c,
1907
+ v: d[r][c]
1908
+ },
1909
+ key: "".concat(r, "_").concat(c),
1910
+ type: "update"
1911
+ });
1863
1912
  if (file != null) {
1864
1913
  var srcKey = "".concat(r1, "_").concat(c);
1865
1914
  var tgtKey = "".concat(r, "_").concat(c);
@@ -1906,6 +1955,9 @@ export function fillDownData(ctx) {
1906
1955
  }
1907
1956
  }
1908
1957
  }
1958
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
1959
+ ctx.hooks.updateCellYdoc(cellChanges);
1960
+ }
1909
1961
  }
1910
1962
  return "success";
1911
1963
  }
@@ -1795,7 +1795,8 @@ function getApplyData(copyD, csLen, asLen) {
1795
1795
  }
1796
1796
  function updateDropCell(ctx) {
1797
1797
  var _a, _b, _c, _d;
1798
- var _e, _f, _g;
1798
+ var _e, _f, _g, _h;
1799
+ console.log("updateDropCell");
1799
1800
  var d = (0, _context.getFlowdata)(ctx);
1800
1801
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1801
1802
  var isReadOnly = (0, _utils.isAllowEditReadOnly)(ctx);
@@ -1831,6 +1832,7 @@ function updateDropCell(ctx) {
1831
1832
  var apply_end_r = applyRange.row[1];
1832
1833
  var apply_str_c = applyRange.column[0];
1833
1834
  var apply_end_c = applyRange.column[1];
1835
+ var cellChanges = [];
1834
1836
  if (direction === "down" || direction === "up") {
1835
1837
  var asLen = apply_end_r - apply_str_r + 1;
1836
1838
  for (var i = apply_str_c; i <= apply_end_c; i += 1) {
@@ -1889,6 +1891,17 @@ function updateDropCell(ctx) {
1889
1891
  }
1890
1892
  }
1891
1893
  d[j][i] = cell || null;
1894
+ cellChanges.push({
1895
+ sheetId: ctx.currentSheetId,
1896
+ path: ["celldata"],
1897
+ value: {
1898
+ r: j,
1899
+ c: i,
1900
+ v: d[j][i]
1901
+ },
1902
+ key: "".concat(j, "_").concat(i),
1903
+ type: "update"
1904
+ });
1892
1905
  var bd_r = copy_str_r + (j - apply_str_r) % csLen;
1893
1906
  var bd_c = i;
1894
1907
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1969,6 +1982,17 @@ function updateDropCell(ctx) {
1969
1982
  }
1970
1983
  }
1971
1984
  d[j][i] = cell || null;
1985
+ cellChanges.push({
1986
+ sheetId: ctx.currentSheetId,
1987
+ path: ["celldata"],
1988
+ value: {
1989
+ r: j,
1990
+ c: i,
1991
+ v: d[j][i]
1992
+ },
1993
+ key: "".concat(j, "_").concat(i),
1994
+ type: "update"
1995
+ });
1972
1996
  var bd_r = copy_end_r - (apply_end_r - j) % csLen;
1973
1997
  var bd_c = i;
1974
1998
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2056,6 +2080,17 @@ function updateDropCell(ctx) {
2056
2080
  }
2057
2081
  }
2058
2082
  d[i][j] = cell || null;
2083
+ cellChanges.push({
2084
+ sheetId: ctx.currentSheetId,
2085
+ path: ["celldata"],
2086
+ value: {
2087
+ r: i,
2088
+ c: j,
2089
+ v: d[i][j]
2090
+ },
2091
+ key: "".concat(i, "_").concat(j),
2092
+ type: "update"
2093
+ });
2059
2094
  var bd_r = i;
2060
2095
  var bd_c = copy_str_c + (j - apply_str_c) % csLen;
2061
2096
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2136,6 +2171,17 @@ function updateDropCell(ctx) {
2136
2171
  }
2137
2172
  }
2138
2173
  d[i][j] = cell || null;
2174
+ cellChanges.push({
2175
+ sheetId: ctx.currentSheetId,
2176
+ path: ["celldata"],
2177
+ value: {
2178
+ r: i,
2179
+ c: j,
2180
+ v: d[i][j]
2181
+ },
2182
+ key: "".concat(i, "_").concat(j),
2183
+ type: "update"
2184
+ });
2139
2185
  var bd_r = i;
2140
2186
  var bd_c = copy_end_c - (apply_end_c - j) % csLen;
2141
2187
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2172,6 +2218,9 @@ function updateDropCell(ctx) {
2172
2218
  }
2173
2219
  }
2174
2220
  }
2221
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
2222
+ ctx.hooks.updateCellYdoc(cellChanges);
2223
+ }
2175
2224
  var cdformat = file.luckysheet_conditionformat_save;
2176
2225
  if (cdformat != null && cdformat.length > 0) {
2177
2226
  for (var i = 0; i < cdformat.length; i += 1) {
@@ -9,7 +9,7 @@ var _utils = require("../utils");
9
9
  var _inlineString = require("./inline-string");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  function mergeCells(ctx, sheetId, ranges, type) {
12
- var _a, _b, _c;
12
+ var _a, _b, _c, _d;
13
13
  var idx = (0, _utils.getSheetIndex)(ctx, sheetId);
14
14
  if (idx == null) return;
15
15
  var sheet = ctx.luckysheetfile[idx];
@@ -18,6 +18,7 @@ function mergeCells(ctx, sheetId, ranges, type) {
18
18
  cfg.merge = {};
19
19
  }
20
20
  var d = sheet.data;
21
+ var cellChanges = [];
21
22
  if (type === "merge-cancel") {
22
23
  for (var i = 0; i < ranges.length; i += 1) {
23
24
  var range = ranges[i];
@@ -47,6 +48,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
47
48
  delete cell_clone.f;
48
49
  delete cell_clone.spl;
49
50
  d[r][c] = cell_clone;
51
+ cellChanges.push({
52
+ sheetId: sheetId,
53
+ path: ["celldata"],
54
+ value: {
55
+ r: r,
56
+ c: c,
57
+ v: d[r][c]
58
+ },
59
+ key: "".concat(r, "_").concat(c),
60
+ type: "update"
61
+ });
50
62
  }
51
63
  }
52
64
  }
@@ -99,6 +111,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
99
111
  delete cell_clone.f;
100
112
  delete cell_clone.spl;
101
113
  d[r][c] = cell_clone;
114
+ cellChanges.push({
115
+ sheetId: sheetId,
116
+ path: ["celldata"],
117
+ value: {
118
+ r: r,
119
+ c: c,
120
+ v: d[r][c]
121
+ },
122
+ key: "".concat(r, "_").concat(c),
123
+ type: "update"
124
+ });
102
125
  }
103
126
  }
104
127
  }
@@ -130,6 +153,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
130
153
  c: c1
131
154
  }
132
155
  };
156
+ cellChanges.push({
157
+ sheetId: sheetId,
158
+ path: ["celldata"],
159
+ value: {
160
+ r: r,
161
+ c: c,
162
+ v: d[r][c]
163
+ },
164
+ key: "".concat(r, "_").concat(c),
165
+ type: "update"
166
+ });
133
167
  }
134
168
  }
135
169
  d[r1][c1] = fv;
@@ -141,6 +175,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
141
175
  rs: r2 - r1 + 1,
142
176
  cs: c2 - c1 + 1
143
177
  };
178
+ cellChanges.push({
179
+ sheetId: sheetId,
180
+ path: ["celldata"],
181
+ value: {
182
+ r: r1,
183
+ c: c1,
184
+ v: d[r1][c1]
185
+ },
186
+ key: "".concat(r1, "_").concat(c1),
187
+ type: "update"
188
+ });
144
189
  cfg.merge["".concat(r1, "_").concat(c1)] = {
145
190
  r: r1,
146
191
  c: c1,
@@ -163,6 +208,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
163
208
  c: c
164
209
  }
165
210
  };
211
+ cellChanges.push({
212
+ sheetId: sheetId,
213
+ path: ["celldata"],
214
+ value: {
215
+ r: r,
216
+ c: c,
217
+ v: d[r][c]
218
+ },
219
+ key: "".concat(r, "_").concat(c),
220
+ type: "update"
221
+ });
166
222
  }
167
223
  d[r1][c] = fv;
168
224
  var a = d[r1][c];
@@ -173,6 +229,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
173
229
  rs: r2 - r1 + 1,
174
230
  cs: 1
175
231
  };
232
+ cellChanges.push({
233
+ sheetId: sheetId,
234
+ path: ["celldata"],
235
+ value: {
236
+ r: r1,
237
+ c: c,
238
+ v: d[r1][c]
239
+ },
240
+ key: "".concat(r1, "_").concat(c),
241
+ type: "update"
242
+ });
176
243
  cfg.merge["".concat(r1, "_").concat(c)] = {
177
244
  r: r1,
178
245
  c: c,
@@ -196,6 +263,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
196
263
  c: c1
197
264
  }
198
265
  };
266
+ cellChanges.push({
267
+ sheetId: sheetId,
268
+ path: ["celldata"],
269
+ value: {
270
+ r: r,
271
+ c: c,
272
+ v: d[r][c]
273
+ },
274
+ key: "".concat(r, "_").concat(c),
275
+ type: "update"
276
+ });
199
277
  }
200
278
  d[r][c1] = fv;
201
279
  var a = d[r][c1];
@@ -206,6 +284,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
206
284
  rs: 1,
207
285
  cs: c2 - c1 + 1
208
286
  };
287
+ cellChanges.push({
288
+ sheetId: sheetId,
289
+ path: ["celldata"],
290
+ value: {
291
+ r: r,
292
+ c: c1,
293
+ v: d[r][c1]
294
+ },
295
+ key: "".concat(r, "_").concat(c1),
296
+ type: "update"
297
+ });
209
298
  cfg.merge["".concat(r, "_").concat(c1)] = {
210
299
  r: r,
211
300
  c: c1,
@@ -216,6 +305,9 @@ function mergeCells(ctx, sheetId, ranges, type) {
216
305
  }
217
306
  }
218
307
  }
308
+ if (cellChanges.length > 0 && ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc)) {
309
+ ctx.hooks.updateCellYdoc(cellChanges);
310
+ }
219
311
  sheet.config = cfg;
220
312
  if (sheet.id === ctx.currentSheetId) {
221
313
  ctx.config = cfg;
@@ -131,7 +131,7 @@ function onCellsMove(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
131
131
  ele.style.display = "block";
132
132
  }
133
133
  function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
134
- var _a, _b, _c, _d;
134
+ var _a, _b, _c, _d, _e;
135
135
  if (!ctx.luckysheet_cell_selected_move) return;
136
136
  ctx.luckysheet_cell_selected_move = false;
137
137
  var ele = document.getElementById("fortune-cell-selected-move");
@@ -140,17 +140,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
140
140
  globalCache.dragCellStartPos = undefined;
141
141
  return;
142
142
  }
143
- var _e = (0, _location.mousePosition)(e.pageX, e.pageY, ctx),
144
- x = _e[0],
145
- y = _e[1];
143
+ var _f = (0, _location.mousePosition)(e.pageX, e.pageY, ctx),
144
+ x = _f[0],
145
+ y = _f[1];
146
146
  var rect = container.getBoundingClientRect();
147
147
  var winH = rect.height - 20 * ctx.zoomRatio;
148
148
  var winW = rect.width - 60 * ctx.zoomRatio;
149
- var _f = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
150
- _g = _f.row,
151
- row_index = _g[2],
152
- _h = _f.column,
153
- col_index = _h[2];
149
+ var _g = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
150
+ _h = _g.row,
151
+ row_index = _h[2],
152
+ _j = _g.column,
153
+ col_index = _j[2];
154
154
  var allowEdit = (0, _utils.isAllowEdit)(ctx, [{
155
155
  row: [row_index, row_index],
156
156
  column: [col_index, col_index]
@@ -200,6 +200,7 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
200
200
  throw new Error(locale_drag.noMerge);
201
201
  }
202
202
  var borderInfoCompute = (0, _border.getBorderInfoCompute)(ctx, ctx.currentSheetId);
203
+ var cellChanges = [];
203
204
  var hyperLinkList = {};
204
205
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
205
206
  for (var r = last.row[0]; r <= last.row[1]; r += 1) {
@@ -212,6 +213,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
212
213
  }
213
214
  }
214
215
  d[r][c] = null;
216
+ cellChanges.push({
217
+ sheetId: ctx.currentSheetId,
218
+ path: ["celldata"],
219
+ value: {
220
+ r: r,
221
+ c: c,
222
+ v: null
223
+ },
224
+ key: "".concat(r, "_").concat(c),
225
+ type: "update"
226
+ });
215
227
  if ((_a = ctx.luckysheetfile[index].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)]) {
216
228
  hyperLinkList["".concat(r, "_").concat(c)] = (_b = ctx.luckysheetfile[index].hyperlink) === null || _b === void 0 ? void 0 : _b["".concat(r, "_").concat(c)];
217
229
  (_c = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].hyperlink) === null || _c === void 0 ? true : delete _c["".concat(r, "_").concat(c)];
@@ -300,6 +312,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
300
312
  }
301
313
  }
302
314
  d[r + row_s][c + col_s] = value;
315
+ cellChanges.push({
316
+ sheetId: ctx.currentSheetId,
317
+ path: ["celldata"],
318
+ value: {
319
+ r: r + row_s,
320
+ c: c + col_s,
321
+ v: d[r + row_s][c + col_s]
322
+ },
323
+ key: "".concat(r + row_s, "_").concat(c + col_s),
324
+ type: "update"
325
+ });
303
326
  if (hyperLinkList === null || hyperLinkList === void 0 ? void 0 : hyperLinkList["".concat(r + last.row[0], "_").concat(c + last.column[0])]) {
304
327
  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])];
305
328
  }
@@ -353,5 +376,8 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
353
376
  if (sheetIndex != null) {
354
377
  ctx.luckysheetfile[sheetIndex].config = _lodash.default.assign({}, cfg);
355
378
  }
379
+ if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
380
+ ctx.hooks.updateCellYdoc(cellChanges);
381
+ }
356
382
  (0, _refresh.jfrefreshgrid)(ctx, d, range);
357
383
  }
@@ -1664,7 +1664,7 @@ function deleteSelectedCellFormat(ctx) {
1664
1664
  }
1665
1665
  function fillRightData(ctx) {
1666
1666
  var _a, _b, _c, _d;
1667
- var _e, _f, _g;
1667
+ var _e, _f, _g, _h;
1668
1668
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1669
1669
  if (allowEdit === false) {
1670
1670
  return "allowEdit";
@@ -1687,6 +1687,7 @@ function fillRightData(ctx) {
1687
1687
  if (has_PartMC) {
1688
1688
  return "partMC";
1689
1689
  }
1690
+ var cellChanges = [];
1690
1691
  for (var s = 0; s < selection.length; s += 1) {
1691
1692
  var r1 = selection[s].row[0];
1692
1693
  var r2 = selection[s].row[1];
@@ -1704,6 +1705,17 @@ function fillRightData(ctx) {
1704
1705
  var srcCol = c1 - 1;
1705
1706
  var prev = d[r1][c1 - 1];
1706
1707
  d[r1][c1] = prev != null ? __assign({}, prev) : {};
1708
+ cellChanges.push({
1709
+ sheetId: ctx.currentSheetId,
1710
+ path: ["celldata"],
1711
+ value: {
1712
+ r: r1,
1713
+ c: c1,
1714
+ v: d[r1][c1]
1715
+ },
1716
+ key: "".concat(r1, "_").concat(c1),
1717
+ type: "update"
1718
+ });
1707
1719
  if (file != null) {
1708
1720
  var srcKey = "".concat(srcRow, "_").concat(srcCol);
1709
1721
  var tgtKey = "".concat(r1, "_").concat(c1);
@@ -1753,6 +1765,17 @@ function fillRightData(ctx) {
1753
1765
  for (var c = c1 + 1; c <= c2; c += 1) {
1754
1766
  if (d[r]) {
1755
1767
  d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1768
+ cellChanges.push({
1769
+ sheetId: ctx.currentSheetId,
1770
+ path: ["celldata"],
1771
+ value: {
1772
+ r: r,
1773
+ c: c,
1774
+ v: d[r][c]
1775
+ },
1776
+ key: "".concat(r, "_").concat(c),
1777
+ type: "update"
1778
+ });
1756
1779
  }
1757
1780
  if (file != null) {
1758
1781
  var srcKey = "".concat(r, "_").concat(c1);
@@ -1800,12 +1823,15 @@ function fillRightData(ctx) {
1800
1823
  }
1801
1824
  }
1802
1825
  }
1826
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
1827
+ ctx.hooks.updateCellYdoc(cellChanges);
1828
+ }
1803
1829
  }
1804
1830
  return "success";
1805
1831
  }
1806
1832
  function fillDownData(ctx) {
1807
1833
  var _a, _b, _c, _d;
1808
- var _e, _f, _g;
1834
+ var _e, _f, _g, _h;
1809
1835
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1810
1836
  if (allowEdit === false) {
1811
1837
  return "allowEdit";
@@ -1828,6 +1854,7 @@ function fillDownData(ctx) {
1828
1854
  if (has_PartMC) {
1829
1855
  return "partMC";
1830
1856
  }
1857
+ var cellChanges = [];
1831
1858
  for (var s = 0; s < selection.length; s += 1) {
1832
1859
  var r1 = selection[s].row[0];
1833
1860
  var r2 = selection[s].row[1];
@@ -1846,6 +1873,17 @@ function fillDownData(ctx) {
1846
1873
  var prev = d[r1 - 1][c1];
1847
1874
  if (!d[r1]) d[r1] = [];
1848
1875
  d[r1][c1] = prev != null ? __assign({}, prev) : {};
1876
+ cellChanges.push({
1877
+ sheetId: ctx.currentSheetId,
1878
+ path: ["celldata"],
1879
+ value: {
1880
+ r: r1,
1881
+ c: c1,
1882
+ v: d[r1][c1]
1883
+ },
1884
+ key: "".concat(r1, "_").concat(c1),
1885
+ type: "update"
1886
+ });
1849
1887
  if (file != null) {
1850
1888
  var srcKey = "".concat(srcRow, "_").concat(srcCol);
1851
1889
  var tgtKey = "".concat(r1, "_").concat(c1);
@@ -1895,6 +1933,17 @@ function fillDownData(ctx) {
1895
1933
  for (var r = r1 + 1; r <= r2; r += 1) {
1896
1934
  if (!d[r]) d[r] = [];
1897
1935
  d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1936
+ cellChanges.push({
1937
+ sheetId: ctx.currentSheetId,
1938
+ path: ["celldata"],
1939
+ value: {
1940
+ r: r,
1941
+ c: c,
1942
+ v: d[r][c]
1943
+ },
1944
+ key: "".concat(r, "_").concat(c),
1945
+ type: "update"
1946
+ });
1898
1947
  if (file != null) {
1899
1948
  var srcKey = "".concat(r1, "_").concat(c);
1900
1949
  var tgtKey = "".concat(r, "_").concat(c);
@@ -1941,6 +1990,9 @@ function fillDownData(ctx) {
1941
1990
  }
1942
1991
  }
1943
1992
  }
1993
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
1994
+ ctx.hooks.updateCellYdoc(cellChanges);
1995
+ }
1944
1996
  }
1945
1997
  return "success";
1946
1998
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.10-test",
3
+ "version": "1.3.10-yjs",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",