@fileverse-dev/fortune-core 1.3.10-yjs-1 → 1.3.10-yjs-3

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.
@@ -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-1",
3
+ "version": "1.3.10-yjs-3",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",