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

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.
@@ -191,7 +191,7 @@ function setEditingComment(ctx, flowdata, r, c) {
191
191
  ctx.editingCommentBox = getCommentBoxByRC(ctx, flowdata, r, c);
192
192
  }
193
193
  function removeEditingComment(ctx, globalCache) {
194
- var _a, _b;
194
+ var _a, _b, _c;
195
195
  var editingCommentBoxEle = globalCache.editingCommentBoxEle;
196
196
  ctx.editingCommentBox = undefined;
197
197
  var r = editingCommentBoxEle === null || editingCommentBoxEle === void 0 ? void 0 : editingCommentBoxEle.dataset.r;
@@ -215,6 +215,19 @@ function removeEditingComment(ctx, globalCache) {
215
215
  return v.rc !== "".concat(r, "_").concat(c);
216
216
  });
217
217
  }
218
+ if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
219
+ ctx.hooks.updateCellYdoc([{
220
+ sheetId: ctx.currentSheetId,
221
+ path: ["celldata"],
222
+ value: {
223
+ r: r,
224
+ c: c,
225
+ v: cell
226
+ },
227
+ key: "".concat(r, "_").concat(c),
228
+ type: "update"
229
+ }]);
230
+ }
218
231
  if (ctx.hooks.afterUpdateComment) {
219
232
  setTimeout(function () {
220
233
  var _a, _b;
@@ -223,7 +236,7 @@ function removeEditingComment(ctx, globalCache) {
223
236
  }
224
237
  }
225
238
  function newComment(ctx, globalCache, r, c) {
226
- var _a, _b;
239
+ var _a, _b, _c, _d;
227
240
  if (((_b = (_a = ctx.hooks).beforeInsertComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
228
241
  return;
229
242
  }
@@ -248,6 +261,19 @@ function newComment(ctx, globalCache, r, c) {
248
261
  ctx.editingCommentBox = __assign(__assign({}, getCommentBoxByRC(ctx, flowdata, r, c)), {
249
262
  autoFocus: true
250
263
  });
264
+ if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
265
+ ctx.hooks.updateCellYdoc([{
266
+ sheetId: ctx.currentSheetId,
267
+ path: ["celldata"],
268
+ value: {
269
+ r: r,
270
+ c: c,
271
+ v: (_d = flowdata[r][c]) !== null && _d !== void 0 ? _d : null
272
+ },
273
+ key: "".concat(r, "_").concat(c),
274
+ type: "update"
275
+ }]);
276
+ }
251
277
  if (ctx.hooks.afterInsertComment) {
252
278
  setTimeout(function () {
253
279
  var _a, _b;
@@ -274,7 +300,7 @@ function editComment(ctx, globalCache, r, c) {
274
300
  }
275
301
  }
276
302
  function deleteComment(ctx, globalCache, r, c) {
277
- var _a, _b;
303
+ var _a, _b, _c;
278
304
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
279
305
  if (!allowEdit) return;
280
306
  if (((_b = (_a = ctx.hooks).beforeDeleteComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
@@ -285,6 +311,19 @@ function deleteComment(ctx, globalCache, r, c) {
285
311
  var cell = flowdata[r][c];
286
312
  if (!cell) return;
287
313
  cell.ps = undefined;
314
+ if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
315
+ ctx.hooks.updateCellYdoc([{
316
+ sheetId: ctx.currentSheetId,
317
+ path: ["celldata"],
318
+ value: {
319
+ r: r,
320
+ c: c,
321
+ v: cell
322
+ },
323
+ key: "".concat(r, "_").concat(c),
324
+ type: "update"
325
+ }]);
326
+ }
288
327
  if (ctx.hooks.afterDeleteComment) {
289
328
  setTimeout(function () {
290
329
  var _a, _b;
@@ -304,7 +343,7 @@ function showComments(ctx, commentShowCells) {
304
343
  }
305
344
  }
306
345
  function showHideComment(ctx, globalCache, r, c) {
307
- var _a;
346
+ var _a, _b, _c;
308
347
  var flowdata = (0, _context.getFlowdata)(ctx);
309
348
  var comment = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c]) === null || _a === void 0 ? void 0 : _a.ps;
310
349
  if (!comment) return;
@@ -318,9 +357,23 @@ function showHideComment(ctx, globalCache, r, c) {
318
357
  } else {
319
358
  comment.isShow = true;
320
359
  }
360
+ var cell = (_b = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _b === void 0 ? void 0 : _b[c];
361
+ if (cell && ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc)) {
362
+ ctx.hooks.updateCellYdoc([{
363
+ sheetId: ctx.currentSheetId,
364
+ path: ["celldata"],
365
+ value: {
366
+ r: r,
367
+ c: c,
368
+ v: cell
369
+ },
370
+ key: "".concat(r, "_").concat(c),
371
+ type: "update"
372
+ }]);
373
+ }
321
374
  }
322
375
  function showHideAllComments(ctx) {
323
- var _a, _b;
376
+ var _a, _b, _c, _d, _e;
324
377
  var flowdata = (0, _context.getFlowdata)(ctx);
325
378
  if (!flowdata) return;
326
379
  var isAllShow = true;
@@ -341,29 +394,55 @@ function showHideAllComments(ctx) {
341
394
  }
342
395
  var rcs = [];
343
396
  if (allComments.length > 0) {
397
+ var cellChanges = [];
344
398
  if (isAllShow) {
345
399
  for (var i = 0; i < allComments.length; i += 1) {
346
- var _c = allComments[i],
347
- r = _c.r,
348
- c = _c.c;
400
+ var _f = allComments[i],
401
+ r = _f.r,
402
+ c = _f.c;
349
403
  var comment = (_a = flowdata[r][c]) === null || _a === void 0 ? void 0 : _a.ps;
350
404
  if (comment === null || comment === void 0 ? void 0 : comment.isShow) {
351
405
  comment.isShow = false;
352
406
  rcs.push("".concat(r, "_").concat(c));
407
+ cellChanges.push({
408
+ sheetId: ctx.currentSheetId,
409
+ path: ["celldata"],
410
+ value: {
411
+ r: r,
412
+ c: c,
413
+ v: (_b = flowdata[r][c]) !== null && _b !== void 0 ? _b : null
414
+ },
415
+ key: "".concat(r, "_").concat(c),
416
+ type: "update"
417
+ });
353
418
  }
354
419
  }
355
420
  ctx.commentBoxes = [];
356
421
  } else {
357
422
  for (var i = 0; i < allComments.length; i += 1) {
358
- var _d = allComments[i],
359
- r = _d.r,
360
- c = _d.c;
361
- var comment = (_b = flowdata[r][c]) === null || _b === void 0 ? void 0 : _b.ps;
423
+ var _g = allComments[i],
424
+ r = _g.r,
425
+ c = _g.c;
426
+ var comment = (_c = flowdata[r][c]) === null || _c === void 0 ? void 0 : _c.ps;
362
427
  if (comment && !comment.isShow) {
363
428
  comment.isShow = true;
429
+ cellChanges.push({
430
+ sheetId: ctx.currentSheetId,
431
+ path: ["celldata"],
432
+ value: {
433
+ r: r,
434
+ c: c,
435
+ v: (_d = flowdata[r][c]) !== null && _d !== void 0 ? _d : null
436
+ },
437
+ key: "".concat(r, "_").concat(c),
438
+ type: "update"
439
+ });
364
440
  }
365
441
  }
366
442
  }
443
+ if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
444
+ ctx.hooks.updateCellYdoc(cellChanges);
445
+ }
367
446
  }
368
447
  }
369
448
  function removeOverShowComment(ctx) {
@@ -525,13 +604,13 @@ function onCommentBoxResize(ctx, globalCache, e) {
525
604
  return false;
526
605
  }
527
606
  function onCommentBoxResizeEnd(ctx, globalCache) {
528
- var _a;
607
+ var _a, _b;
529
608
  if ((_a = globalCache.commentBox) === null || _a === void 0 ? void 0 : _a.resizingId) {
530
- var _b = globalCache.commentBox,
531
- resizingId = _b.resizingId,
532
- _c = _b.commentRC,
533
- r = _c.r,
534
- c = _c.c;
609
+ var _c = globalCache.commentBox,
610
+ resizingId = _c.resizingId,
611
+ _d = _c.commentRC,
612
+ r = _d.r,
613
+ c = _d.c;
535
614
  globalCache.commentBox.resizingId = undefined;
536
615
  var position = getCommentBoxPosition(resizingId);
537
616
  if (position) {
@@ -547,6 +626,19 @@ function onCommentBoxResizeEnd(ctx, globalCache) {
547
626
  cell.ps.width = width / ctx.zoomRatio;
548
627
  cell.ps.height = height / ctx.zoomRatio;
549
628
  setEditingComment(ctx, flowdata, r, c);
629
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
630
+ ctx.hooks.updateCellYdoc([{
631
+ sheetId: ctx.currentSheetId,
632
+ path: ["celldata"],
633
+ value: {
634
+ r: r,
635
+ c: c,
636
+ v: cell
637
+ },
638
+ key: "".concat(r, "_").concat(c),
639
+ type: "update"
640
+ }]);
641
+ }
550
642
  }
551
643
  }
552
644
  }
@@ -598,13 +690,13 @@ function onCommentBoxMove(ctx, globalCache, e) {
598
690
  return false;
599
691
  }
600
692
  function onCommentBoxMoveEnd(ctx, globalCache) {
601
- var _a;
693
+ var _a, _b;
602
694
  if ((_a = globalCache.commentBox) === null || _a === void 0 ? void 0 : _a.movingId) {
603
- var _b = globalCache.commentBox,
604
- movingId = _b.movingId,
605
- _c = _b.commentRC,
606
- r = _c.r,
607
- c = _c.c;
695
+ var _c = globalCache.commentBox,
696
+ movingId = _c.movingId,
697
+ _d = _c.commentRC,
698
+ r = _d.r,
699
+ c = _d.c;
608
700
  globalCache.commentBox.movingId = undefined;
609
701
  var position = getCommentBoxPosition(movingId);
610
702
  if (position) {
@@ -616,6 +708,19 @@ function onCommentBoxMoveEnd(ctx, globalCache) {
616
708
  cell.ps.left = left / ctx.zoomRatio;
617
709
  cell.ps.top = top_5 / ctx.zoomRatio;
618
710
  setEditingComment(ctx, flowdata, r, c);
711
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
712
+ ctx.hooks.updateCellYdoc([{
713
+ sheetId: ctx.currentSheetId,
714
+ path: ["celldata"],
715
+ value: {
716
+ r: r,
717
+ c: c,
718
+ v: cell
719
+ },
720
+ key: "".concat(r, "_").concat(c),
721
+ type: "update"
722
+ }]);
723
+ }
619
724
  }
620
725
  }
621
726
  }
@@ -67,8 +67,63 @@ var refreshLocalMergeData = function refreshLocalMergeData(merge_new, file) {
67
67
  }
68
68
  });
69
69
  };
70
+ var getMergeBounds = function getMergeBounds(mergeMap) {
71
+ if (!mergeMap) return null;
72
+ var minR = Infinity;
73
+ var minC = Infinity;
74
+ var maxR = -Infinity;
75
+ var maxC = -Infinity;
76
+ Object.values(mergeMap).forEach(function (mc) {
77
+ var _a, _b;
78
+ if (!mc) return;
79
+ var r = Number(mc.r);
80
+ var c = Number(mc.c);
81
+ var rs = Number((_a = mc.rs) !== null && _a !== void 0 ? _a : 1);
82
+ var cs = Number((_b = mc.cs) !== null && _b !== void 0 ? _b : 1);
83
+ if (!Number.isFinite(r) || !Number.isFinite(c)) return;
84
+ minR = Math.min(minR, r);
85
+ minC = Math.min(minC, c);
86
+ maxR = Math.max(maxR, r + Math.max(1, rs) - 1);
87
+ maxC = Math.max(maxC, c + Math.max(1, cs) - 1);
88
+ });
89
+ if (minR === Infinity) return null;
90
+ return {
91
+ minR: minR,
92
+ minC: minC,
93
+ maxR: maxR,
94
+ maxC: maxC
95
+ };
96
+ };
97
+ var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2, c1, c2) {
98
+ var _a, _b, _c, _d;
99
+ if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) return;
100
+ if (!d || !Array.isArray(d) || d.length === 0) return;
101
+ var rowEnd = Math.min(r2, d.length - 1);
102
+ var colEnd = Math.min(c2, ((_c = (_b = d[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) - 1);
103
+ var rowStart = Math.max(0, r1);
104
+ var colStart = Math.max(0, c1);
105
+ if (rowStart > rowEnd || colStart > colEnd) return;
106
+ var changes = [];
107
+ for (var r = rowStart; r <= rowEnd; r += 1) {
108
+ var row = d[r] || [];
109
+ for (var c = colStart; c <= colEnd; c += 1) {
110
+ changes.push({
111
+ sheetId: sheetId,
112
+ path: ["celldata"],
113
+ value: {
114
+ r: r,
115
+ c: c,
116
+ v: (_d = row === null || row === void 0 ? void 0 : row[c]) !== null && _d !== void 0 ? _d : null
117
+ },
118
+ key: "".concat(r, "_").concat(c),
119
+ type: "update"
120
+ });
121
+ }
122
+ }
123
+ if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
124
+ };
70
125
  function insertRowCol(ctx, op, changeSelection) {
71
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
126
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
72
127
  if (changeSelection === void 0) {
73
128
  changeSelection = true;
74
129
  }
@@ -1033,9 +1088,22 @@ function insertRowCol(ctx, op, changeSelection) {
1033
1088
  }
1034
1089
  }
1035
1090
  refreshLocalMergeData(merge_new, file);
1091
+ var mergeBounds = getMergeBounds(cfg.merge);
1092
+ if (type === "row") {
1093
+ var baseStart = direction === "lefttop" ? index : index + 1;
1094
+ var startR = mergeBounds ? Math.min(baseStart, mergeBounds.minR) : baseStart;
1095
+ emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_y = (_x = d[0]) === null || _x === void 0 ? void 0 : _x.length) !== null && _y !== void 0 ? _y : 1) - 1);
1096
+ } else {
1097
+ var baseStart = direction === "lefttop" ? index : index + 1;
1098
+ var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
1099
+ emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_0 = (_z = d[0]) === null || _z === void 0 ? void 0 : _z.length) !== null && _0 !== void 0 ? _0 : 1) - 1);
1100
+ }
1101
+ if ((_1 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _1 === void 0 ? void 0 : _1.updateAllCell) {
1102
+ ctx.hooks.updateAllCell(id);
1103
+ }
1036
1104
  }
1037
1105
  function deleteRowCol(ctx, op) {
1038
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
1039
1107
  var type = op.type;
1040
1108
  var start = op.start,
1041
1109
  end = op.end,
@@ -1755,6 +1823,17 @@ function deleteRowCol(ctx, op) {
1755
1823
  file.dataVerification = newDataVerification;
1756
1824
  file.hyperlink = newHyperlink;
1757
1825
  refreshLocalMergeData(merge_new, file);
1826
+ var mergeBounds = getMergeBounds(cfg.merge);
1827
+ if (type === "row") {
1828
+ var startR = mergeBounds ? Math.min(start, mergeBounds.minR) : start;
1829
+ emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_s = (_r = d[0]) === null || _r === void 0 ? void 0 : _r.length) !== null && _s !== void 0 ? _s : 1) - 1);
1830
+ } else {
1831
+ var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
1832
+ emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_u = (_t = d[0]) === null || _t === void 0 ? void 0 : _t.length) !== null && _u !== void 0 ? _u : 1) - 1);
1833
+ }
1834
+ if ((_v = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _v === void 0 ? void 0 : _v.updateAllCell) {
1835
+ ctx.hooks.updateAllCell(id);
1836
+ }
1758
1837
  if (file.id === ctx.currentSheetId) {
1759
1838
  ctx.config = cfg;
1760
1839
  } else {}
@@ -215,7 +215,7 @@ function selectTitlesRange(map) {
215
215
  return rangeArr;
216
216
  }
217
217
  function pasteHandlerOfPaintModel(ctx, copyRange) {
218
- var _a;
218
+ var _a, _b, _c;
219
219
  var cfg = ctx.config;
220
220
  if (cfg.merge == null) {
221
221
  cfg.merge = {};
@@ -254,6 +254,7 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
254
254
  var timesC = Math.ceil((maxc - minc + 1) / copyc);
255
255
  var flowdata = (0, _context.getFlowdata)(ctx);
256
256
  if (flowdata == null) return;
257
+ var cellChanges = [];
257
258
  var cellMaxLength = flowdata[0].length;
258
259
  var rowMaxLength = flowdata.length;
259
260
  var borderInfoCompute = (0, _border.getBorderInfoCompute)(ctx, copySheetIndex);
@@ -391,6 +392,17 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
391
392
  }
392
393
  }
393
394
  }
395
+ cellChanges.push({
396
+ sheetId: ctx.currentSheetId,
397
+ path: ["celldata"],
398
+ value: {
399
+ r: h,
400
+ c: c,
401
+ v: (_a = x[c]) !== null && _a !== void 0 ? _a : null
402
+ },
403
+ key: "".concat(h, "_").concat(c),
404
+ type: "update"
405
+ });
394
406
  };
395
407
  for (var c = mtc; c < maxcellCahe; c += 1) {
396
408
  _loop_2(c);
@@ -403,6 +415,9 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
403
415
  }
404
416
  }
405
417
  }
418
+ if (cellChanges.length > 0 && ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc)) {
419
+ ctx.hooks.updateCellYdoc(cellChanges);
420
+ }
406
421
  var currFile = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)];
407
422
  currFile.config = cfg;
408
423
  if (dataVerification != null) {
@@ -414,7 +429,7 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
414
429
  if (!_lodash.default.isNil(ruleArr) && ruleArr.length > 0) {
415
430
  var currentIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
416
431
  var existingCf = ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save;
417
- var cdformat = (_a = _lodash.default.cloneDeep(existingCf)) !== null && _a !== void 0 ? _a : [];
432
+ var cdformat = (_c = _lodash.default.cloneDeep(existingCf)) !== null && _c !== void 0 ? _c : [];
418
433
  for (var i = 0; i < ruleArr.length; i += 1) {
419
434
  var cdformat_cellrange = ruleArr[i].cellrange;
420
435
  var emptyRange = [];
@@ -1536,7 +1551,7 @@ function copy(ctx) {
1536
1551
  }
1537
1552
  }
1538
1553
  function deleteSelectedCellText(ctx) {
1539
- var _a, _b, _c, _d;
1554
+ var _a, _b, _c, _d, _e;
1540
1555
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1541
1556
  if (allowEdit === false || ctx.isFlvReadOnly) {
1542
1557
  return "allowEdit";
@@ -1546,6 +1561,7 @@ function deleteSelectedCellText(ctx) {
1546
1561
  var d = (0, _context.getFlowdata)(ctx);
1547
1562
  if (!d) return "dataNullError";
1548
1563
  var has_PartMC = false;
1564
+ var cellChanges = [];
1549
1565
  for (var s = 0; s < selection.length; s += 1) {
1550
1566
  var r1 = selection[s].row[0];
1551
1567
  var r2 = selection[s].row[1];
@@ -1606,15 +1622,21 @@ function deleteSelectedCellText(ctx) {
1606
1622
  r: r,
1607
1623
  c: c,
1608
1624
  v: d[r][c]
1609
- }
1625
+ },
1626
+ key: "".concat(r, "_").concat(c),
1627
+ type: "update"
1610
1628
  });
1611
1629
  }
1612
1630
  }
1631
+ if (changes.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
1632
+ ctx.hooks.updateCellYdoc(changes);
1633
+ }
1613
1634
  }
1614
1635
  }
1615
1636
  return "success";
1616
1637
  }
1617
1638
  function deleteSelectedCellFormat(ctx) {
1639
+ var _a;
1618
1640
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1619
1641
  if (allowEdit === false) {
1620
1642
  return "allowEdit";
@@ -1637,6 +1659,7 @@ function deleteSelectedCellFormat(ctx) {
1637
1659
  if (has_PartMC) {
1638
1660
  return "partMC";
1639
1661
  }
1662
+ var cellChanges = [];
1640
1663
  for (var s = 0; s < selection.length; s += 1) {
1641
1664
  var r1 = selection[s].row[0];
1642
1665
  var r2 = selection[s].row[1];
@@ -1655,10 +1678,24 @@ function deleteSelectedCellFormat(ctx) {
1655
1678
  delete cell.bg;
1656
1679
  delete cell.tb;
1657
1680
  }
1681
+ cellChanges.push({
1682
+ sheetId: ctx.currentSheetId,
1683
+ path: ["celldata"],
1684
+ value: {
1685
+ r: r,
1686
+ c: c,
1687
+ v: d[r][c]
1688
+ },
1689
+ key: "".concat(r, "_").concat(c),
1690
+ type: "update"
1691
+ });
1658
1692
  }
1659
1693
  }
1660
1694
  }
1661
1695
  }
1696
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
1697
+ ctx.hooks.updateCellYdoc(cellChanges);
1698
+ }
1662
1699
  }
1663
1700
  return "success";
1664
1701
  }
@@ -153,32 +153,53 @@ function sortSelection(ctx, isAsc, colIndex) {
153
153
  sortDataRange(ctx, d, data, colIndex, isAsc, str, edr, c1, c2);
154
154
  }
155
155
  function createRowsOrColumnsForSpilledValues(ctx, startRow, startColumn, spillRows, spillCols) {
156
+ var _a, _b;
156
157
  var flowdata = (0, _2.getFlowdata)(ctx);
157
158
  if (!flowdata) return;
159
+ var cellChanges = [];
158
160
  try {
159
161
  var sheetIndex = (0, _2.getSheetIndex)(ctx, ctx.currentSheetId);
160
162
  var sheet = ctx.luckysheetfile[sheetIndex];
161
- var requiredRowCount = startRow + spillRows;
162
- var requiredColCount = startColumn + spillCols;
163
- if (sheet.row && sheet.row < requiredRowCount) {
164
- sheet.row = requiredRowCount;
163
+ var requiredRowCount_1 = startRow + spillRows;
164
+ var requiredColCount_1 = startColumn + spillCols;
165
+ if (sheet.row && sheet.row < requiredRowCount_1) {
166
+ sheet.row = requiredRowCount_1;
165
167
  }
166
- if (sheet.column && sheet.column < requiredColCount) {
167
- sheet.column = requiredColCount;
168
+ if (sheet.column && sheet.column < requiredColCount_1) {
169
+ sheet.column = requiredColCount_1;
168
170
  }
169
171
  } catch (error) {
170
172
  console.error("Failed to update sheet metadata for spill operation", error);
171
173
  }
172
- while (flowdata.length < startRow + spillRows) {
174
+ var requiredRowCount = startRow + spillRows;
175
+ var requiredColCount = startColumn + spillCols;
176
+ while (flowdata.length < requiredRowCount) {
173
177
  flowdata.push([]);
174
178
  }
175
- for (var rowIndex = startRow; rowIndex < startRow + spillRows; rowIndex++) {
179
+ for (var rowIndex = startRow; rowIndex < requiredRowCount; rowIndex++) {
176
180
  if (!Array.isArray(flowdata[rowIndex])) {
177
181
  flowdata[rowIndex] = [];
178
182
  }
179
- while (flowdata[rowIndex].length < startColumn + spillCols) {
183
+ var prevLen = flowdata[rowIndex].length;
184
+ while (flowdata[rowIndex].length < requiredColCount) {
180
185
  flowdata[rowIndex].push(null);
181
186
  }
187
+ for (var c = Math.max(prevLen, startColumn); c < requiredColCount; c += 1) {
188
+ cellChanges.push({
189
+ sheetId: ctx.currentSheetId,
190
+ path: ["celldata"],
191
+ value: {
192
+ r: rowIndex,
193
+ c: c,
194
+ v: (_a = flowdata[rowIndex][c]) !== null && _a !== void 0 ? _a : null
195
+ },
196
+ key: "".concat(rowIndex, "_").concat(c),
197
+ type: "update"
198
+ });
199
+ }
200
+ }
201
+ if (cellChanges.length > 0 && ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc)) {
202
+ ctx.hooks.updateCellYdoc(cellChanges);
182
203
  }
183
204
  }
184
205
  function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
package/lib/settings.d.ts CHANGED
@@ -19,6 +19,7 @@ export type Hooks = {
19
19
  cellDataChange?: () => void;
20
20
  hyperlinkChange?: () => void;
21
21
  updateCellYdoc?: (changes: SheetChangePath[]) => void;
22
+ updateAllCell?: (sheetId: string) => void;
22
23
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
23
24
  afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
24
25
  afterSelectionChange?: (sheetId: string, selection: Selection) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.10-yjs",
3
+ "version": "1.3.10-yjs-2",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",