@fileverse-dev/fortune-core 1.3.10-yjs-6 → 1.3.10-yjs-8

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/sheet.js CHANGED
@@ -13,7 +13,7 @@ import _ from "lodash";
13
13
  import { v4 as uuidv4 } from "uuid";
14
14
  import { dataToCelldata, getSheet } from "./common";
15
15
  import { getSheetIndex } from "../utils";
16
- import { api, execfunction, getFlowdata, insertUpdateFunctionGroup, locale, spillSortResult } from "..";
16
+ import { api, changeSheet, execfunction, getFlowdata, insertUpdateFunctionGroup, locale, spillSortResult } from "..";
17
17
  function isCellReferenced(formulaString, cell) {
18
18
  function colToNumber(col) {
19
19
  var num = 0;
@@ -183,6 +183,7 @@ export function copySheet(ctx, sheetId) {
183
183
  var sheetOrderList = {};
184
184
  sheetOrderList[newSheetId] = order;
185
185
  api.setSheetOrder(ctx, sheetOrderList);
186
+ changeSheet(ctx, newSheetId, undefined, true, true);
186
187
  if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateAllCell) {
187
188
  ctx.hooks.updateAllCell(newSheetId);
188
189
  } else if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
@@ -380,7 +380,7 @@ export function handleArrowKey(ctx, e) {
380
380
  export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
381
381
  var _a, _b, _c;
382
382
  return __awaiter(this, void 0, void 0, function () {
383
- var kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
383
+ var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
384
384
  return __generator(this, function (_d) {
385
385
  if (e.shiftKey && e.code === "Space") {
386
386
  e.stopImmediatePropagation();
@@ -388,27 +388,41 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
388
388
  e.preventDefault();
389
389
  return [2];
390
390
  }
391
+ handledFlvShortcut = false;
391
392
  if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyE") {
392
393
  textFormat(ctx, "center");
394
+ handledFlvShortcut = true;
393
395
  } else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
394
396
  textFormat(ctx, "left");
397
+ handledFlvShortcut = true;
395
398
  } else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
396
399
  textFormat(ctx, "right");
400
+ handledFlvShortcut = true;
397
401
  }
398
402
  if ((e.metaKey || e.ctrlKey) && e.code === "KeyK") {
399
403
  handleLink(ctx, cellInput);
400
404
  }
401
405
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "Semicolon") {
402
406
  fillDate(ctx);
407
+ handledFlvShortcut = true;
403
408
  }
404
409
  if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.code === "Semicolon") {
405
410
  fillTime(ctx);
411
+ handledFlvShortcut = true;
406
412
  }
407
413
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "KeyR") {
408
414
  fillRightData(ctx);
415
+ handledFlvShortcut = true;
409
416
  }
410
417
  if ((e.metaKey || e.ctrlKey) && e.code === "KeyD") {
411
418
  fillDownData(ctx);
419
+ handledFlvShortcut = true;
420
+ }
421
+ if (handledFlvShortcut) {
422
+ jfrefreshgrid(ctx, null, undefined);
423
+ e.stopPropagation();
424
+ e.preventDefault();
425
+ return [2];
412
426
  }
413
427
  ctx.luckysheet_select_status = false;
414
428
  kcode = e.keyCode;
@@ -1262,13 +1262,16 @@ function keepOnlyValueParts(cell) {
1262
1262
  } : null;
1263
1263
  }
1264
1264
  export function clearSelectedCellFormat(ctx) {
1265
+ var _a;
1265
1266
  var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1266
1267
  if (activeSheetIndex == null) return;
1268
+ var changeMap = new Map();
1267
1269
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1268
1270
  var selectedRanges = ctx.luckysheet_select_save;
1269
1271
  if (!activeSheetFile || !selectedRanges) return;
1270
1272
  var sheetData = activeSheetFile.data;
1271
1273
  selectedRanges.forEach(function (_a) {
1274
+ var _b;
1272
1275
  var rowRange = _a.row,
1273
1276
  columnRange = _a.column;
1274
1277
  var startRow = rowRange[0],
@@ -1281,20 +1284,38 @@ export function clearSelectedCellFormat(ctx) {
1281
1284
  for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
1282
1285
  if (rowCells[columnIndex] === undefined) continue;
1283
1286
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1287
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1288
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1289
+ changeMap.set(key, {
1290
+ sheetId: ctx.currentSheetId,
1291
+ path: ["celldata"],
1292
+ key: key,
1293
+ value: {
1294
+ r: rowIndex,
1295
+ c: columnIndex,
1296
+ v: v
1297
+ },
1298
+ type: v == null ? "delete" : "update"
1299
+ });
1284
1300
  }
1285
1301
  }
1286
1302
  });
1303
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
1304
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1305
+ }
1287
1306
  }
1288
1307
  export function clearRowsCellsFormat(ctx) {
1289
- var _a, _b;
1308
+ var _a, _b, _c;
1290
1309
  var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1291
1310
  if (activeSheetIndex == null) return;
1311
+ var changeMap = new Map();
1292
1312
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1293
1313
  var selectedRanges = ctx.luckysheet_select_save;
1294
1314
  if (!activeSheetFile || !selectedRanges) return;
1295
1315
  var sheetData = activeSheetFile.data;
1296
1316
  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;
1297
1317
  selectedRanges.forEach(function (_a) {
1318
+ var _b;
1298
1319
  var rowRange = _a.row;
1299
1320
  var startRow = rowRange[0],
1300
1321
  endRow = rowRange[1];
@@ -1304,19 +1325,38 @@ export function clearRowsCellsFormat(ctx) {
1304
1325
  for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
1305
1326
  if (rowCells[columnIndex] === undefined) continue;
1306
1327
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1328
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1329
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1330
+ changeMap.set(key, {
1331
+ sheetId: ctx.currentSheetId,
1332
+ path: ["celldata"],
1333
+ key: key,
1334
+ value: {
1335
+ r: rowIndex,
1336
+ c: columnIndex,
1337
+ v: v
1338
+ },
1339
+ type: v == null ? "delete" : "update"
1340
+ });
1307
1341
  }
1308
1342
  }
1309
1343
  });
1344
+ if (((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) && changeMap.size > 0) {
1345
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1346
+ }
1310
1347
  }
1311
1348
  export function clearColumnsCellsFormat(ctx) {
1349
+ var _a;
1312
1350
  var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1313
1351
  if (activeSheetIndex == null) return;
1352
+ var changeMap = new Map();
1314
1353
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1315
1354
  var selectedRanges = ctx.luckysheet_select_save;
1316
1355
  if (!activeSheetFile || !selectedRanges) return;
1317
1356
  var sheetData = activeSheetFile.data;
1318
1357
  var rowCount = sheetData.length;
1319
1358
  selectedRanges.forEach(function (_a) {
1359
+ var _b;
1320
1360
  var columnRange = _a.column;
1321
1361
  var startColumn = columnRange[0],
1322
1362
  endColumn = columnRange[1];
@@ -1326,7 +1366,23 @@ export function clearColumnsCellsFormat(ctx) {
1326
1366
  for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
1327
1367
  if (rowCells[columnIndex] === undefined) continue;
1328
1368
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1369
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1370
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1371
+ changeMap.set(key, {
1372
+ sheetId: ctx.currentSheetId,
1373
+ path: ["celldata"],
1374
+ key: key,
1375
+ value: {
1376
+ r: rowIndex,
1377
+ c: columnIndex,
1378
+ v: v
1379
+ },
1380
+ type: v == null ? "delete" : "update"
1381
+ });
1329
1382
  }
1330
1383
  }
1331
1384
  });
1385
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
1386
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1387
+ }
1332
1388
  }
@@ -2000,6 +2000,7 @@ export function fillDownData(ctx) {
2000
2000
  return "success";
2001
2001
  }
2002
2002
  export function textFormat(ctx, type) {
2003
+ var _a;
2003
2004
  var allowEdit = isAllowEdit(ctx);
2004
2005
  if (allowEdit === false) {
2005
2006
  return "allowEdit";
@@ -2008,6 +2009,7 @@ export function textFormat(ctx, type) {
2008
2009
  if (selection && !_.isEmpty(selection)) {
2009
2010
  var d = getFlowdata(ctx);
2010
2011
  if (!d) return "dataNullError";
2012
+ var cellChanges = [];
2011
2013
  var has_PartMC = false;
2012
2014
  for (var s = 0; s < selection.length; s += 1) {
2013
2015
  var r1 = selection[s].row[0];
@@ -2041,14 +2043,29 @@ export function textFormat(ctx, type) {
2041
2043
  cell.tb = "1";
2042
2044
  cell.ht = 2;
2043
2045
  }
2046
+ cellChanges.push({
2047
+ sheetId: ctx.currentSheetId,
2048
+ path: ["celldata"],
2049
+ value: {
2050
+ r: r,
2051
+ c: c,
2052
+ v: d[r][c]
2053
+ },
2054
+ key: "".concat(r, "_").concat(c),
2055
+ type: "update"
2056
+ });
2044
2057
  }
2045
2058
  }
2046
2059
  }
2047
2060
  }
2061
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
2062
+ ctx.hooks.updateCellYdoc(cellChanges);
2063
+ }
2048
2064
  }
2049
2065
  return "success";
2050
2066
  }
2051
2067
  export function fillDate(ctx) {
2068
+ var _a;
2052
2069
  var allowEdit = isAllowEdit(ctx);
2053
2070
  if (allowEdit === false) {
2054
2071
  return "allowEdit";
@@ -2057,6 +2074,7 @@ export function fillDate(ctx) {
2057
2074
  if (selection && !_.isEmpty(selection)) {
2058
2075
  var d = getFlowdata(ctx);
2059
2076
  if (!d) return "dataNullError";
2077
+ var cellChanges = [];
2060
2078
  var has_PartMC = false;
2061
2079
  for (var s = 0; s < selection.length; s += 1) {
2062
2080
  var r1 = selection[s].row[0];
@@ -2083,13 +2101,28 @@ export function fillDate(ctx) {
2083
2101
  d[r][c] = {
2084
2102
  v: formattedDate
2085
2103
  };
2104
+ cellChanges.push({
2105
+ sheetId: ctx.currentSheetId,
2106
+ path: ["celldata"],
2107
+ value: {
2108
+ r: r,
2109
+ c: c,
2110
+ v: d[r][c]
2111
+ },
2112
+ key: "".concat(r, "_").concat(c),
2113
+ type: "update"
2114
+ });
2086
2115
  }
2087
2116
  }
2088
2117
  }
2118
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
2119
+ ctx.hooks.updateCellYdoc(cellChanges);
2120
+ }
2089
2121
  }
2090
2122
  return "success";
2091
2123
  }
2092
2124
  export function fillTime(ctx) {
2125
+ var _a;
2093
2126
  var allowEdit = isAllowEdit(ctx);
2094
2127
  if (allowEdit === false) {
2095
2128
  return "allowEdit";
@@ -2098,6 +2131,7 @@ export function fillTime(ctx) {
2098
2131
  if (selection && !_.isEmpty(selection)) {
2099
2132
  var d = getFlowdata(ctx);
2100
2133
  if (!d) return "dataNullError";
2134
+ var cellChanges = [];
2101
2135
  var has_PartMC = false;
2102
2136
  for (var s = 0; s < selection.length; s += 1) {
2103
2137
  var r1 = selection[s].row[0];
@@ -2124,9 +2158,23 @@ export function fillTime(ctx) {
2124
2158
  d[r][c] = {
2125
2159
  v: formattedTime
2126
2160
  };
2161
+ cellChanges.push({
2162
+ sheetId: ctx.currentSheetId,
2163
+ path: ["celldata"],
2164
+ value: {
2165
+ r: r,
2166
+ c: c,
2167
+ v: d[r][c]
2168
+ },
2169
+ key: "".concat(r, "_").concat(c),
2170
+ type: "update"
2171
+ });
2127
2172
  }
2128
2173
  }
2129
2174
  }
2175
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
2176
+ ctx.hooks.updateCellYdoc(cellChanges);
2177
+ }
2130
2178
  }
2131
2179
  return "success";
2132
2180
  }
package/lib/api/sheet.js CHANGED
@@ -201,6 +201,7 @@ 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);
204
205
  if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateAllCell) {
205
206
  ctx.hooks.updateAllCell(newSheetId);
206
207
  } else if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
@@ -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;
@@ -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
  }
@@ -2035,6 +2035,7 @@ function fillDownData(ctx) {
2035
2035
  return "success";
2036
2036
  }
2037
2037
  function textFormat(ctx, type) {
2038
+ var _a;
2038
2039
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
2039
2040
  if (allowEdit === false) {
2040
2041
  return "allowEdit";
@@ -2043,6 +2044,7 @@ function textFormat(ctx, type) {
2043
2044
  if (selection && !_lodash.default.isEmpty(selection)) {
2044
2045
  var d = (0, _context.getFlowdata)(ctx);
2045
2046
  if (!d) return "dataNullError";
2047
+ var cellChanges = [];
2046
2048
  var has_PartMC = false;
2047
2049
  for (var s = 0; s < selection.length; s += 1) {
2048
2050
  var r1 = selection[s].row[0];
@@ -2076,14 +2078,29 @@ function textFormat(ctx, type) {
2076
2078
  cell.tb = "1";
2077
2079
  cell.ht = 2;
2078
2080
  }
2081
+ cellChanges.push({
2082
+ sheetId: ctx.currentSheetId,
2083
+ path: ["celldata"],
2084
+ value: {
2085
+ r: r,
2086
+ c: c,
2087
+ v: d[r][c]
2088
+ },
2089
+ key: "".concat(r, "_").concat(c),
2090
+ type: "update"
2091
+ });
2079
2092
  }
2080
2093
  }
2081
2094
  }
2082
2095
  }
2096
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
2097
+ ctx.hooks.updateCellYdoc(cellChanges);
2098
+ }
2083
2099
  }
2084
2100
  return "success";
2085
2101
  }
2086
2102
  function fillDate(ctx) {
2103
+ var _a;
2087
2104
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
2088
2105
  if (allowEdit === false) {
2089
2106
  return "allowEdit";
@@ -2092,6 +2109,7 @@ function fillDate(ctx) {
2092
2109
  if (selection && !_lodash.default.isEmpty(selection)) {
2093
2110
  var d = (0, _context.getFlowdata)(ctx);
2094
2111
  if (!d) return "dataNullError";
2112
+ var cellChanges = [];
2095
2113
  var has_PartMC = false;
2096
2114
  for (var s = 0; s < selection.length; s += 1) {
2097
2115
  var r1 = selection[s].row[0];
@@ -2118,13 +2136,28 @@ function fillDate(ctx) {
2118
2136
  d[r][c] = {
2119
2137
  v: formattedDate
2120
2138
  };
2139
+ cellChanges.push({
2140
+ sheetId: ctx.currentSheetId,
2141
+ path: ["celldata"],
2142
+ value: {
2143
+ r: r,
2144
+ c: c,
2145
+ v: d[r][c]
2146
+ },
2147
+ key: "".concat(r, "_").concat(c),
2148
+ type: "update"
2149
+ });
2121
2150
  }
2122
2151
  }
2123
2152
  }
2153
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
2154
+ ctx.hooks.updateCellYdoc(cellChanges);
2155
+ }
2124
2156
  }
2125
2157
  return "success";
2126
2158
  }
2127
2159
  function fillTime(ctx) {
2160
+ var _a;
2128
2161
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
2129
2162
  if (allowEdit === false) {
2130
2163
  return "allowEdit";
@@ -2133,6 +2166,7 @@ function fillTime(ctx) {
2133
2166
  if (selection && !_lodash.default.isEmpty(selection)) {
2134
2167
  var d = (0, _context.getFlowdata)(ctx);
2135
2168
  if (!d) return "dataNullError";
2169
+ var cellChanges = [];
2136
2170
  var has_PartMC = false;
2137
2171
  for (var s = 0; s < selection.length; s += 1) {
2138
2172
  var r1 = selection[s].row[0];
@@ -2159,9 +2193,23 @@ function fillTime(ctx) {
2159
2193
  d[r][c] = {
2160
2194
  v: formattedTime
2161
2195
  };
2196
+ cellChanges.push({
2197
+ sheetId: ctx.currentSheetId,
2198
+ path: ["celldata"],
2199
+ value: {
2200
+ r: r,
2201
+ c: c,
2202
+ v: d[r][c]
2203
+ },
2204
+ key: "".concat(r, "_").concat(c),
2205
+ type: "update"
2206
+ });
2162
2207
  }
2163
2208
  }
2164
2209
  }
2210
+ if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
2211
+ ctx.hooks.updateCellYdoc(cellChanges);
2212
+ }
2165
2213
  }
2166
2214
  return "success";
2167
2215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.10-yjs-6",
3
+ "version": "1.3.10-yjs-8",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",