@fileverse-dev/fortune-core 1.3.10-yjs-3 → 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.
package/es/api/range.js CHANGED
@@ -78,6 +78,7 @@ export function setSelection(ctx, range, options) {
78
78
  }
79
79
  }
80
80
  export function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpdate) {
81
+ var _a, _b, _c, _d, _e;
81
82
  if (options === void 0) {
82
83
  options = {};
83
84
  }
@@ -95,13 +96,32 @@ export function setCellValuesByRange(ctx, data, range, cellInput, options, callA
95
96
  if (data.length !== rowCount || data[0].length !== columnCount) {
96
97
  throw new Error("data size does not match range");
97
98
  }
99
+ var sheet = getSheet(ctx, options);
100
+ var sheetId = sheet.id || ctx.currentSheetId;
101
+ var cellChanges = [];
98
102
  for (var i = 0; i < rowCount; i += 1) {
99
103
  for (var j = 0; j < columnCount; j += 1) {
100
104
  var row = range.row[0] + i;
101
105
  var column = range.column[0] + j;
102
106
  setCellValue(ctx, row, column, data[i][j], cellInput, options, callAfterUpdate);
107
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && sheet.data) {
108
+ cellChanges.push({
109
+ sheetId: sheetId,
110
+ path: ["celldata"],
111
+ value: {
112
+ r: row,
113
+ c: column,
114
+ 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
115
+ },
116
+ key: "".concat(row, "_").concat(column),
117
+ type: "update"
118
+ });
119
+ }
103
120
  }
104
121
  }
122
+ if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
123
+ ctx.hooks.updateCellYdoc(cellChanges);
124
+ }
105
125
  }
106
126
  export function setCellFormatByRange(ctx, attr, value, range, options) {
107
127
  if (options === void 0) {
@@ -919,7 +919,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
919
919
  }
920
920
  }
921
921
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
922
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
922
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
923
923
  var allowEdit = isAllowEdit(ctx);
924
924
  if (!allowEdit || ctx.isFlvReadOnly) return;
925
925
  if (!copyRange) return;
@@ -1100,6 +1100,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1100
1100
  value.m = "Loading...";
1101
1101
  }
1102
1102
  }
1103
+ var afterHookCalled = false;
1103
1104
  if (!_.isNil(value) && !_.isNil(value.f)) {
1104
1105
  var adjustedFormula = value.f;
1105
1106
  var isError = false;
@@ -1152,6 +1153,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1152
1153
  v: arr.length === 1 ? funcV[1] : value.v,
1153
1154
  m: funcV[1] instanceof Promise ? "[object Promise]" : funcV[1]
1154
1155
  }));
1156
+ afterHookCalled = true;
1155
1157
  }
1156
1158
  }
1157
1159
  if (!_.isNil(value.spl)) {}
@@ -1172,17 +1174,19 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1172
1174
  };
1173
1175
  }
1174
1176
  }
1175
- changes.push({
1176
- sheetId: ctx.currentSheetId,
1177
- path: ["celldata"],
1178
- value: {
1179
- r: h,
1180
- c: c,
1181
- v: d[h][c]
1182
- },
1183
- key: "".concat(h, "_").concat(c),
1184
- type: "update"
1185
- });
1177
+ if (!(((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.afterUpdateCell) && afterHookCalled)) {
1178
+ changes.push({
1179
+ sheetId: ctx.currentSheetId,
1180
+ path: ["celldata"],
1181
+ value: {
1182
+ r: h,
1183
+ c: c,
1184
+ v: d[h][c]
1185
+ },
1186
+ key: "".concat(h, "_").concat(c),
1187
+ type: "update"
1188
+ });
1189
+ }
1186
1190
  }
1187
1191
  d[h] = x;
1188
1192
  }
@@ -1194,7 +1198,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1194
1198
  var a_file = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
1195
1199
  var ruleArr_cf = _.cloneDeep(c_file.luckysheet_conditionformat_save);
1196
1200
  if (!_.isNil(ruleArr_cf) && ruleArr_cf.length > 0) {
1197
- cdformat = (_k = _.cloneDeep(a_file.luckysheet_conditionformat_save)) !== null && _k !== void 0 ? _k : [];
1201
+ cdformat = (_l = _.cloneDeep(a_file.luckysheet_conditionformat_save)) !== null && _l !== void 0 ? _l : [];
1198
1202
  for (var i = 0; i < ruleArr_cf.length; i += 1) {
1199
1203
  var cf_range = ruleArr_cf[i].cellrange;
1200
1204
  var emptyRange = [];
@@ -1230,8 +1234,8 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1230
1234
  file.config = cfg;
1231
1235
  file.luckysheet_conditionformat_save = cdformat;
1232
1236
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1233
- 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) {
1234
- var srcIndex = getSheetIndex(ctx, (_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.dataSheetId);
1237
+ 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) {
1238
+ var srcIndex = getSheetIndex(ctx, (_p = ctx.luckysheet_copy_save) === null || _p === void 0 ? void 0 : _p.dataSheetId);
1235
1239
  var targetSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1236
1240
  var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
1237
1241
  var srcData = ctx.luckysheetfile[srcIndex].data;
@@ -1242,7 +1246,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1242
1246
  var isSingleCell = copyh === 1 && copyc === 1;
1243
1247
  var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
1244
1248
  var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
1245
- var cachedSrcCell = isSingleCell && srcData ? (_p = srcData[c_r1]) === null || _p === void 0 ? void 0 : _p[c_c1] : null;
1249
+ var cachedSrcCell = isSingleCell && srcData ? (_q = srcData[c_r1]) === null || _q === void 0 ? void 0 : _q[c_c1] : null;
1246
1250
  for (var th = 1; th <= timesH; th += 1) {
1247
1251
  for (var tc = 1; tc <= timesC; tc += 1) {
1248
1252
  var linkMth = minh + (th - 1) * copyh;
@@ -1262,7 +1266,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1262
1266
  if (!srcLink) continue;
1263
1267
  var targetKey = "".concat(h, "_").concat(c);
1264
1268
  targetHyperlinks[targetKey] = srcLink;
1265
- var cell = (_q = d[h]) === null || _q === void 0 ? void 0 : _q[c];
1269
+ var cell = (_r = d[h]) === null || _r === void 0 ? void 0 : _r[c];
1266
1270
  if (cell) {
1267
1271
  var srcCell = void 0;
1268
1272
  if (isSingleCell && cachedSrcCell) {
@@ -1270,7 +1274,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1270
1274
  } else {
1271
1275
  var srcRow = c_r1 + (h - linkMth);
1272
1276
  var srcCol = c_c1 + (c - linkMtc);
1273
- srcCell = (_r = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _r === void 0 ? void 0 : _r[srcCol];
1277
+ srcCell = (_s = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _s === void 0 ? void 0 : _s[srcCol];
1274
1278
  }
1275
1279
  cell.hl = {
1276
1280
  r: h,
@@ -1290,7 +1294,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1290
1294
  }
1291
1295
  }
1292
1296
  }
1293
- if (changes.length > 0 && ((_s = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _s === void 0 ? void 0 : _s.updateCellYdoc)) {
1297
+ if (changes.length > 0 && ((_t = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _t === void 0 ? void 0 : _t.updateCellYdoc)) {
1294
1298
  ctx.hooks.updateCellYdoc(changes);
1295
1299
  }
1296
1300
  if (copyRowlChange || addr > 0 || addc > 0) {
@@ -229,7 +229,7 @@ export function validateCellData(ctx, item, cellValue) {
229
229
  return true;
230
230
  }
231
231
  export function checkboxChange(ctx, r, c) {
232
- var _a;
232
+ var _a, _b, _c, _d;
233
233
  var index = getSheetIndex(ctx, ctx.currentSheetId);
234
234
  var currentDataVerification = (_a = ctx.luckysheetfile[index].dataVerification) !== null && _a !== void 0 ? _a : {};
235
235
  var item = currentDataVerification["".concat(r, "_").concat(c)];
@@ -240,6 +240,25 @@ export function checkboxChange(ctx, r, c) {
240
240
  }
241
241
  var d = getFlowdata(ctx);
242
242
  setCellValue(ctx, r, c, d, value);
243
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
244
+ ctx.hooks.updateCellYdoc([{
245
+ sheetId: ctx.currentSheetId,
246
+ path: ["celldata"],
247
+ value: {
248
+ r: r,
249
+ c: c,
250
+ 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
251
+ },
252
+ key: "".concat(r, "_").concat(c),
253
+ type: "update"
254
+ }, {
255
+ sheetId: ctx.currentSheetId,
256
+ path: ["dataVerification"],
257
+ key: "".concat(r, "_").concat(c),
258
+ value: JSON.parse(JSON.stringify(item)),
259
+ type: "update"
260
+ }]);
261
+ }
243
262
  }
244
263
  export function getFailureText(ctx, item) {
245
264
  var _a, _b, _c, _d, _e;
@@ -587,6 +606,7 @@ export function cellFocus(ctx, r, c, clickMode) {
587
606
  }
588
607
  export function setDropdownValue(ctx, value, arr) {
589
608
  var _a;
609
+ var _b, _c, _d;
590
610
  if (!ctx.luckysheet_select_save) return;
591
611
  var d = getFlowdata(ctx);
592
612
  if (!d) return;
@@ -632,6 +652,19 @@ export function setDropdownValue(ctx, value, arr) {
632
652
  v: value,
633
653
  pillColor: selectedColor
634
654
  });
655
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
656
+ ctx.hooks.updateCellYdoc([{
657
+ sheetId: ctx.currentSheetId,
658
+ path: ["celldata"],
659
+ value: {
660
+ r: rowIndex,
661
+ c: colIndex,
662
+ 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
663
+ },
664
+ key: "".concat(rowIndex, "_").concat(colIndex),
665
+ type: "update"
666
+ }]);
667
+ }
635
668
  var currentRowHeight = getRowHeight(ctx, [rowIndex])[rowIndex];
636
669
  var newHeight = 22 * (value.split(",").length || (valueData === null || valueData === void 0 ? void 0 : valueData.length)) || 22;
637
670
  if (currentRowHeight < newHeight) {
@@ -1827,6 +1827,7 @@ export function updateDropCell(ctx) {
1827
1827
  for (var j = apply_str_r; j <= apply_end_r; j += 1) {
1828
1828
  if (hiddenRows.has("".concat(j))) continue;
1829
1829
  var cell = applyData[j - apply_str_r];
1830
+ var afterHookCalled = false;
1830
1831
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1831
1832
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "down", j - apply_str_r + 1));
1832
1833
  var v = formula.execfunction(ctx, f, j, i);
@@ -1838,6 +1839,7 @@ export function updateDropCell(ctx) {
1838
1839
  v: v[1] instanceof Promise ? v[1] : cell.v,
1839
1840
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1840
1841
  }));
1842
+ afterHookCalled = true;
1841
1843
  }
1842
1844
  if (cell.spl != null) {
1843
1845
  cell.spl = v[3].data;
@@ -1875,17 +1877,19 @@ export function updateDropCell(ctx) {
1875
1877
  }
1876
1878
  }
1877
1879
  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
- });
1880
+ if (!afterHookCalled) {
1881
+ cellChanges.push({
1882
+ sheetId: ctx.currentSheetId,
1883
+ path: ["celldata"],
1884
+ value: {
1885
+ r: j,
1886
+ c: i,
1887
+ v: d[j][i]
1888
+ },
1889
+ key: "".concat(j, "_").concat(i),
1890
+ type: "update"
1891
+ });
1892
+ }
1889
1893
  var bd_r = copy_str_r + (j - apply_str_r) % csLen;
1890
1894
  var bd_c = i;
1891
1895
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1924,6 +1928,7 @@ export function updateDropCell(ctx) {
1924
1928
  for (var j = apply_end_r; j >= apply_str_r; j -= 1) {
1925
1929
  if (hiddenRows.has("".concat(j))) continue;
1926
1930
  var cell = applyData[apply_end_r - j];
1931
+ var afterHookCalled = false;
1927
1932
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1928
1933
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "up", apply_end_r - j + 1));
1929
1934
  var v = formula.execfunction(ctx, f, j, i);
@@ -1935,6 +1940,7 @@ export function updateDropCell(ctx) {
1935
1940
  v: v[1] instanceof Promise ? v[1] : cell.v,
1936
1941
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1937
1942
  }));
1943
+ afterHookCalled = true;
1938
1944
  }
1939
1945
  if (cell.spl != null) {
1940
1946
  cell.spl = v[3].data;
@@ -1966,17 +1972,19 @@ export function updateDropCell(ctx) {
1966
1972
  }
1967
1973
  }
1968
1974
  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
- });
1975
+ if (!afterHookCalled) {
1976
+ cellChanges.push({
1977
+ sheetId: ctx.currentSheetId,
1978
+ path: ["celldata"],
1979
+ value: {
1980
+ r: j,
1981
+ c: i,
1982
+ v: d[j][i]
1983
+ },
1984
+ key: "".concat(j, "_").concat(i),
1985
+ type: "update"
1986
+ });
1987
+ }
1980
1988
  var bd_r = copy_end_r - (apply_end_r - j) % csLen;
1981
1989
  var bd_c = i;
1982
1990
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2022,6 +2030,7 @@ export function updateDropCell(ctx) {
2022
2030
  for (var j = apply_str_c; j <= apply_end_c; j += 1) {
2023
2031
  if (hiddenCols.has("".concat(j))) continue;
2024
2032
  var cell = applyData[j - apply_str_c];
2033
+ var afterHookCalled = false;
2025
2034
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2026
2035
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "right", j - apply_str_c + 1));
2027
2036
  var v = formula.execfunction(ctx, f, i, j);
@@ -2033,6 +2042,7 @@ export function updateDropCell(ctx) {
2033
2042
  v: v[1] instanceof Promise ? v[1] : cell.v,
2034
2043
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2035
2044
  }));
2045
+ afterHookCalled = true;
2036
2046
  }
2037
2047
  if (cell.spl != null) {
2038
2048
  cell.spl = v[3].data;
@@ -2064,17 +2074,19 @@ export function updateDropCell(ctx) {
2064
2074
  }
2065
2075
  }
2066
2076
  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
- });
2077
+ if (!afterHookCalled) {
2078
+ cellChanges.push({
2079
+ sheetId: ctx.currentSheetId,
2080
+ path: ["celldata"],
2081
+ value: {
2082
+ r: i,
2083
+ c: j,
2084
+ v: d[i][j]
2085
+ },
2086
+ key: "".concat(i, "_").concat(j),
2087
+ type: "update"
2088
+ });
2089
+ }
2078
2090
  var bd_r = i;
2079
2091
  var bd_c = copy_str_c + (j - apply_str_c) % csLen;
2080
2092
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2113,6 +2125,7 @@ export function updateDropCell(ctx) {
2113
2125
  for (var j = apply_end_c; j >= apply_str_c; j -= 1) {
2114
2126
  if (hiddenCols.has("".concat(j))) continue;
2115
2127
  var cell = applyData[apply_end_c - j];
2128
+ var afterHookCalled = false;
2116
2129
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2117
2130
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "left", apply_end_c - j + 1));
2118
2131
  var v = formula.execfunction(ctx, f, i, j);
@@ -2124,6 +2137,7 @@ export function updateDropCell(ctx) {
2124
2137
  v: v[1] instanceof Promise ? v[1] : cell.v,
2125
2138
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2126
2139
  }));
2140
+ afterHookCalled = true;
2127
2141
  }
2128
2142
  if (cell.spl != null) {
2129
2143
  cell.spl = v[3].data;
@@ -2155,17 +2169,19 @@ export function updateDropCell(ctx) {
2155
2169
  }
2156
2170
  }
2157
2171
  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
- });
2172
+ if (!afterHookCalled) {
2173
+ cellChanges.push({
2174
+ sheetId: ctx.currentSheetId,
2175
+ path: ["celldata"],
2176
+ value: {
2177
+ r: i,
2178
+ c: j,
2179
+ v: d[i][j]
2180
+ },
2181
+ key: "".concat(i, "_").concat(j),
2182
+ type: "update"
2183
+ });
2184
+ }
2169
2185
  var bd_r = i;
2170
2186
  var bd_c = copy_end_c - (apply_end_c - j) % csLen;
2171
2187
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -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
  }
@@ -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 = (_a = ctx.linkCard) === null || _a === void 0 ? void 0 : _a.selectionOffsets;
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 ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
95
- (_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc([{
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;
@@ -107,9 +107,6 @@ var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2,
107
107
  });
108
108
  }
109
109
  }
110
- changes.forEach(function (change) {
111
- console.log("emitCellRangeToYdoc", change, __assign({}, change.value.v));
112
- });
113
110
  if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
114
111
  };
115
112
  export function insertRowCol(ctx, op, changeSelection) {
@@ -257,7 +257,7 @@ export function onSearchDialogMoveEnd(globalCache) {
257
257
  _.set(globalCache, "searchDialog.moveProps", undefined);
258
258
  }
259
259
  export function replace(ctx, searchText, replaceText, checkModes) {
260
- var _a, _b;
260
+ var _a, _b, _c, _d, _e, _f, _g, _h;
261
261
  var findAndReplace = locale(ctx).findAndReplace;
262
262
  var allowEdit = isAllowEdit(ctx);
263
263
  if (!allowEdit) {
@@ -304,6 +304,19 @@ export function replace(ctx, searchText, replaceText, checkModes) {
304
304
  c = searchIndexArr[count].c;
305
305
  var v = replaceText;
306
306
  setCellValue(ctx, r, c, d, v);
307
+ if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
308
+ ctx.hooks.updateCellYdoc([{
309
+ sheetId: ctx.currentSheetId,
310
+ path: ["celldata"],
311
+ value: {
312
+ r: r,
313
+ c: c,
314
+ 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
315
+ },
316
+ key: "".concat(r, "_").concat(c),
317
+ type: "update"
318
+ }]);
319
+ }
307
320
  } else {
308
321
  var reg = void 0;
309
322
  if (checkModes.caseCheck) {
@@ -315,6 +328,19 @@ export function replace(ctx, searchText, replaceText, checkModes) {
315
328
  c = searchIndexArr[count].c;
316
329
  var v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
317
330
  setCellValue(ctx, r, c, d, v);
331
+ if ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc) {
332
+ ctx.hooks.updateCellYdoc([{
333
+ sheetId: ctx.currentSheetId,
334
+ path: ["celldata"],
335
+ value: {
336
+ r: r,
337
+ c: c,
338
+ 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
339
+ },
340
+ key: "".concat(r, "_").concat(c),
341
+ type: "update"
342
+ }]);
343
+ }
318
344
  }
319
345
  ctx.luckysheet_select_save = normalizeSelection(ctx, [{
320
346
  row: [r, r],
@@ -324,7 +350,7 @@ export function replace(ctx, searchText, replaceText, checkModes) {
324
350
  return null;
325
351
  }
326
352
  export function replaceAll(ctx, searchText, replaceText, checkModes) {
327
- var _a;
353
+ var _a, _b, _c, _d, _e, _f, _g, _h;
328
354
  var findAndReplace = locale(ctx).findAndReplace;
329
355
  var allowEdit = isAllowEdit(ctx);
330
356
  if (!allowEdit) {
@@ -348,6 +374,7 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
348
374
  return findAndReplace.noReplceTip;
349
375
  }
350
376
  var d = flowdata;
377
+ var cellChanges = [];
351
378
  var replaceCount = 0;
352
379
  if (checkModes.wordCheck) {
353
380
  for (var i = 0; i < searchIndexArr.length; i += 1) {
@@ -355,6 +382,19 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
355
382
  var c = searchIndexArr[i].c;
356
383
  var v = replaceText;
357
384
  setCellValue(ctx, r, c, d, v);
385
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
386
+ cellChanges.push({
387
+ sheetId: ctx.currentSheetId,
388
+ path: ["celldata"],
389
+ value: {
390
+ r: r,
391
+ c: c,
392
+ 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
393
+ },
394
+ key: "".concat(r, "_").concat(c),
395
+ type: "update"
396
+ });
397
+ }
358
398
  range.push({
359
399
  row: [r, r],
360
400
  column: [c, c]
@@ -373,6 +413,19 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
373
413
  var c = searchIndexArr[i].c;
374
414
  var v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
375
415
  setCellValue(ctx, r, c, d, v);
416
+ if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
417
+ cellChanges.push({
418
+ sheetId: ctx.currentSheetId,
419
+ path: ["celldata"],
420
+ value: {
421
+ r: r,
422
+ c: c,
423
+ 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
424
+ },
425
+ key: "".concat(r, "_").concat(c),
426
+ type: "update"
427
+ });
428
+ }
376
429
  range.push({
377
430
  row: [r, r],
378
431
  column: [c, c]
@@ -380,6 +433,9 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
380
433
  replaceCount += 1;
381
434
  }
382
435
  }
436
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
437
+ ctx.hooks.updateCellYdoc(cellChanges);
438
+ }
383
439
  ctx.luckysheet_select_save = normalizeSelection(ctx, range);
384
440
  var succeedInfo = replaceHtml(findAndReplace.successTip, {
385
441
  xlength: replaceCount