@fileverse-dev/fortune-core 1.3.10-yjs-4 → 1.3.10-yjs-5

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.
@@ -396,7 +396,8 @@ function activeFormulaInput(cellInput, fxInput, ctx, row_index, col_index, rowh,
396
396
  });
397
397
  }
398
398
  function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
399
- var _a;
399
+ var _a, _b, _c;
400
+ var _d;
400
401
  var f = "=".concat(formula.toUpperCase(), "(").concat(getRangetxt(ctx, ctx.currentSheetId, {
401
402
  row: rowh,
402
403
  column: columnh
@@ -407,7 +408,20 @@ function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
407
408
  f: v[2]
408
409
  };
409
410
  setCellValue(ctx, r, c, d, value);
410
- (_a = ctx.formulaCache).execFunctionExist || (_a.execFunctionExist = []);
411
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
412
+ ctx.hooks.updateCellYdoc([{
413
+ sheetId: ctx.currentSheetId,
414
+ path: ["celldata"],
415
+ value: {
416
+ r: r,
417
+ c: c,
418
+ 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
419
+ },
420
+ key: "".concat(r, "_").concat(c),
421
+ type: "update"
422
+ }]);
423
+ }
424
+ (_d = ctx.formulaCache).execFunctionExist || (_d.execFunctionExist = []);
411
425
  ctx.formulaCache.execFunctionExist.push({
412
426
  r: r,
413
427
  c: c,
package/lib/api/range.js CHANGED
@@ -93,6 +93,7 @@ function setSelection(ctx, range, options) {
93
93
  }
94
94
  }
95
95
  function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpdate) {
96
+ var _a, _b, _c, _d, _e;
96
97
  if (options === void 0) {
97
98
  options = {};
98
99
  }
@@ -110,13 +111,32 @@ function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpd
110
111
  if (data.length !== rowCount || data[0].length !== columnCount) {
111
112
  throw new Error("data size does not match range");
112
113
  }
114
+ var sheet = (0, _common.getSheet)(ctx, options);
115
+ var sheetId = sheet.id || ctx.currentSheetId;
116
+ var cellChanges = [];
113
117
  for (var i = 0; i < rowCount; i += 1) {
114
118
  for (var j = 0; j < columnCount; j += 1) {
115
119
  var row = range.row[0] + i;
116
120
  var column = range.column[0] + j;
117
121
  (0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options, callAfterUpdate);
122
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && sheet.data) {
123
+ cellChanges.push({
124
+ sheetId: sheetId,
125
+ path: ["celldata"],
126
+ value: {
127
+ r: row,
128
+ c: column,
129
+ v: (_d = (_c = (_b = sheet.data) === null || _b === void 0 ? void 0 : _b[row]) === null || _c === void 0 ? void 0 : _c[column]) !== null && _d !== void 0 ? _d : null
130
+ },
131
+ key: "".concat(row, "_").concat(column),
132
+ type: "update"
133
+ });
134
+ }
118
135
  }
119
136
  }
137
+ if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
138
+ ctx.hooks.updateCellYdoc(cellChanges);
139
+ }
120
140
  }
121
141
  function setCellFormatByRange(ctx, attr, value, range, options) {
122
142
  if (options === void 0) {
@@ -932,7 +932,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
932
932
  }
933
933
  }
934
934
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
935
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
935
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
936
936
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
937
937
  if (!allowEdit || ctx.isFlvReadOnly) return;
938
938
  if (!copyRange) return;
@@ -1113,6 +1113,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1113
1113
  value.m = "Loading...";
1114
1114
  }
1115
1115
  }
1116
+ var afterHookCalled = false;
1116
1117
  if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
1117
1118
  var adjustedFormula = value.f;
1118
1119
  var isError = false;
@@ -1165,6 +1166,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1165
1166
  v: arr.length === 1 ? funcV[1] : value.v,
1166
1167
  m: funcV[1] instanceof Promise ? "[object Promise]" : funcV[1]
1167
1168
  }));
1169
+ afterHookCalled = true;
1168
1170
  }
1169
1171
  }
1170
1172
  if (!_lodash.default.isNil(value.spl)) {}
@@ -1185,17 +1187,19 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1185
1187
  };
1186
1188
  }
1187
1189
  }
1188
- changes.push({
1189
- sheetId: ctx.currentSheetId,
1190
- path: ["celldata"],
1191
- value: {
1192
- r: h,
1193
- c: c,
1194
- v: d[h][c]
1195
- },
1196
- key: "".concat(h, "_").concat(c),
1197
- type: "update"
1198
- });
1190
+ if (!(((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.afterUpdateCell) && afterHookCalled)) {
1191
+ changes.push({
1192
+ sheetId: ctx.currentSheetId,
1193
+ path: ["celldata"],
1194
+ value: {
1195
+ r: h,
1196
+ c: c,
1197
+ v: d[h][c]
1198
+ },
1199
+ key: "".concat(h, "_").concat(c),
1200
+ type: "update"
1201
+ });
1202
+ }
1199
1203
  }
1200
1204
  d[h] = x;
1201
1205
  }
@@ -1207,7 +1211,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1207
1211
  var a_file = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)];
1208
1212
  var ruleArr_cf = _lodash.default.cloneDeep(c_file.luckysheet_conditionformat_save);
1209
1213
  if (!_lodash.default.isNil(ruleArr_cf) && ruleArr_cf.length > 0) {
1210
- cdformat = (_k = _lodash.default.cloneDeep(a_file.luckysheet_conditionformat_save)) !== null && _k !== void 0 ? _k : [];
1214
+ cdformat = (_l = _lodash.default.cloneDeep(a_file.luckysheet_conditionformat_save)) !== null && _l !== void 0 ? _l : [];
1211
1215
  for (var i = 0; i < ruleArr_cf.length; i += 1) {
1212
1216
  var cf_range = ruleArr_cf[i].cellrange;
1213
1217
  var emptyRange = [];
@@ -1243,8 +1247,8 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1243
1247
  file.config = cfg;
1244
1248
  file.luckysheet_conditionformat_save = cdformat;
1245
1249
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1246
- if (((_l = ctx.luckysheet_select_save) === null || _l === void 0 ? void 0 : _l.length) === 1 && ((_m = ctx.luckysheet_copy_save) === null || _m === void 0 ? void 0 : _m.copyRange.length) === 1) {
1247
- var srcIndex = (0, _utils.getSheetIndex)(ctx, (_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.dataSheetId);
1250
+ if (((_m = ctx.luckysheet_select_save) === null || _m === void 0 ? void 0 : _m.length) === 1 && ((_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.copyRange.length) === 1) {
1251
+ var srcIndex = (0, _utils.getSheetIndex)(ctx, (_p = ctx.luckysheet_copy_save) === null || _p === void 0 ? void 0 : _p.dataSheetId);
1248
1252
  var targetSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1249
1253
  var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
1250
1254
  var srcData = ctx.luckysheetfile[srcIndex].data;
@@ -1255,7 +1259,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1255
1259
  var isSingleCell = copyh === 1 && copyc === 1;
1256
1260
  var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
1257
1261
  var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
1258
- var cachedSrcCell = isSingleCell && srcData ? (_p = srcData[c_r1]) === null || _p === void 0 ? void 0 : _p[c_c1] : null;
1262
+ var cachedSrcCell = isSingleCell && srcData ? (_q = srcData[c_r1]) === null || _q === void 0 ? void 0 : _q[c_c1] : null;
1259
1263
  for (var th = 1; th <= timesH; th += 1) {
1260
1264
  for (var tc = 1; tc <= timesC; tc += 1) {
1261
1265
  var linkMth = minh + (th - 1) * copyh;
@@ -1275,7 +1279,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1275
1279
  if (!srcLink) continue;
1276
1280
  var targetKey = "".concat(h, "_").concat(c);
1277
1281
  targetHyperlinks[targetKey] = srcLink;
1278
- var cell = (_q = d[h]) === null || _q === void 0 ? void 0 : _q[c];
1282
+ var cell = (_r = d[h]) === null || _r === void 0 ? void 0 : _r[c];
1279
1283
  if (cell) {
1280
1284
  var srcCell = void 0;
1281
1285
  if (isSingleCell && cachedSrcCell) {
@@ -1283,7 +1287,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1283
1287
  } else {
1284
1288
  var srcRow = c_r1 + (h - linkMth);
1285
1289
  var srcCol = c_c1 + (c - linkMtc);
1286
- srcCell = (_r = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _r === void 0 ? void 0 : _r[srcCol];
1290
+ srcCell = (_s = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _s === void 0 ? void 0 : _s[srcCol];
1287
1291
  }
1288
1292
  cell.hl = {
1289
1293
  r: h,
@@ -1303,7 +1307,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1303
1307
  }
1304
1308
  }
1305
1309
  }
1306
- if (changes.length > 0 && ((_s = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _s === void 0 ? void 0 : _s.updateCellYdoc)) {
1310
+ if (changes.length > 0 && ((_t = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _t === void 0 ? void 0 : _t.updateCellYdoc)) {
1307
1311
  ctx.hooks.updateCellYdoc(changes);
1308
1312
  }
1309
1313
  if (copyRowlChange || addr > 0 || addc > 0) {
@@ -244,7 +244,7 @@ function validateCellData(ctx, item, cellValue) {
244
244
  return true;
245
245
  }
246
246
  function checkboxChange(ctx, r, c) {
247
- var _a;
247
+ var _a, _b, _c, _d;
248
248
  var index = (0, _.getSheetIndex)(ctx, ctx.currentSheetId);
249
249
  var currentDataVerification = (_a = ctx.luckysheetfile[index].dataVerification) !== null && _a !== void 0 ? _a : {};
250
250
  var item = currentDataVerification["".concat(r, "_").concat(c)];
@@ -255,6 +255,25 @@ function checkboxChange(ctx, r, c) {
255
255
  }
256
256
  var d = (0, _.getFlowdata)(ctx);
257
257
  (0, _.setCellValue)(ctx, r, c, d, value);
258
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
259
+ ctx.hooks.updateCellYdoc([{
260
+ sheetId: ctx.currentSheetId,
261
+ path: ["celldata"],
262
+ value: {
263
+ r: r,
264
+ c: c,
265
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) !== null && _d !== void 0 ? _d : null
266
+ },
267
+ key: "".concat(r, "_").concat(c),
268
+ type: "update"
269
+ }, {
270
+ sheetId: ctx.currentSheetId,
271
+ path: ["dataVerification"],
272
+ key: "".concat(r, "_").concat(c),
273
+ value: JSON.parse(JSON.stringify(item)),
274
+ type: "update"
275
+ }]);
276
+ }
258
277
  }
259
278
  function getFailureText(ctx, item) {
260
279
  var _a, _b, _c, _d, _e;
@@ -602,6 +621,7 @@ function cellFocus(ctx, r, c, clickMode) {
602
621
  }
603
622
  function setDropdownValue(ctx, value, arr) {
604
623
  var _a;
624
+ var _b, _c, _d;
605
625
  if (!ctx.luckysheet_select_save) return;
606
626
  var d = (0, _.getFlowdata)(ctx);
607
627
  if (!d) return;
@@ -647,6 +667,19 @@ function setDropdownValue(ctx, value, arr) {
647
667
  v: value,
648
668
  pillColor: selectedColor
649
669
  });
670
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
671
+ ctx.hooks.updateCellYdoc([{
672
+ sheetId: ctx.currentSheetId,
673
+ path: ["celldata"],
674
+ value: {
675
+ r: rowIndex,
676
+ c: colIndex,
677
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[rowIndex]) === null || _c === void 0 ? void 0 : _c[colIndex]) !== null && _d !== void 0 ? _d : null
678
+ },
679
+ key: "".concat(rowIndex, "_").concat(colIndex),
680
+ type: "update"
681
+ }]);
682
+ }
650
683
  var currentRowHeight = (0, _api.getRowHeight)(ctx, [rowIndex])[rowIndex];
651
684
  var newHeight = 22 * (value.split(",").length || (valueData === null || valueData === void 0 ? void 0 : valueData.length)) || 22;
652
685
  if (currentRowHeight < newHeight) {
@@ -1843,6 +1843,7 @@ function updateDropCell(ctx) {
1843
1843
  for (var j = apply_str_r; j <= apply_end_r; j += 1) {
1844
1844
  if (hiddenRows.has("".concat(j))) continue;
1845
1845
  var cell = applyData[j - apply_str_r];
1846
+ var afterHookCalled = false;
1846
1847
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1847
1848
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "down", j - apply_str_r + 1));
1848
1849
  var v = formula.execfunction(ctx, f, j, i);
@@ -1854,6 +1855,7 @@ function updateDropCell(ctx) {
1854
1855
  v: v[1] instanceof Promise ? v[1] : cell.v,
1855
1856
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1856
1857
  }));
1858
+ afterHookCalled = true;
1857
1859
  }
1858
1860
  if (cell.spl != null) {
1859
1861
  cell.spl = v[3].data;
@@ -1891,17 +1893,19 @@ function updateDropCell(ctx) {
1891
1893
  }
1892
1894
  }
1893
1895
  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
- });
1896
+ if (!afterHookCalled) {
1897
+ cellChanges.push({
1898
+ sheetId: ctx.currentSheetId,
1899
+ path: ["celldata"],
1900
+ value: {
1901
+ r: j,
1902
+ c: i,
1903
+ v: d[j][i]
1904
+ },
1905
+ key: "".concat(j, "_").concat(i),
1906
+ type: "update"
1907
+ });
1908
+ }
1905
1909
  var bd_r = copy_str_r + (j - apply_str_r) % csLen;
1906
1910
  var bd_c = i;
1907
1911
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1940,6 +1944,7 @@ function updateDropCell(ctx) {
1940
1944
  for (var j = apply_end_r; j >= apply_str_r; j -= 1) {
1941
1945
  if (hiddenRows.has("".concat(j))) continue;
1942
1946
  var cell = applyData[apply_end_r - j];
1947
+ var afterHookCalled = false;
1943
1948
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1944
1949
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "up", apply_end_r - j + 1));
1945
1950
  var v = formula.execfunction(ctx, f, j, i);
@@ -1951,6 +1956,7 @@ function updateDropCell(ctx) {
1951
1956
  v: v[1] instanceof Promise ? v[1] : cell.v,
1952
1957
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1953
1958
  }));
1959
+ afterHookCalled = true;
1954
1960
  }
1955
1961
  if (cell.spl != null) {
1956
1962
  cell.spl = v[3].data;
@@ -1982,17 +1988,19 @@ function updateDropCell(ctx) {
1982
1988
  }
1983
1989
  }
1984
1990
  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
- });
1991
+ if (!afterHookCalled) {
1992
+ cellChanges.push({
1993
+ sheetId: ctx.currentSheetId,
1994
+ path: ["celldata"],
1995
+ value: {
1996
+ r: j,
1997
+ c: i,
1998
+ v: d[j][i]
1999
+ },
2000
+ key: "".concat(j, "_").concat(i),
2001
+ type: "update"
2002
+ });
2003
+ }
1996
2004
  var bd_r = copy_end_r - (apply_end_r - j) % csLen;
1997
2005
  var bd_c = i;
1998
2006
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2038,6 +2046,7 @@ function updateDropCell(ctx) {
2038
2046
  for (var j = apply_str_c; j <= apply_end_c; j += 1) {
2039
2047
  if (hiddenCols.has("".concat(j))) continue;
2040
2048
  var cell = applyData[j - apply_str_c];
2049
+ var afterHookCalled = false;
2041
2050
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2042
2051
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "right", j - apply_str_c + 1));
2043
2052
  var v = formula.execfunction(ctx, f, i, j);
@@ -2049,6 +2058,7 @@ function updateDropCell(ctx) {
2049
2058
  v: v[1] instanceof Promise ? v[1] : cell.v,
2050
2059
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2051
2060
  }));
2061
+ afterHookCalled = true;
2052
2062
  }
2053
2063
  if (cell.spl != null) {
2054
2064
  cell.spl = v[3].data;
@@ -2080,17 +2090,19 @@ function updateDropCell(ctx) {
2080
2090
  }
2081
2091
  }
2082
2092
  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
- });
2093
+ if (!afterHookCalled) {
2094
+ cellChanges.push({
2095
+ sheetId: ctx.currentSheetId,
2096
+ path: ["celldata"],
2097
+ value: {
2098
+ r: i,
2099
+ c: j,
2100
+ v: d[i][j]
2101
+ },
2102
+ key: "".concat(i, "_").concat(j),
2103
+ type: "update"
2104
+ });
2105
+ }
2094
2106
  var bd_r = i;
2095
2107
  var bd_c = copy_str_c + (j - apply_str_c) % csLen;
2096
2108
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2129,6 +2141,7 @@ function updateDropCell(ctx) {
2129
2141
  for (var j = apply_end_c; j >= apply_str_c; j -= 1) {
2130
2142
  if (hiddenCols.has("".concat(j))) continue;
2131
2143
  var cell = applyData[apply_end_c - j];
2144
+ var afterHookCalled = false;
2132
2145
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2133
2146
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "left", apply_end_c - j + 1));
2134
2147
  var v = formula.execfunction(ctx, f, i, j);
@@ -2140,6 +2153,7 @@ function updateDropCell(ctx) {
2140
2153
  v: v[1] instanceof Promise ? v[1] : cell.v,
2141
2154
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2142
2155
  }));
2156
+ afterHookCalled = true;
2143
2157
  }
2144
2158
  if (cell.spl != null) {
2145
2159
  cell.spl = v[3].data;
@@ -2171,17 +2185,19 @@ function updateDropCell(ctx) {
2171
2185
  }
2172
2186
  }
2173
2187
  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
- });
2188
+ if (!afterHookCalled) {
2189
+ cellChanges.push({
2190
+ sheetId: ctx.currentSheetId,
2191
+ path: ["celldata"],
2192
+ value: {
2193
+ r: i,
2194
+ c: j,
2195
+ v: d[i][j]
2196
+ },
2197
+ key: "".concat(i, "_").concat(j),
2198
+ type: "update"
2199
+ });
2200
+ }
2185
2201
  var bd_r = i;
2186
2202
  var bd_c = copy_end_c - (apply_end_c - j) % csLen;
2187
2203
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -815,6 +815,7 @@ function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
815
815
  return dynamicArray;
816
816
  }
817
817
  function groupValuesRefresh(ctx) {
818
+ var _a, _b, _c;
818
819
  var luckysheetfile = ctx.luckysheetfile;
819
820
  if (ctx.groupValuesRefreshData.length > 0) {
820
821
  for (var i = 0; i < ctx.groupValuesRefreshData.length; i += 1) {
@@ -837,6 +838,19 @@ function groupValuesRefresh(ctx) {
837
838
  updateValue.v = item.v;
838
839
  updateValue.f = item.f;
839
840
  (0, _cell.setCellValue)(ctx, item.r, item.c, data, updateValue);
841
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
842
+ ctx.hooks.updateCellYdoc([{
843
+ sheetId: item.id,
844
+ path: ["celldata"],
845
+ value: {
846
+ r: item.r,
847
+ c: item.c,
848
+ 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
849
+ },
850
+ key: "".concat(item.r, "_").concat(item.c),
851
+ type: "update"
852
+ }]);
853
+ }
840
854
  }
841
855
  ctx.groupValuesRefreshData = [];
842
856
  }
@@ -271,7 +271,7 @@ function onSearchDialogMoveEnd(globalCache) {
271
271
  _lodash.default.set(globalCache, "searchDialog.moveProps", undefined);
272
272
  }
273
273
  function replace(ctx, searchText, replaceText, checkModes) {
274
- var _a, _b;
274
+ var _a, _b, _c, _d, _e, _f, _g, _h;
275
275
  var findAndReplace = (0, _locale.locale)(ctx).findAndReplace;
276
276
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
277
277
  if (!allowEdit) {
@@ -318,6 +318,19 @@ function replace(ctx, searchText, replaceText, checkModes) {
318
318
  c = searchIndexArr[count].c;
319
319
  var v = replaceText;
320
320
  (0, _cell.setCellValue)(ctx, r, c, d, v);
321
+ if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
322
+ ctx.hooks.updateCellYdoc([{
323
+ sheetId: ctx.currentSheetId,
324
+ path: ["celldata"],
325
+ value: {
326
+ r: r,
327
+ c: c,
328
+ v: (_e = (_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) !== null && _e !== void 0 ? _e : null
329
+ },
330
+ key: "".concat(r, "_").concat(c),
331
+ type: "update"
332
+ }]);
333
+ }
321
334
  } else {
322
335
  var reg = void 0;
323
336
  if (checkModes.caseCheck) {
@@ -329,6 +342,19 @@ function replace(ctx, searchText, replaceText, checkModes) {
329
342
  c = searchIndexArr[count].c;
330
343
  var v = (0, _format.valueShowEs)(r, c, d).toString().replace(reg, replaceText);
331
344
  (0, _cell.setCellValue)(ctx, r, c, d, v);
345
+ if ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc) {
346
+ ctx.hooks.updateCellYdoc([{
347
+ sheetId: ctx.currentSheetId,
348
+ path: ["celldata"],
349
+ value: {
350
+ r: r,
351
+ c: c,
352
+ v: (_h = (_g = d === null || d === void 0 ? void 0 : d[r]) === null || _g === void 0 ? void 0 : _g[c]) !== null && _h !== void 0 ? _h : null
353
+ },
354
+ key: "".concat(r, "_").concat(c),
355
+ type: "update"
356
+ }]);
357
+ }
332
358
  }
333
359
  ctx.luckysheet_select_save = (0, _selection.normalizeSelection)(ctx, [{
334
360
  row: [r, r],
@@ -338,7 +364,7 @@ function replace(ctx, searchText, replaceText, checkModes) {
338
364
  return null;
339
365
  }
340
366
  function replaceAll(ctx, searchText, replaceText, checkModes) {
341
- var _a;
367
+ var _a, _b, _c, _d, _e, _f, _g, _h;
342
368
  var findAndReplace = (0, _locale.locale)(ctx).findAndReplace;
343
369
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
344
370
  if (!allowEdit) {
@@ -362,6 +388,7 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
362
388
  return findAndReplace.noReplceTip;
363
389
  }
364
390
  var d = flowdata;
391
+ var cellChanges = [];
365
392
  var replaceCount = 0;
366
393
  if (checkModes.wordCheck) {
367
394
  for (var i = 0; i < searchIndexArr.length; i += 1) {
@@ -369,6 +396,19 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
369
396
  var c = searchIndexArr[i].c;
370
397
  var v = replaceText;
371
398
  (0, _cell.setCellValue)(ctx, r, c, d, v);
399
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
400
+ cellChanges.push({
401
+ sheetId: ctx.currentSheetId,
402
+ path: ["celldata"],
403
+ value: {
404
+ r: r,
405
+ c: c,
406
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) !== null && _d !== void 0 ? _d : null
407
+ },
408
+ key: "".concat(r, "_").concat(c),
409
+ type: "update"
410
+ });
411
+ }
372
412
  range.push({
373
413
  row: [r, r],
374
414
  column: [c, c]
@@ -387,6 +427,19 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
387
427
  var c = searchIndexArr[i].c;
388
428
  var v = (0, _format.valueShowEs)(r, c, d).toString().replace(reg, replaceText);
389
429
  (0, _cell.setCellValue)(ctx, r, c, d, v);
430
+ if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
431
+ cellChanges.push({
432
+ sheetId: ctx.currentSheetId,
433
+ path: ["celldata"],
434
+ value: {
435
+ r: r,
436
+ c: c,
437
+ v: (_g = (_f = d === null || d === void 0 ? void 0 : d[r]) === null || _f === void 0 ? void 0 : _f[c]) !== null && _g !== void 0 ? _g : null
438
+ },
439
+ key: "".concat(r, "_").concat(c),
440
+ type: "update"
441
+ });
442
+ }
390
443
  range.push({
391
444
  row: [r, r],
392
445
  column: [c, c]
@@ -394,6 +447,9 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
394
447
  replaceCount += 1;
395
448
  }
396
449
  }
450
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
451
+ ctx.hooks.updateCellYdoc(cellChanges);
452
+ }
397
453
  ctx.luckysheet_select_save = (0, _selection.normalizeSelection)(ctx, range);
398
454
  var succeedInfo = (0, _utils.replaceHtml)(findAndReplace.successTip, {
399
455
  xlength: replaceCount
@@ -1551,7 +1551,7 @@ function copy(ctx) {
1551
1551
  }
1552
1552
  }
1553
1553
  function deleteSelectedCellText(ctx) {
1554
- var _a, _b, _c, _d, _e;
1554
+ var _a, _b, _c, _d, _e, _f;
1555
1555
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1556
1556
  if (allowEdit === false || ctx.isFlvReadOnly) {
1557
1557
  return "allowEdit";
@@ -1614,20 +1614,22 @@ function deleteSelectedCellText(ctx) {
1614
1614
  if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
1615
1615
  ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
1616
1616
  }
1617
- changes.push({
1618
- sheetId: ctx.currentSheetId,
1619
- path: ["celldata"],
1620
- value: {
1621
- r: r,
1622
- c: c,
1623
- v: d[r][c]
1624
- },
1625
- key: "".concat(r, "_").concat(c),
1626
- type: "update"
1627
- });
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
+ }
1628
1630
  }
1629
1631
  }
1630
- if (changes.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
1632
+ if (changes.length > 0 && ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc)) {
1631
1633
  ctx.hooks.updateCellYdoc(changes);
1632
1634
  }
1633
1635
  }
@@ -224,6 +224,7 @@ function createRowsOrColumnsForSpilledValues(ctx, startRow, startColumn, spillRo
224
224
  }
225
225
  }
226
226
  function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
227
+ var _a, _b;
227
228
  var formulaString = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.f;
228
229
  var formulaValue = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.v;
229
230
  if (typeof formulaString !== "string" || !(/= *SORT\s*\(/i.test(formulaString) || /= *XLOOKUP\s*\(/i.test(formulaString) || /= *SEQUENCE\s*\(/i.test(formulaString))) return false;
@@ -255,5 +256,27 @@ function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
255
256
  });
256
257
  }
257
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
+ }
258
281
  return true;
259
282
  }