@fileverse-dev/fortune-react 1.3.10-test → 1.3.10-yjs-1

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.
@@ -211,7 +211,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
211
211
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
212
212
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
213
213
  setContext(function (draft) {
214
- var _a, _b, _c, _d, _e, _f, _g;
214
+ var _a, _b, _c, _d, _e, _f, _g, _h;
215
215
  var _sheet = draft.luckysheetfile[sheetIdx_1];
216
216
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
217
217
  var rows = _sheet.data;
@@ -374,6 +374,30 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
374
374
  }
375
375
  });
376
376
  (_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
377
+ var cellChanges = [];
378
+ var affectedColStart = Math.min(sourceIndex_1, targetIndex);
379
+ var affectedColEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceCol.length - 1;
380
+ var numRows = rows.length;
381
+ for (var r = 0; r < numRows; r += 1) {
382
+ var row = rows[r];
383
+ for (var c = affectedColStart; c <= affectedColEnd; c += 1) {
384
+ var cell = row === null || row === void 0 ? void 0 : row[c];
385
+ cellChanges.push({
386
+ sheetId: draft.currentSheetId,
387
+ path: ["celldata"],
388
+ value: {
389
+ r: r,
390
+ c: c,
391
+ v: cell !== null && cell !== void 0 ? cell : null
392
+ },
393
+ key: "".concat(r, "_").concat(c),
394
+ type: "update"
395
+ });
396
+ }
397
+ }
398
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
399
+ draft.hooks.updateCellYdoc(cellChanges);
400
+ }
377
401
  var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
378
402
  api.setSelection(draft, [{
379
403
  row: [0, rowLen],
@@ -207,7 +207,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
207
207
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
208
208
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
209
209
  setContext(function (draft) {
210
- var _a, _b, _c, _d, _e, _f;
210
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
211
211
  var _sheet = draft.luckysheetfile[sheetIdx_1];
212
212
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
213
213
  var rows = _sheet.data;
@@ -364,7 +364,31 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
364
364
  }
365
365
  });
366
366
  (_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
367
- var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
367
+ var cellChanges = [];
368
+ var affectedRowStart = Math.min(sourceIndex_1, targetIndex);
369
+ var affectedRowEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceRow.length - 1;
370
+ var numCols = (_g = (_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
371
+ for (var r = affectedRowStart; r <= affectedRowEnd; r += 1) {
372
+ var row = rows[r];
373
+ for (var c = 0; c < numCols; c += 1) {
374
+ var cell = row === null || row === void 0 ? void 0 : row[c];
375
+ cellChanges.push({
376
+ sheetId: draft.currentSheetId,
377
+ path: ["celldata"],
378
+ value: {
379
+ r: r,
380
+ c: c,
381
+ v: cell !== null && cell !== void 0 ? cell : null
382
+ },
383
+ key: "".concat(r, "_").concat(c),
384
+ type: "update"
385
+ });
386
+ }
387
+ }
388
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
389
+ draft.hooks.updateCellYdoc(cellChanges);
390
+ }
391
+ var colLen = ((_j = d === null || d === void 0 ? void 0 : d[0]) === null || _j === void 0 ? void 0 : _j.length) || 0;
368
392
  api.setSelection(draft, [{
369
393
  row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
370
394
  column: [0, colLen]
@@ -219,7 +219,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
219
219
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
220
220
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
221
221
  setContext(function (draft) {
222
- var _a, _b, _c, _d, _e, _f, _g;
222
+ var _a, _b, _c, _d, _e, _f, _g, _h;
223
223
  var _sheet = draft.luckysheetfile[sheetIdx_1];
224
224
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
225
225
  var rows = _sheet.data;
@@ -382,6 +382,30 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
382
382
  }
383
383
  });
384
384
  (_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
385
+ var cellChanges = [];
386
+ var affectedColStart = Math.min(sourceIndex_1, targetIndex);
387
+ var affectedColEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceCol.length - 1;
388
+ var numRows = rows.length;
389
+ for (var r = 0; r < numRows; r += 1) {
390
+ var row = rows[r];
391
+ for (var c = affectedColStart; c <= affectedColEnd; c += 1) {
392
+ var cell = row === null || row === void 0 ? void 0 : row[c];
393
+ cellChanges.push({
394
+ sheetId: draft.currentSheetId,
395
+ path: ["celldata"],
396
+ value: {
397
+ r: r,
398
+ c: c,
399
+ v: cell !== null && cell !== void 0 ? cell : null
400
+ },
401
+ key: "".concat(r, "_").concat(c),
402
+ type: "update"
403
+ });
404
+ }
405
+ }
406
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
407
+ draft.hooks.updateCellYdoc(cellChanges);
408
+ }
385
409
  var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
386
410
  _fortuneCore.api.setSelection(draft, [{
387
411
  row: [0, rowLen],
@@ -214,7 +214,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
214
214
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
215
215
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
216
216
  setContext(function (draft) {
217
- var _a, _b, _c, _d, _e, _f;
217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
218
218
  var _sheet = draft.luckysheetfile[sheetIdx_1];
219
219
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
220
220
  var rows = _sheet.data;
@@ -371,7 +371,31 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
371
371
  }
372
372
  });
373
373
  (_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
374
- var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
374
+ var cellChanges = [];
375
+ var affectedRowStart = Math.min(sourceIndex_1, targetIndex);
376
+ var affectedRowEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceRow.length - 1;
377
+ var numCols = (_g = (_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
378
+ for (var r = affectedRowStart; r <= affectedRowEnd; r += 1) {
379
+ var row = rows[r];
380
+ for (var c = 0; c < numCols; c += 1) {
381
+ var cell = row === null || row === void 0 ? void 0 : row[c];
382
+ cellChanges.push({
383
+ sheetId: draft.currentSheetId,
384
+ path: ["celldata"],
385
+ value: {
386
+ r: r,
387
+ c: c,
388
+ v: cell !== null && cell !== void 0 ? cell : null
389
+ },
390
+ key: "".concat(r, "_").concat(c),
391
+ type: "update"
392
+ });
393
+ }
394
+ }
395
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
396
+ draft.hooks.updateCellYdoc(cellChanges);
397
+ }
398
+ var colLen = ((_j = d === null || d === void 0 ? void 0 : d[0]) === null || _j === void 0 ? void 0 : _j.length) || 0;
375
399
  _fortuneCore.api.setSelection(draft, [{
376
400
  row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
377
401
  column: [0, colLen]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.10-test",
3
+ "version": "1.3.10-yjs-1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.3.10-test",
19
+ "@fileverse-dev/fortune-core": "1.3.10-yjs-1",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",