@fileverse-dev/fortune-core 1.3.10 → 1.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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) {
package/lib/api/sheet.js CHANGED
@@ -164,7 +164,7 @@ function generateCopySheetName(ctx, sheetId) {
164
164
  return sheetCopyName;
165
165
  }
166
166
  function copySheet(ctx, sheetId) {
167
- var _a, _b, _c;
167
+ var _a, _b, _c, _d, _e;
168
168
  var index = (0, _utils.getSheetIndex)(ctx, sheetId);
169
169
  var order = ctx.luckysheetfile[index].order + 1;
170
170
  var sheetName = generateCopySheetName(ctx, sheetId);
@@ -201,6 +201,34 @@ function copySheet(ctx, sheetId) {
201
201
  var sheetOrderList = {};
202
202
  sheetOrderList[newSheetId] = order;
203
203
  _2.api.setSheetOrder(ctx, sheetOrderList);
204
+ (0, _2.changeSheet)(ctx, newSheetId, undefined, true, true);
205
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateAllCell) {
206
+ ctx.hooks.updateAllCell(newSheetId);
207
+ } else if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
208
+ var changes_1 = [];
209
+ var celldata = newSheet.celldata || (0, _common.dataToCelldata)(newSheet.data);
210
+ if (Array.isArray(celldata)) {
211
+ celldata.forEach(function (d) {
212
+ var _a;
213
+ if (d == null) return;
214
+ var r = d.r;
215
+ var c = d.c;
216
+ if (!_lodash.default.isNumber(r) || !_lodash.default.isNumber(c)) return;
217
+ changes_1.push({
218
+ sheetId: newSheetId,
219
+ path: ["celldata"],
220
+ key: "".concat(r, "_").concat(c),
221
+ value: {
222
+ r: r,
223
+ c: c,
224
+ v: (_a = d.v) !== null && _a !== void 0 ? _a : null
225
+ },
226
+ type: d.v == null ? "delete" : "update"
227
+ });
228
+ });
229
+ }
230
+ if (changes_1.length > 0) ctx.hooks.updateCellYdoc(changes_1);
231
+ }
204
232
  }
205
233
  function calculateSheetFromula(ctx, id) {
206
234
  var _a, _b, _c;
@@ -390,7 +390,7 @@ function handleArrowKey(ctx, e) {
390
390
  function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
391
391
  var _a, _b, _c;
392
392
  return __awaiter(this, void 0, void 0, function () {
393
- var kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
393
+ var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
394
394
  return __generator(this, function (_d) {
395
395
  if (e.shiftKey && e.code === "Space") {
396
396
  e.stopImmediatePropagation();
@@ -398,27 +398,41 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
398
398
  e.preventDefault();
399
399
  return [2];
400
400
  }
401
+ handledFlvShortcut = false;
401
402
  if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyE") {
402
403
  (0, _selection.textFormat)(ctx, "center");
404
+ handledFlvShortcut = true;
403
405
  } else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
404
406
  (0, _selection.textFormat)(ctx, "left");
407
+ handledFlvShortcut = true;
405
408
  } else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
406
409
  (0, _selection.textFormat)(ctx, "right");
410
+ handledFlvShortcut = true;
407
411
  }
408
412
  if ((e.metaKey || e.ctrlKey) && e.code === "KeyK") {
409
413
  (0, _toolbar.handleLink)(ctx, cellInput);
410
414
  }
411
415
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "Semicolon") {
412
416
  (0, _selection.fillDate)(ctx);
417
+ handledFlvShortcut = true;
413
418
  }
414
419
  if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.code === "Semicolon") {
415
420
  (0, _selection.fillTime)(ctx);
421
+ handledFlvShortcut = true;
416
422
  }
417
423
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "KeyR") {
418
424
  (0, _selection.fillRightData)(ctx);
425
+ handledFlvShortcut = true;
419
426
  }
420
427
  if ((e.metaKey || e.ctrlKey) && e.code === "KeyD") {
421
428
  (0, _selection.fillDownData)(ctx);
429
+ handledFlvShortcut = true;
430
+ }
431
+ if (handledFlvShortcut) {
432
+ (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
433
+ e.stopPropagation();
434
+ e.preventDefault();
435
+ return [2];
422
436
  }
423
437
  ctx.luckysheet_select_status = false;
424
438
  kcode = e.keyCode;
@@ -216,19 +216,19 @@ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
216
216
  cell.f = f;
217
217
  cell.m = v.toString();
218
218
  x[c] = cell;
219
+ changes.push({
220
+ sheetId: ctx.currentSheetId,
221
+ path: ["celldata"],
222
+ value: {
223
+ r: r,
224
+ c: c,
225
+ v: d[r][c]
226
+ },
227
+ key: "".concat(r, "_").concat(c),
228
+ type: "update"
229
+ });
219
230
  }
220
231
  d[r] = x;
221
- changes.push({
222
- sheetId: ctx.currentSheetId,
223
- path: ["celldata"],
224
- value: {
225
- r: r,
226
- c: c,
227
- v: d[r][c]
228
- },
229
- key: "".concat(r, "_").concat(c),
230
- type: "update"
231
- });
232
232
  }
233
233
  }
234
234
  if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
@@ -362,7 +362,9 @@ function pasteHandler(ctx, data, borderInfo) {
362
362
  ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config = cfg;
363
363
  }
364
364
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
365
- handleFormulaOnPaste(ctx, d);
365
+ if (data.includes("=")) {
366
+ handleFormulaOnPaste(ctx, d);
367
+ }
366
368
  } else {
367
369
  data = data.replace(/\r/g, "");
368
370
  var dataChe = [];
@@ -492,17 +494,17 @@ function pasteHandler(ctx, data, borderInfo) {
492
494
  }
493
495
  x[c + curC] = cell;
494
496
  }
495
- changes.push(changes.push({
497
+ changes.push({
496
498
  sheetId: ctx.currentSheetId,
497
499
  path: ["celldata"],
498
500
  value: {
499
- r: r,
500
- c: c,
501
- v: d[r][c]
501
+ r: r + curR,
502
+ c: c + curC,
503
+ v: d[r + curR][c + curC]
502
504
  },
503
- key: "".concat(r, "_").concat(c),
505
+ key: "".concat(r + curR, "_").concat(c + curC),
504
506
  type: "update"
505
- }));
507
+ });
506
508
  }
507
509
  d[r + curR] = x;
508
510
  }
@@ -512,7 +514,9 @@ function pasteHandler(ctx, data, borderInfo) {
512
514
  last.row = [curR, curR + rlen - 1];
513
515
  last.column = [curC, curC + clen - 1];
514
516
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
515
- handleFormulaOnPaste(ctx, d);
517
+ if (data.includes("=")) {
518
+ handleFormulaOnPaste(ctx, d);
519
+ }
516
520
  }
517
521
  }
518
522
  function setCellHyperlink(ctx, id, r, c, link) {
@@ -523,7 +527,7 @@ function setCellHyperlink(ctx, id, r, c, link) {
523
527
  ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)] = link;
524
528
  }
525
529
  function pasteHandlerOfCutPaste(ctx, copyRange) {
526
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
530
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
527
531
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
528
532
  if (!allowEdit || ctx.isFlvReadOnly) return;
529
533
  if (!copyRange) return;
@@ -566,6 +570,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
566
570
  if (addr > 0 || addc > 0) {
567
571
  (0, _sheet.expandRowsAndColumns)(d, addr, addc);
568
572
  }
573
+ var changes = [];
569
574
  var borderInfoCompute = (0, _border.getBorderInfoCompute)(ctx, copySheetId);
570
575
  var c_dataVerification = _lodash.default.cloneDeep(ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, copySheetId)].dataVerification) || {};
571
576
  var dataVerification = _lodash.default.cloneDeep(ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].dataVerification) || {};
@@ -597,6 +602,17 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
597
602
  delete cell.mc;
598
603
  }
599
604
  d[i][j] = null;
605
+ changes.push({
606
+ sheetId: ctx.currentSheetId,
607
+ path: ["celldata"],
608
+ value: {
609
+ r: i,
610
+ c: j,
611
+ v: null
612
+ },
613
+ key: "".concat(i, "_").concat(j),
614
+ type: "update"
615
+ });
600
616
  delete dataVerification["".concat(i, "_").concat(j)];
601
617
  (_f = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].hyperlink) === null || _f === void 0 ? true : delete _f["".concat(i, "_").concat(j)];
602
618
  }
@@ -696,6 +712,17 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
696
712
  value = copyData[h - minh][c - minc];
697
713
  }
698
714
  x[c] = _lodash.default.cloneDeep(value);
715
+ changes.push({
716
+ sheetId: ctx.currentSheetId,
717
+ path: ["celldata"],
718
+ value: {
719
+ r: h,
720
+ c: c,
721
+ v: d[h][c]
722
+ },
723
+ key: "".concat(h, "_").concat(c),
724
+ type: "update"
725
+ });
699
726
  if (value != null && copyHasMC && ((_k = x[c]) === null || _k === void 0 ? void 0 : _k.mc)) {
700
727
  if (x[c].mc.rs != null) {
701
728
  x[c].mc.r = h;
@@ -716,6 +743,9 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
716
743
  }
717
744
  last.row = [minh, maxh];
718
745
  last.column = [minc, maxc];
746
+ if (changes.length > 0 && ((_l = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc)) {
747
+ ctx.hooks.updateCellYdoc(changes);
748
+ }
719
749
  if (copyRowlChange) {}
720
750
  var source;
721
751
  var target;
@@ -798,7 +828,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
798
828
  }
799
829
  source_curCdformat[i].cellrange = emptyRange;
800
830
  if (emptyRange2.length > 0) {
801
- var ruleObj = (_l = source_curCdformat[i]) !== null && _l !== void 0 ? _l : {};
831
+ var ruleObj = (_m = source_curCdformat[i]) !== null && _m !== void 0 ? _m : {};
802
832
  ruleObj.cellrange = emptyRange2;
803
833
  ruleArr.push(ruleObj);
804
834
  }
@@ -902,7 +932,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
902
932
  }
903
933
  }
904
934
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
905
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
935
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
906
936
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
907
937
  if (!allowEdit || ctx.isFlvReadOnly) return;
908
938
  if (!copyRange) return;
@@ -993,6 +1023,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
993
1023
  if (addr > 0 || addc > 0) {
994
1024
  (0, _sheet.expandRowsAndColumns)(d, addr, addc);
995
1025
  }
1026
+ var changes = [];
996
1027
  var borderInfoCompute = (0, _border.getBorderInfoCompute)(ctx, copySheetIndex);
997
1028
  var c_dataVerification = _lodash.default.cloneDeep(ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, copySheetIndex)].dataVerification) || {};
998
1029
  var dataVerification = null;
@@ -1082,6 +1113,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1082
1113
  value.m = "Loading...";
1083
1114
  }
1084
1115
  }
1116
+ var afterHookCalled = false;
1085
1117
  if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
1086
1118
  var adjustedFormula = value.f;
1087
1119
  var isError = false;
@@ -1134,6 +1166,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1134
1166
  v: arr.length === 1 ? funcV[1] : value.v,
1135
1167
  m: funcV[1] instanceof Promise ? "[object Promise]" : funcV[1]
1136
1168
  }));
1169
+ afterHookCalled = true;
1137
1170
  }
1138
1171
  }
1139
1172
  if (!_lodash.default.isNil(value.spl)) {}
@@ -1154,6 +1187,19 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1154
1187
  };
1155
1188
  }
1156
1189
  }
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
+ }
1157
1203
  }
1158
1204
  d[h] = x;
1159
1205
  }
@@ -1165,7 +1211,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1165
1211
  var a_file = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)];
1166
1212
  var ruleArr_cf = _lodash.default.cloneDeep(c_file.luckysheet_conditionformat_save);
1167
1213
  if (!_lodash.default.isNil(ruleArr_cf) && ruleArr_cf.length > 0) {
1168
- 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 : [];
1169
1215
  for (var i = 0; i < ruleArr_cf.length; i += 1) {
1170
1216
  var cf_range = ruleArr_cf[i].cellrange;
1171
1217
  var emptyRange = [];
@@ -1201,8 +1247,8 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1201
1247
  file.config = cfg;
1202
1248
  file.luckysheet_conditionformat_save = cdformat;
1203
1249
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1204
- 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) {
1205
- 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);
1206
1252
  var targetSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1207
1253
  var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
1208
1254
  var srcData = ctx.luckysheetfile[srcIndex].data;
@@ -1213,7 +1259,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1213
1259
  var isSingleCell = copyh === 1 && copyc === 1;
1214
1260
  var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
1215
1261
  var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
1216
- 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;
1217
1263
  for (var th = 1; th <= timesH; th += 1) {
1218
1264
  for (var tc = 1; tc <= timesC; tc += 1) {
1219
1265
  var linkMth = minh + (th - 1) * copyh;
@@ -1233,7 +1279,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1233
1279
  if (!srcLink) continue;
1234
1280
  var targetKey = "".concat(h, "_").concat(c);
1235
1281
  targetHyperlinks[targetKey] = srcLink;
1236
- 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];
1237
1283
  if (cell) {
1238
1284
  var srcCell = void 0;
1239
1285
  if (isSingleCell && cachedSrcCell) {
@@ -1241,7 +1287,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1241
1287
  } else {
1242
1288
  var srcRow = c_r1 + (h - linkMth);
1243
1289
  var srcCol = c_c1 + (c - linkMtc);
1244
- 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];
1245
1291
  }
1246
1292
  cell.hl = {
1247
1293
  r: h,
@@ -1261,6 +1307,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1261
1307
  }
1262
1308
  }
1263
1309
  }
1310
+ if (changes.length > 0 && ((_t = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _t === void 0 ? void 0 : _t.updateCellYdoc)) {
1311
+ ctx.hooks.updateCellYdoc(changes);
1312
+ }
1264
1313
  if (copyRowlChange || addr > 0 || addc > 0) {
1265
1314
  (0, _refresh.jfrefreshgrid)(ctx, d, ctx.luckysheet_select_save);
1266
1315
  } else {
@@ -842,7 +842,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
842
842
  var newValue_1 = _lodash.default.cloneDeep(d[r][c]);
843
843
  setTimeout(function () {
844
844
  var _a, _b;
845
- return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
845
+ return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, oldValue_1, newValue_1);
846
846
  });
847
847
  }
848
848
  ctx.formulaCache.execFunctionGlobalData = null;
@@ -1295,13 +1295,16 @@ function keepOnlyValueParts(cell) {
1295
1295
  } : null;
1296
1296
  }
1297
1297
  function clearSelectedCellFormat(ctx) {
1298
+ var _a;
1298
1299
  var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1299
1300
  if (activeSheetIndex == null) return;
1301
+ var changeMap = new Map();
1300
1302
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1301
1303
  var selectedRanges = ctx.luckysheet_select_save;
1302
1304
  if (!activeSheetFile || !selectedRanges) return;
1303
1305
  var sheetData = activeSheetFile.data;
1304
1306
  selectedRanges.forEach(function (_a) {
1307
+ var _b;
1305
1308
  var rowRange = _a.row,
1306
1309
  columnRange = _a.column;
1307
1310
  var startRow = rowRange[0],
@@ -1314,20 +1317,38 @@ function clearSelectedCellFormat(ctx) {
1314
1317
  for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
1315
1318
  if (rowCells[columnIndex] === undefined) continue;
1316
1319
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1320
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1321
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1322
+ changeMap.set(key, {
1323
+ sheetId: ctx.currentSheetId,
1324
+ path: ["celldata"],
1325
+ key: key,
1326
+ value: {
1327
+ r: rowIndex,
1328
+ c: columnIndex,
1329
+ v: v
1330
+ },
1331
+ type: v == null ? "delete" : "update"
1332
+ });
1317
1333
  }
1318
1334
  }
1319
1335
  });
1336
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
1337
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1338
+ }
1320
1339
  }
1321
1340
  function clearRowsCellsFormat(ctx) {
1322
- var _a, _b;
1341
+ var _a, _b, _c;
1323
1342
  var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1324
1343
  if (activeSheetIndex == null) return;
1344
+ var changeMap = new Map();
1325
1345
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1326
1346
  var selectedRanges = ctx.luckysheet_select_save;
1327
1347
  if (!activeSheetFile || !selectedRanges) return;
1328
1348
  var sheetData = activeSheetFile.data;
1329
1349
  var columnCount = (_b = (_a = sheetData === null || sheetData === void 0 ? void 0 : sheetData[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
1330
1350
  selectedRanges.forEach(function (_a) {
1351
+ var _b;
1331
1352
  var rowRange = _a.row;
1332
1353
  var startRow = rowRange[0],
1333
1354
  endRow = rowRange[1];
@@ -1337,19 +1358,38 @@ function clearRowsCellsFormat(ctx) {
1337
1358
  for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
1338
1359
  if (rowCells[columnIndex] === undefined) continue;
1339
1360
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1361
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1362
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1363
+ changeMap.set(key, {
1364
+ sheetId: ctx.currentSheetId,
1365
+ path: ["celldata"],
1366
+ key: key,
1367
+ value: {
1368
+ r: rowIndex,
1369
+ c: columnIndex,
1370
+ v: v
1371
+ },
1372
+ type: v == null ? "delete" : "update"
1373
+ });
1340
1374
  }
1341
1375
  }
1342
1376
  });
1377
+ if (((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) && changeMap.size > 0) {
1378
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1379
+ }
1343
1380
  }
1344
1381
  function clearColumnsCellsFormat(ctx) {
1382
+ var _a;
1345
1383
  var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1346
1384
  if (activeSheetIndex == null) return;
1385
+ var changeMap = new Map();
1347
1386
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1348
1387
  var selectedRanges = ctx.luckysheet_select_save;
1349
1388
  if (!activeSheetFile || !selectedRanges) return;
1350
1389
  var sheetData = activeSheetFile.data;
1351
1390
  var rowCount = sheetData.length;
1352
1391
  selectedRanges.forEach(function (_a) {
1392
+ var _b;
1353
1393
  var columnRange = _a.column;
1354
1394
  var startColumn = columnRange[0],
1355
1395
  endColumn = columnRange[1];
@@ -1359,7 +1399,23 @@ function clearColumnsCellsFormat(ctx) {
1359
1399
  for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
1360
1400
  if (rowCells[columnIndex] === undefined) continue;
1361
1401
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1402
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1403
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1404
+ changeMap.set(key, {
1405
+ sheetId: ctx.currentSheetId,
1406
+ path: ["celldata"],
1407
+ key: key,
1408
+ value: {
1409
+ r: rowIndex,
1410
+ c: columnIndex,
1411
+ v: v
1412
+ },
1413
+ type: v == null ? "delete" : "update"
1414
+ });
1362
1415
  }
1363
1416
  }
1364
1417
  });
1418
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
1419
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1420
+ }
1365
1421
  }